From e5fa807e54e3c0dc996e2721b141ec3e6aa4153e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Palet?= Date: Tue, 10 Oct 2023 15:56:58 +0100 Subject: [PATCH 1/5] Rename in LogMe --- MIGRATION.md | 4 +- ...gme_credentials.md => logme_credential.md} | 12 +--- docs/index.md | 60 +++++++++++-------- ...gme_credentials.md => logme_credential.md} | 4 +- .../stackit_logme_credentials/data-source.tf | 2 +- .../stackit_logme_credentials /resource.tf | 2 +- .../{credentials => credential}/datasource.go | 28 ++++----- .../{credentials => credential}/resource.go | 48 +++++++-------- .../resource_test.go | 0 .../internal/services/logme/logme_acc_test.go | 38 ++++++------ stackit/provider.go | 6 +- 11 files changed, 103 insertions(+), 101 deletions(-) rename docs/data-sources/{logme_credentials.md => logme_credential.md} (67%) rename docs/resources/{logme_credentials.md => logme_credential.md} (88%) rename stackit/internal/services/logme/{credentials => credential}/datasource.go (80%) rename stackit/internal/services/logme/{credentials => credential}/resource.go (85%) rename stackit/internal/services/logme/{credentials => credential}/resource_test.go (100%) diff --git a/MIGRATION.md b/MIGRATION.md index a505deb0..66e3c239 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -98,7 +98,7 @@ import { import { id = "project_id,instance_id,credentials_id" - to = stackit_logme_credentials.example-credentials + to = stackit_logme_credential.example-credential } ``` @@ -120,7 +120,7 @@ resource "stackit_logme_instance" "example-instance" { } # __generated__ by Terraform from "project_id,instance_id,credentials_id" -resource "stackit_logme_credentials" "example-credentials" { +resource "stackit_logme_credential" "example-credential" { instance_id = "instance_id" project_id = "project_id" } diff --git a/docs/data-sources/logme_credentials.md b/docs/data-sources/logme_credential.md similarity index 67% rename from docs/data-sources/logme_credentials.md rename to docs/data-sources/logme_credential.md index 29c3c768..de3def98 100644 --- a/docs/data-sources/logme_credentials.md +++ b/docs/data-sources/logme_credential.md @@ -1,24 +1,16 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackit_logme_credentials Data Source - stackit" +page_title: "stackit_logme_credential Data Source - stackit" subcategory: "" description: |- LogMe credentials data source schema. --- -# stackit_logme_credentials (Data Source) +# stackit_logme_credential (Data Source) LogMe credentials data source schema. -## Example Usage -```terraform -data "stackit_logme_credentials" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -} -``` ## Schema diff --git a/docs/index.md b/docs/index.md index 389e9c4d..021cf45f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -41,13 +41,13 @@ To authenticate, you will need a [service account](https://docs.stackit.cloud/st When setting up authentication, the provider will always try to use the key flow first and search for credentials in several locations, following a specific order: -1. Explicit configuration, e.g. by seting the fiel `stackit_service_account_key_path` in the provider block (see example below) +1. Explicit configuration, e.g. by seting the field `stackit_service_account_key_path` in the provider block (see example below) 2. Environment variable, e.g. by setting `STACKIT_SERVICE_ACCOUNT_KEY_PATH` 3. Credentials file The SDK will check the credentials file located in the path defined by the `STACKIT_CREDENTIALS_PATH` env var, if specified, or in `$HOME/.stackit/credentials.json` as a fallback. - The credentials should be set using the same name as the environmnet variables. Example: + The credentials should be set using the same name as the environment variables. Example: ```json { @@ -64,32 +64,42 @@ To configure it, follow this steps: The following instructions assume that you have created a service account and assigned it the necessary permissions, e.g. project.owner. -1. In the Portal, go to `Service Account -> Service Account Keys` and create a key. - - You can create your own RSA key-pair or have the Portal generate one for you. -2. Save the content of the service account key and the corresponding private key by copying them or saving them in a file. The expected format of the service account key is the following: - ```json - { - "id": "uuid", - "publicKey": "public key", - "createdAt": "2023-08-24T14:15:22Z", - "validUntil": "2023-08-24T14:15:22Z", - "keyType": "USER_MANAGED", - "keyOrigin": "USER_PROVIDED", - "keyAlgorithm": "RSA_2048", - "active": true, - "credentials": { - "kid": "string", - "iss": "my-sa@sa.stackit.cloud", - "sub": "uuid", - "aud": "string", - (optional) "privateKey": "private key when generated by the SA service" - } - } - ``` +1. In the Portal, go to the `Service Accounts` tab, choose a `Service Account` and go to `Service Account Keys` to create a key. + +- You can create your own RSA key-pair or have the Portal generate one for you. + +**Disclaimer:** as of now, creation of a service account key in the Portal is only available in DEV and QA environments. You can use this flow in these environments by setting the fields `token_custom_endpoint` and `jwks_custom_endpoint` to the corresponding endpoints in the provider block. + +2. Save the content of the service account key and the corresponding private key by copying them or saving them in a file. + + **Hint:** If you have generated the RSA key-pair using the Portal, you can save the private key in a PEM encoded file by downloading the service account key as a PEM file and using `openssl storeutl -keys > private.key` to extract the private key from the service account key. + +The expected format of the service account key is a **json** with the following structure: + +```json +{ + "id": "uuid", + "publicKey": "public key", + "createdAt": "2023-08-24T14:15:22Z", + "validUntil": "2023-08-24T14:15:22Z", + "keyType": "USER_MANAGED", + "keyOrigin": "USER_PROVIDED", + "keyAlgorithm": "RSA_2048", + "active": true, + "credentials": { + "kid": "string", + "iss": "my-sa@sa.stackit.cloud", + "sub": "uuid", + "aud": "string", + (optional) "privateKey": "private key when generated by the SA service" + } +} +``` + 3. Configure the service account key and private key for authentication in the SDK: - setting the fiels in the provider block: `service_account_key` or `service_account_key_path`, `private_key` or `private_key_path` - setting environment variables: `STACKIT_SERVICE_ACCOUNT_KEY_PATH` and `STACKIT_PRIVATE_KEY_PATH` - - setting them in the credentials file (see above) + - setting `STACKIT_SERVICE_ACCOUNT_KEY_PATH` and `STACKIT_PRIVATE_KEY_PATH` in the credentials file (see above) ### Token flow diff --git a/docs/resources/logme_credentials.md b/docs/resources/logme_credential.md similarity index 88% rename from docs/resources/logme_credentials.md rename to docs/resources/logme_credential.md index f510cccf..9cf29d4d 100644 --- a/docs/resources/logme_credentials.md +++ b/docs/resources/logme_credential.md @@ -1,12 +1,12 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackit_logme_credentials Resource - stackit" +page_title: "stackit_logme_credential Resource - stackit" subcategory: "" description: |- LogMe credentials resource schema. --- -# stackit_logme_credentials (Resource) +# stackit_logme_credential (Resource) LogMe credentials resource schema. diff --git a/examples/data-sources/stackit_logme_credentials/data-source.tf b/examples/data-sources/stackit_logme_credentials/data-source.tf index 4522cebf..513579b8 100644 --- a/examples/data-sources/stackit_logme_credentials/data-source.tf +++ b/examples/data-sources/stackit_logme_credentials/data-source.tf @@ -1,4 +1,4 @@ -data "stackit_logme_credentials" "example" { +data "stackit_logme_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" diff --git a/examples/resources/stackit_logme_credentials /resource.tf b/examples/resources/stackit_logme_credentials /resource.tf index de522cfc..94d917f0 100644 --- a/examples/resources/stackit_logme_credentials /resource.tf +++ b/examples/resources/stackit_logme_credentials /resource.tf @@ -1,4 +1,4 @@ -resource "stackit_logme_credentials" "example" { +resource "stackit_logme_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } diff --git a/stackit/internal/services/logme/credentials/datasource.go b/stackit/internal/services/logme/credential/datasource.go similarity index 80% rename from stackit/internal/services/logme/credentials/datasource.go rename to stackit/internal/services/logme/credential/datasource.go index e572f05d..b65490f4 100644 --- a/stackit/internal/services/logme/credentials/datasource.go +++ b/stackit/internal/services/logme/credential/datasource.go @@ -18,26 +18,26 @@ import ( // Ensure the implementation satisfies the expected interfaces. var ( - _ datasource.DataSource = &credentialsDataSource{} + _ datasource.DataSource = &credentialDataSource{} ) -// NewCredentialsDataSource is a helper function to simplify the provider implementation. -func NewCredentialsDataSource() datasource.DataSource { - return &credentialsDataSource{} +// NewCredentialDataSource is a helper function to simplify the provider implementation. +func NewCredentialDataSource() datasource.DataSource { + return &credentialDataSource{} } -// credentialsDataSource is the data source implementation. -type credentialsDataSource struct { +// credentialDataSource is the data source implementation. +type credentialDataSource struct { client *logme.APIClient } // Metadata returns the data source type name. -func (r *credentialsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_logme_credentials" +func (r *credentialDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_logme_credential" } // Configure adds the provider configured client to the data source. -func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { +func (r *credentialDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -69,13 +69,13 @@ func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.Co } r.client = apiClient - tflog.Info(ctx, "LogMe credentials client configured") + tflog.Info(ctx, "LogMe credential client configured") } // Schema defines the schema for the data source. -func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { +func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { descriptions := map[string]string{ - "main": "LogMe credentials data source schema.", + "main": "LogMe credential data source schema.", "id": "Terraform's internal data source. identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".", "credentials_id": "The credentials ID.", "instance_id": "ID of the LogMe instance.", @@ -144,7 +144,7 @@ func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaReq } // Read refreshes the Terraform state with the latest data. -func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.Config.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -177,5 +177,5 @@ func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadReq if resp.Diagnostics.HasError() { return } - tflog.Info(ctx, "LogMe credentials read") + tflog.Info(ctx, "LogMe credential read") } diff --git a/stackit/internal/services/logme/credentials/resource.go b/stackit/internal/services/logme/credential/resource.go similarity index 85% rename from stackit/internal/services/logme/credentials/resource.go rename to stackit/internal/services/logme/credential/resource.go index 92fc0b48..b6e74c3d 100644 --- a/stackit/internal/services/logme/credentials/resource.go +++ b/stackit/internal/services/logme/credential/resource.go @@ -26,9 +26,9 @@ import ( // Ensure the implementation satisfies the expected interfaces. var ( - _ resource.Resource = &credentialsResource{} - _ resource.ResourceWithConfigure = &credentialsResource{} - _ resource.ResourceWithImportState = &credentialsResource{} + _ resource.Resource = &credentialResource{} + _ resource.ResourceWithConfigure = &credentialResource{} + _ resource.ResourceWithImportState = &credentialResource{} ) type Model struct { @@ -46,23 +46,23 @@ type Model struct { Username types.String `tfsdk:"username"` } -// NewCredentialsResource is a helper function to simplify the provider implementation. -func NewCredentialsResource() resource.Resource { - return &credentialsResource{} +// NewCredentialResource is a helper function to simplify the provider implementation. +func NewCredentialResource() resource.Resource { + return &credentialResource{} } -// credentialsResource is the resource implementation. -type credentialsResource struct { +// credentialResource is the resource implementation. +type credentialResource struct { client *logme.APIClient } // Metadata returns the resource type name. -func (r *credentialsResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_logme_credentials" +func (r *credentialResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_logme_credential" } // Configure adds the provider configured client to the resource. -func (r *credentialsResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { +func (r *credentialResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -94,13 +94,13 @@ func (r *credentialsResource) Configure(ctx context.Context, req resource.Config } r.client = apiClient - tflog.Info(ctx, "LogMe credentials client configured") + tflog.Info(ctx, "LogMe credential client configured") } // Schema defines the schema for the resource. -func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { descriptions := map[string]string{ - "main": "LogMe credentials resource schema.", + "main": "LogMe credential resource schema.", "id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".", "credentials_id": "The credentials ID.", "instance_id": "ID of the LogMe instance.", @@ -183,7 +183,7 @@ func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest } // Create creates the resource and sets the initial Terraform state. -func (r *credentialsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.Plan.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -230,11 +230,11 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq if resp.Diagnostics.HasError() { return } - tflog.Info(ctx, "LogMe credentials created") + tflog.Info(ctx, "LogMe credential created") } // Read refreshes the Terraform state with the latest data. -func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.State.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -267,17 +267,17 @@ func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest if resp.Diagnostics.HasError() { return } - tflog.Info(ctx, "LogMe credentials read") + tflog.Info(ctx, "LogMe credential read") } // Update updates the resource and sets the updated Terraform state on success. -func (r *credentialsResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform // Update shouldn't be called - core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated") + core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "credential can't be updated") } // Delete deletes the resource and removes the Terraform state on success. -func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.State.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -302,12 +302,12 @@ func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteReq core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Instance deletion waiting: %v", err)) return } - tflog.Info(ctx, "LogMe credentials deleted") + tflog.Info(ctx, "LogMe credential deleted") } // ImportState imports a resource into the Terraform state on success. // The expected format of the resource import identifier is: project_id,instance_id,credentials_id -func (r *credentialsResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { +func (r *credentialResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" { core.LogAndAddError(ctx, &resp.Diagnostics, @@ -320,7 +320,7 @@ func (r *credentialsResource) ImportState(ctx context.Context, req resource.Impo resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...) resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[1])...) resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("credentials_id"), idParts[2])...) - tflog.Info(ctx, "LogMe credentials state imported") + tflog.Info(ctx, "LogMe credential state imported") } func mapFields(credentialsResp *logme.CredentialsResponse, model *Model) error { diff --git a/stackit/internal/services/logme/credentials/resource_test.go b/stackit/internal/services/logme/credential/resource_test.go similarity index 100% rename from stackit/internal/services/logme/credentials/resource_test.go rename to stackit/internal/services/logme/credential/resource_test.go diff --git a/stackit/internal/services/logme/logme_acc_test.go b/stackit/internal/services/logme/logme_acc_test.go index 4cf56321..a59a1104 100644 --- a/stackit/internal/services/logme/logme_acc_test.go +++ b/stackit/internal/services/logme/logme_acc_test.go @@ -41,7 +41,7 @@ func resourceConfig(acls string) string { } } - resource "stackit_logme_credentials" "credentials" { + resource "stackit_logme_credential" "credentials" { project_id = stackit_logme_instance.instance.project_id instance_id = stackit_logme_instance.instance.instance_id } @@ -75,15 +75,15 @@ func TestAccLogMeResource(t *testing.T) { // Credentials data resource.TestCheckResourceAttrPair( - "stackit_logme_credentials.credentials", "project_id", + "stackit_logme_credential.credentials", "project_id", "stackit_logme_instance.instance", "project_id", ), resource.TestCheckResourceAttrPair( - "stackit_logme_credentials.credentials", "instance_id", + "stackit_logme_credential.credentials", "instance_id", "stackit_logme_instance.instance", "instance_id", ), - resource.TestCheckResourceAttrSet("stackit_logme_credentials.credentials", "credentials_id"), - resource.TestCheckResourceAttrSet("stackit_logme_credentials.credentials", "host"), + resource.TestCheckResourceAttrSet("stackit_logme_credential.credentials", "credentials_id"), + resource.TestCheckResourceAttrSet("stackit_logme_credential.credentials", "host"), ), }, // Data source @@ -96,10 +96,10 @@ func TestAccLogMeResource(t *testing.T) { instance_id = stackit_logme_instance.instance.instance_id } - data "stackit_logme_credentials" "credentials" { - project_id = stackit_logme_credentials.credentials.project_id - instance_id = stackit_logme_credentials.credentials.instance_id - credentials_id = stackit_logme_credentials.credentials.credentials_id + data "stackit_logme_credential" "credentials" { + project_id = stackit_logme_credential.credentials.project_id + instance_id = stackit_logme_credential.credentials.instance_id + credentials_id = stackit_logme_credential.credentials.credentials_id }`, resourceConfig(instanceResource["sgw_acl-1"]), ), @@ -109,18 +109,18 @@ func TestAccLogMeResource(t *testing.T) { resource.TestCheckResourceAttrPair("stackit_logme_instance.instance", "instance_id", "data.stackit_logme_instance.instance", "instance_id"), - resource.TestCheckResourceAttrPair("stackit_logme_credentials.credentials", "credentials_id", - "data.stackit_logme_credentials.credentials", "credentials_id"), + resource.TestCheckResourceAttrPair("stackit_logme_credential.credentials", "credentials_id", + "data.stackit_logme_credential.credentials", "credentials_id"), resource.TestCheckResourceAttr("data.stackit_logme_instance.instance", "plan_id", instanceResource["plan_id"]), resource.TestCheckResourceAttr("data.stackit_logme_instance.instance", "name", instanceResource["name"]), resource.TestCheckResourceAttr("data.stackit_logme_instance.instance", "parameters.sgw_acl", instanceResource["sgw_acl-1"]), // Credentials data - resource.TestCheckResourceAttr("data.stackit_logme_credentials.credentials", "project_id", instanceResource["project_id"]), - resource.TestCheckResourceAttrSet("data.stackit_logme_credentials.credentials", "credentials_id"), - resource.TestCheckResourceAttrSet("data.stackit_logme_credentials.credentials", "host"), - resource.TestCheckResourceAttrSet("data.stackit_logme_credentials.credentials", "port"), - resource.TestCheckResourceAttrSet("data.stackit_logme_credentials.credentials", "uri"), + resource.TestCheckResourceAttr("data.stackit_logme_credential.credentials", "project_id", instanceResource["project_id"]), + resource.TestCheckResourceAttrSet("data.stackit_logme_credential.credentials", "credentials_id"), + resource.TestCheckResourceAttrSet("data.stackit_logme_credential.credentials", "host"), + resource.TestCheckResourceAttrSet("data.stackit_logme_credential.credentials", "port"), + resource.TestCheckResourceAttrSet("data.stackit_logme_credential.credentials", "uri"), ), }, // Import @@ -141,11 +141,11 @@ func TestAccLogMeResource(t *testing.T) { ImportStateVerify: true, }, { - ResourceName: "stackit_logme_credentials.credentials", + ResourceName: "stackit_logme_credential.credentials", ImportStateIdFunc: func(s *terraform.State) (string, error) { - r, ok := s.RootModule().Resources["stackit_logme_credentials.credentials"] + r, ok := s.RootModule().Resources["stackit_logme_credential.credentials"] if !ok { - return "", fmt.Errorf("couldn't find resource stackit_logme_credentials.credentials") + return "", fmt.Errorf("couldn't find resource stackit_logme_credential.credentials") } instanceId, ok := r.Primary.Attributes["instance_id"] if !ok { diff --git a/stackit/provider.go b/stackit/provider.go index deda860c..79138c03 100644 --- a/stackit/provider.go +++ b/stackit/provider.go @@ -14,7 +14,7 @@ import ( argusScrapeConfig "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/argus/scrapeconfig" dnsRecordSet "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/dns/recordset" dnsZone "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/dns/zone" - logMeCredentials "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/logme/credentials" + logMeCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/logme/credential" logMeInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/logme/instance" mariaDBCredentials "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/mariadb/credentials" mariaDBInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/mariadb/instance" @@ -309,7 +309,7 @@ func (p *Provider) DataSources(_ context.Context) []func() datasource.DataSource postgresInstance.NewInstanceDataSource, postgresCredentials.NewCredentialsDataSource, logMeInstance.NewInstanceDataSource, - logMeCredentials.NewCredentialsDataSource, + logMeCredential.NewCredentialDataSource, mariaDBInstance.NewInstanceDataSource, mariaDBCredentials.NewCredentialsDataSource, objectStorageBucket.NewBucketDataSource, @@ -337,7 +337,7 @@ func (p *Provider) Resources(_ context.Context) []func() resource.Resource { postgresInstance.NewInstanceResource, postgresCredentials.NewCredentialsResource, logMeInstance.NewInstanceResource, - logMeCredentials.NewCredentialsResource, + logMeCredential.NewCredentialResource, mariaDBInstance.NewInstanceResource, mariaDBCredentials.NewCredentialsResource, objectStorageBucket.NewBucketResource, From 90852bc8a9e3a6820318971dc06a84aa927be449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Palet?= Date: Tue, 10 Oct 2023 18:29:17 +0100 Subject: [PATCH 2/5] Rename in other DSA --- docs/data-sources/logme_credential.md | 4 +- ...b_credentials.md => mariadb_credential.md} | 16 ++------ docs/data-sources/objectstorage_bucket.md | 4 +- ...redentials.md => opensearch_credential.md} | 16 ++------ ...redentials.md => postgresql_credential.md} | 16 ++------ ..._credentials.md => rabbitmq_credential.md} | 16 ++------ ...dis_credentials.md => redis_credential.md} | 16 ++------ docs/resources/logme_credential.md | 4 +- ...b_credentials.md => mariadb_credential.md} | 15 ++----- ...redentials.md => opensearch_credential.md} | 15 ++----- ...redentials.md => postgresql_credential.md} | 15 ++----- ..._credentials.md => rabbitmq_credential.md} | 15 ++----- ...dis_credentials.md => redis_credential.md} | 15 ++----- .../data-source.tf | 2 +- .../data-source.tf | 2 +- .../data-source.tf | 2 +- .../data-source.tf | 2 +- .../stackit_redis_credentials/data-source.tf | 2 +- .../stackit_mariadb_credentials/resource.tf | 2 +- .../resource.tf | 2 +- .../resource.tf | 2 +- .../stackit_rabbitmq_credentials/resource.tf | 2 +- .../stackit_redis_credentials/resource.tf | 2 +- .../internal/services/argus/argus_acc_test.go | 4 +- .../services/logme/credential/datasource.go | 4 +- .../services/logme/credential/resource.go | 10 ++--- .../logme/credential/resource_test.go | 2 +- .../mariadb/credentials/datasource.go | 24 +++++------ .../services/mariadb/credentials/resource.go | 36 ++++++++--------- .../mariadb/credentials/resource_test.go | 2 +- .../services/mariadb/mariadb_acc_test.go | 38 +++++++++--------- .../objectstorage/bucket/datasource.go | 2 +- .../opensearch/credentials/datasource.go | 24 +++++------ .../opensearch/credentials/resource.go | 36 ++++++++--------- .../opensearch/credentials/resource_test.go | 2 +- .../opensearch/opensearch_acc_test.go | 40 +++++++++---------- .../postgresql/credentials/datasource.go | 24 +++++------ .../postgresql/credentials/resource.go | 36 ++++++++--------- .../postgresql/credentials/resource_test.go | 2 +- .../postgresql/postgresql_acc_test.go | 38 +++++++++--------- .../rabbitmq/credentials/datasource.go | 24 +++++------ .../services/rabbitmq/credentials/resource.go | 36 ++++++++--------- .../rabbitmq/credentials/resource_test.go | 2 +- .../services/rabbitmq/rabbitmq_acc_test.go | 38 +++++++++--------- .../services/redis/credentials/datasource.go | 24 +++++------ .../services/redis/credentials/resource.go | 36 ++++++++--------- .../redis/credentials/resource_test.go | 2 +- .../internal/services/redis/redis_acc_test.go | 38 +++++++++--------- stackit/provider.go | 30 +++++++------- 49 files changed, 333 insertions(+), 408 deletions(-) rename docs/data-sources/{mariadb_credentials.md => mariadb_credential.md} (60%) rename docs/data-sources/{opensearch_credentials.md => opensearch_credential.md} (59%) rename docs/data-sources/{postgresql_credentials.md => postgresql_credential.md} (59%) rename docs/data-sources/{rabbitmq_credentials.md => rabbitmq_credential.md} (60%) rename docs/data-sources/{redis_credentials.md => redis_credential.md} (60%) rename docs/resources/{mariadb_credentials.md => mariadb_credential.md} (64%) rename docs/resources/{opensearch_credentials.md => opensearch_credential.md} (63%) rename docs/resources/{postgresql_credentials.md => postgresql_credential.md} (63%) rename docs/resources/{rabbitmq_credentials.md => rabbitmq_credential.md} (64%) rename docs/resources/{redis_credentials.md => redis_credential.md} (64%) diff --git a/docs/data-sources/logme_credential.md b/docs/data-sources/logme_credential.md index de3def98..40d38f57 100644 --- a/docs/data-sources/logme_credential.md +++ b/docs/data-sources/logme_credential.md @@ -3,12 +3,12 @@ page_title: "stackit_logme_credential Data Source - stackit" subcategory: "" description: |- - LogMe credentials data source schema. + LogMe credential data source schema. --- # stackit_logme_credential (Data Source) -LogMe credentials data source schema. +LogMe credential data source schema. diff --git a/docs/data-sources/mariadb_credentials.md b/docs/data-sources/mariadb_credential.md similarity index 60% rename from docs/data-sources/mariadb_credentials.md rename to docs/data-sources/mariadb_credential.md index 87bc9de3..0fb323a3 100644 --- a/docs/data-sources/mariadb_credentials.md +++ b/docs/data-sources/mariadb_credential.md @@ -1,24 +1,16 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackit_mariadb_credentials Data Source - stackit" +page_title: "stackit_mariadb_credential Data Source - stackit" subcategory: "" description: |- - MariaDB credentials data source schema. + MariaDB credential data source schema. --- -# stackit_mariadb_credentials (Data Source) +# stackit_mariadb_credential (Data Source) -MariaDB credentials data source schema. +MariaDB credential data source schema. -## Example Usage -```terraform -data "stackit_mariadb_credentials" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -} -``` ## Schema diff --git a/docs/data-sources/objectstorage_bucket.md b/docs/data-sources/objectstorage_bucket.md index 223d1599..f96f4cf7 100644 --- a/docs/data-sources/objectstorage_bucket.md +++ b/docs/data-sources/objectstorage_bucket.md @@ -3,12 +3,12 @@ page_title: "stackit_objectstorage_bucket Data Source - stackit" subcategory: "" description: |- - ObjectStorage credentials data source schema. + ObjectStorage credential data source schema. --- # stackit_objectstorage_bucket (Data Source) -ObjectStorage credentials data source schema. +ObjectStorage credential data source schema. diff --git a/docs/data-sources/opensearch_credentials.md b/docs/data-sources/opensearch_credential.md similarity index 59% rename from docs/data-sources/opensearch_credentials.md rename to docs/data-sources/opensearch_credential.md index d6a80264..35fbf236 100644 --- a/docs/data-sources/opensearch_credentials.md +++ b/docs/data-sources/opensearch_credential.md @@ -1,24 +1,16 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackit_opensearch_credentials Data Source - stackit" +page_title: "stackit_opensearch_credential Data Source - stackit" subcategory: "" description: |- - OpenSearch credentials data source schema. + OpenSearch credential data source schema. --- -# stackit_opensearch_credentials (Data Source) +# stackit_opensearch_credential (Data Source) -OpenSearch credentials data source schema. +OpenSearch credential data source schema. -## Example Usage -```terraform -data "stackit_opensearch_credentials" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -} -``` ## Schema diff --git a/docs/data-sources/postgresql_credentials.md b/docs/data-sources/postgresql_credential.md similarity index 59% rename from docs/data-sources/postgresql_credentials.md rename to docs/data-sources/postgresql_credential.md index d0c282d3..25754726 100644 --- a/docs/data-sources/postgresql_credentials.md +++ b/docs/data-sources/postgresql_credential.md @@ -1,24 +1,16 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackit_postgresql_credentials Data Source - stackit" +page_title: "stackit_postgresql_credential Data Source - stackit" subcategory: "" description: |- - PostgreSQL credentials data source schema. + PostgreSQL credential data source schema. --- -# stackit_postgresql_credentials (Data Source) +# stackit_postgresql_credential (Data Source) -PostgreSQL credentials data source schema. +PostgreSQL credential data source schema. -## Example Usage -```terraform -data "stackit_postgresql_credentials" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -} -``` ## Schema diff --git a/docs/data-sources/rabbitmq_credentials.md b/docs/data-sources/rabbitmq_credential.md similarity index 60% rename from docs/data-sources/rabbitmq_credentials.md rename to docs/data-sources/rabbitmq_credential.md index b1ad93c8..692206bf 100644 --- a/docs/data-sources/rabbitmq_credentials.md +++ b/docs/data-sources/rabbitmq_credential.md @@ -1,24 +1,16 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackit_rabbitmq_credentials Data Source - stackit" +page_title: "stackit_rabbitmq_credential Data Source - stackit" subcategory: "" description: |- - RabbitMQ credentials data source schema. + RabbitMQ credential data source schema. --- -# stackit_rabbitmq_credentials (Data Source) +# stackit_rabbitmq_credential (Data Source) -RabbitMQ credentials data source schema. +RabbitMQ credential data source schema. -## Example Usage -```terraform -data "stackit_rabbitmq_credentials" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -} -``` ## Schema diff --git a/docs/data-sources/redis_credentials.md b/docs/data-sources/redis_credential.md similarity index 60% rename from docs/data-sources/redis_credentials.md rename to docs/data-sources/redis_credential.md index da785305..7089eb1a 100644 --- a/docs/data-sources/redis_credentials.md +++ b/docs/data-sources/redis_credential.md @@ -1,24 +1,16 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackit_redis_credentials Data Source - stackit" +page_title: "stackit_redis_credential Data Source - stackit" subcategory: "" description: |- - Redis credentials data source schema. + Redis credential data source schema. --- -# stackit_redis_credentials (Data Source) +# stackit_redis_credential (Data Source) -Redis credentials data source schema. +Redis credential data source schema. -## Example Usage -```terraform -data "stackit_redis_credentials" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -} -``` ## Schema diff --git a/docs/resources/logme_credential.md b/docs/resources/logme_credential.md index 9cf29d4d..ad63185b 100644 --- a/docs/resources/logme_credential.md +++ b/docs/resources/logme_credential.md @@ -3,12 +3,12 @@ page_title: "stackit_logme_credential Resource - stackit" subcategory: "" description: |- - LogMe credentials resource schema. + LogMe credential resource schema. --- # stackit_logme_credential (Resource) -LogMe credentials resource schema. +LogMe credential resource schema. diff --git a/docs/resources/mariadb_credentials.md b/docs/resources/mariadb_credential.md similarity index 64% rename from docs/resources/mariadb_credentials.md rename to docs/resources/mariadb_credential.md index 22c495d1..2819fe28 100644 --- a/docs/resources/mariadb_credentials.md +++ b/docs/resources/mariadb_credential.md @@ -1,23 +1,16 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackit_mariadb_credentials Resource - stackit" +page_title: "stackit_mariadb_credential Resource - stackit" subcategory: "" description: |- - MariaDB credentials resource schema. + MariaDB credential resource schema. --- -# stackit_mariadb_credentials (Resource) +# stackit_mariadb_credential (Resource) -MariaDB credentials resource schema. +MariaDB credential resource schema. -## Example Usage -```terraform -resource "stackit_mariadb_credentials" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -} -``` ## Schema diff --git a/docs/resources/opensearch_credentials.md b/docs/resources/opensearch_credential.md similarity index 63% rename from docs/resources/opensearch_credentials.md rename to docs/resources/opensearch_credential.md index 9f0140c5..d8adef7a 100644 --- a/docs/resources/opensearch_credentials.md +++ b/docs/resources/opensearch_credential.md @@ -1,23 +1,16 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackit_opensearch_credentials Resource - stackit" +page_title: "stackit_opensearch_credential Resource - stackit" subcategory: "" description: |- - OpenSearch credentials resource schema. + OpenSearch credential resource schema. --- -# stackit_opensearch_credentials (Resource) +# stackit_opensearch_credential (Resource) -OpenSearch credentials resource schema. +OpenSearch credential resource schema. -## Example Usage -```terraform -resource "stackit_opensearch_credentials" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -} -``` ## Schema diff --git a/docs/resources/postgresql_credentials.md b/docs/resources/postgresql_credential.md similarity index 63% rename from docs/resources/postgresql_credentials.md rename to docs/resources/postgresql_credential.md index 82e5b091..c3b8a61f 100644 --- a/docs/resources/postgresql_credentials.md +++ b/docs/resources/postgresql_credential.md @@ -1,23 +1,16 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackit_postgresql_credentials Resource - stackit" +page_title: "stackit_postgresql_credential Resource - stackit" subcategory: "" description: |- - PostgreSQL credentials resource schema. + PostgreSQL credential resource schema. --- -# stackit_postgresql_credentials (Resource) +# stackit_postgresql_credential (Resource) -PostgreSQL credentials resource schema. +PostgreSQL credential resource schema. -## Example Usage -```terraform -resource "stackit_postgresql_credentials" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -} -``` ## Schema diff --git a/docs/resources/rabbitmq_credentials.md b/docs/resources/rabbitmq_credential.md similarity index 64% rename from docs/resources/rabbitmq_credentials.md rename to docs/resources/rabbitmq_credential.md index d9011d4f..8a872c76 100644 --- a/docs/resources/rabbitmq_credentials.md +++ b/docs/resources/rabbitmq_credential.md @@ -1,23 +1,16 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackit_rabbitmq_credentials Resource - stackit" +page_title: "stackit_rabbitmq_credential Resource - stackit" subcategory: "" description: |- - RabbitMQ credentials resource schema. + RabbitMQ credential resource schema. --- -# stackit_rabbitmq_credentials (Resource) +# stackit_rabbitmq_credential (Resource) -RabbitMQ credentials resource schema. +RabbitMQ credential resource schema. -## Example Usage -```terraform -resource "stackit_rabbitmq_credentials" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -} -``` ## Schema diff --git a/docs/resources/redis_credentials.md b/docs/resources/redis_credential.md similarity index 64% rename from docs/resources/redis_credentials.md rename to docs/resources/redis_credential.md index f504691d..27a1575a 100644 --- a/docs/resources/redis_credentials.md +++ b/docs/resources/redis_credential.md @@ -1,23 +1,16 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "stackit_redis_credentials Resource - stackit" +page_title: "stackit_redis_credential Resource - stackit" subcategory: "" description: |- - Redis credentials resource schema. + Redis credential resource schema. --- -# stackit_redis_credentials (Resource) +# stackit_redis_credential (Resource) -Redis credentials resource schema. +Redis credential resource schema. -## Example Usage -```terraform -resource "stackit_redis_credentials" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -} -``` ## Schema diff --git a/examples/data-sources/stackit_mariadb_credentials/data-source.tf b/examples/data-sources/stackit_mariadb_credentials/data-source.tf index 8a6c8734..7e8fbe10 100644 --- a/examples/data-sources/stackit_mariadb_credentials/data-source.tf +++ b/examples/data-sources/stackit_mariadb_credentials/data-source.tf @@ -1,4 +1,4 @@ -data "stackit_mariadb_credentials" "example" { +data "stackit_mariadb_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" diff --git a/examples/data-sources/stackit_opensearch_credentials/data-source.tf b/examples/data-sources/stackit_opensearch_credentials/data-source.tf index 5d27b545..c380fd50 100644 --- a/examples/data-sources/stackit_opensearch_credentials/data-source.tf +++ b/examples/data-sources/stackit_opensearch_credentials/data-source.tf @@ -1,4 +1,4 @@ -data "stackit_opensearch_credentials" "example" { +data "stackit_opensearch_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" diff --git a/examples/data-sources/stackit_postgresql_credentials/data-source.tf b/examples/data-sources/stackit_postgresql_credentials/data-source.tf index cf918f17..dd53a75d 100644 --- a/examples/data-sources/stackit_postgresql_credentials/data-source.tf +++ b/examples/data-sources/stackit_postgresql_credentials/data-source.tf @@ -1,4 +1,4 @@ -data "stackit_postgresql_credentials" "example" { +data "stackit_postgresql_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" diff --git a/examples/data-sources/stackit_rabbitmq_credentials/data-source.tf b/examples/data-sources/stackit_rabbitmq_credentials/data-source.tf index 26ccb0db..37827ec6 100644 --- a/examples/data-sources/stackit_rabbitmq_credentials/data-source.tf +++ b/examples/data-sources/stackit_rabbitmq_credentials/data-source.tf @@ -1,4 +1,4 @@ -data "stackit_rabbitmq_credentials" "example" { +data "stackit_rabbitmq_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" diff --git a/examples/data-sources/stackit_redis_credentials/data-source.tf b/examples/data-sources/stackit_redis_credentials/data-source.tf index 46289780..08bba4c3 100644 --- a/examples/data-sources/stackit_redis_credentials/data-source.tf +++ b/examples/data-sources/stackit_redis_credentials/data-source.tf @@ -1,4 +1,4 @@ -data "stackit_redis_credentials" "example" { +data "stackit_redis_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" diff --git a/examples/resources/stackit_mariadb_credentials/resource.tf b/examples/resources/stackit_mariadb_credentials/resource.tf index 11d72f0f..0b6d2c3f 100644 --- a/examples/resources/stackit_mariadb_credentials/resource.tf +++ b/examples/resources/stackit_mariadb_credentials/resource.tf @@ -1,4 +1,4 @@ -resource "stackit_mariadb_credentials" "example" { +resource "stackit_mariadb_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } diff --git a/examples/resources/stackit_opensearch_credentials/resource.tf b/examples/resources/stackit_opensearch_credentials/resource.tf index f1d1325a..24d75424 100644 --- a/examples/resources/stackit_opensearch_credentials/resource.tf +++ b/examples/resources/stackit_opensearch_credentials/resource.tf @@ -1,4 +1,4 @@ -resource "stackit_opensearch_credentials" "example" { +resource "stackit_opensearch_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } diff --git a/examples/resources/stackit_postgresql_credentials/resource.tf b/examples/resources/stackit_postgresql_credentials/resource.tf index 0775c2cf..a4e29f91 100644 --- a/examples/resources/stackit_postgresql_credentials/resource.tf +++ b/examples/resources/stackit_postgresql_credentials/resource.tf @@ -1,4 +1,4 @@ -resource "stackit_postgresql_credentials" "example" { +resource "stackit_postgresql_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } diff --git a/examples/resources/stackit_rabbitmq_credentials/resource.tf b/examples/resources/stackit_rabbitmq_credentials/resource.tf index 922d0d4f..7c860c8e 100644 --- a/examples/resources/stackit_rabbitmq_credentials/resource.tf +++ b/examples/resources/stackit_rabbitmq_credentials/resource.tf @@ -1,4 +1,4 @@ -resource "stackit_rabbitmq_credentials" "example" { +resource "stackit_rabbitmq_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } diff --git a/examples/resources/stackit_redis_credentials/resource.tf b/examples/resources/stackit_redis_credentials/resource.tf index 0e89eb2e..c39d45e9 100644 --- a/examples/resources/stackit_redis_credentials/resource.tf +++ b/examples/resources/stackit_redis_credentials/resource.tf @@ -1,4 +1,4 @@ -resource "stackit_redis_credentials" "example" { +resource "stackit_redis_credential" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } diff --git a/stackit/internal/services/argus/argus_acc_test.go b/stackit/internal/services/argus/argus_acc_test.go index c34c7b52..e68bd50c 100644 --- a/stackit/internal/services/argus/argus_acc_test.go +++ b/stackit/internal/services/argus/argus_acc_test.go @@ -33,7 +33,7 @@ var scrapeConfigResource = map[string]string{ "saml2_enable_url_parameters": "false", } -var credentialsResource = map[string]string{ +var credentialResource = map[string]string{ "project_id": testutil.ProjectId, } @@ -129,7 +129,7 @@ func TestAccResource(t *testing.T) { resource.TestCheckResourceAttr("stackit_argus_scrapeconfig.scrapeconfig", "saml2.enable_url_parameters", scrapeConfigResource["saml2_enable_url_parameters"]), // credentials - resource.TestCheckResourceAttr("stackit_argus_credential.credential", "project_id", credentialsResource["project_id"]), + resource.TestCheckResourceAttr("stackit_argus_credential.credential", "project_id", credentialResource["project_id"]), resource.TestCheckResourceAttrPair( "stackit_argus_instance.instance", "instance_id", "stackit_argus_credential.credential", "instance_id", diff --git a/stackit/internal/services/logme/credential/datasource.go b/stackit/internal/services/logme/credential/datasource.go index b65490f4..248c4f3e 100644 --- a/stackit/internal/services/logme/credential/datasource.go +++ b/stackit/internal/services/logme/credential/datasource.go @@ -69,7 +69,7 @@ func (r *credentialDataSource) Configure(ctx context.Context, req datasource.Con } r.client = apiClient - tflog.Info(ctx, "LogMe credential client configured") + tflog.Info(ctx, "LogMe credentials client configured") } // Schema defines the schema for the data source. @@ -177,5 +177,5 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ if resp.Diagnostics.HasError() { return } - tflog.Info(ctx, "LogMe credential read") + tflog.Info(ctx, "LogMe credentials read") } diff --git a/stackit/internal/services/logme/credential/resource.go b/stackit/internal/services/logme/credential/resource.go index b6e74c3d..7890f034 100644 --- a/stackit/internal/services/logme/credential/resource.go +++ b/stackit/internal/services/logme/credential/resource.go @@ -94,7 +94,7 @@ func (r *credentialResource) Configure(ctx context.Context, req resource.Configu } r.client = apiClient - tflog.Info(ctx, "LogMe credential client configured") + tflog.Info(ctx, "LogMe credentials client configured") } // Schema defines the schema for the resource. @@ -230,7 +230,7 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ if resp.Diagnostics.HasError() { return } - tflog.Info(ctx, "LogMe credential created") + tflog.Info(ctx, "LogMe credentials created") } // Read refreshes the Terraform state with the latest data. @@ -267,7 +267,7 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, if resp.Diagnostics.HasError() { return } - tflog.Info(ctx, "LogMe credential read") + tflog.Info(ctx, "LogMe credentials read") } // Update updates the resource and sets the updated Terraform state on success. @@ -302,7 +302,7 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Instance deletion waiting: %v", err)) return } - tflog.Info(ctx, "LogMe credential deleted") + tflog.Info(ctx, "LogMe credentials deleted") } // ImportState imports a resource into the Terraform state on success. @@ -320,7 +320,7 @@ func (r *credentialResource) ImportState(ctx context.Context, req resource.Impor resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...) resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[1])...) resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("credentials_id"), idParts[2])...) - tflog.Info(ctx, "LogMe credential state imported") + tflog.Info(ctx, "LogMe credentials state imported") } func mapFields(credentialsResp *logme.CredentialsResponse, model *Model) error { diff --git a/stackit/internal/services/logme/credential/resource_test.go b/stackit/internal/services/logme/credential/resource_test.go index fd53c26c..e690f781 100644 --- a/stackit/internal/services/logme/credential/resource_test.go +++ b/stackit/internal/services/logme/credential/resource_test.go @@ -124,7 +124,7 @@ func TestMapFields(t *testing.T) { false, }, { - "nil_raw_credentials", + "nil_raw_credential", &logme.CredentialsResponse{ Id: utils.Ptr("cid"), }, diff --git a/stackit/internal/services/mariadb/credentials/datasource.go b/stackit/internal/services/mariadb/credentials/datasource.go index a018ab73..659ccbea 100644 --- a/stackit/internal/services/mariadb/credentials/datasource.go +++ b/stackit/internal/services/mariadb/credentials/datasource.go @@ -18,26 +18,26 @@ import ( // Ensure the implementation satisfies the expected interfaces. var ( - _ datasource.DataSource = &credentialsDataSource{} + _ datasource.DataSource = &credentialDataSource{} ) -// NewCredentialsDataSource is a helper function to simplify the provider implementation. -func NewCredentialsDataSource() datasource.DataSource { - return &credentialsDataSource{} +// NewCredentialDataSource is a helper function to simplify the provider implementation. +func NewCredentialDataSource() datasource.DataSource { + return &credentialDataSource{} } -// credentialsDataSource is the data source implementation. -type credentialsDataSource struct { +// credentialDataSource is the data source implementation. +type credentialDataSource struct { client *mariadb.APIClient } // Metadata returns the data source type name. -func (r *credentialsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_mariadb_credentials" +func (r *credentialDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_mariadb_credential" } // Configure adds the provider configured client to the data source. -func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { +func (r *credentialDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -73,9 +73,9 @@ func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.Co } // Schema defines the schema for the data source. -func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { +func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { descriptions := map[string]string{ - "main": "MariaDB credentials data source schema.", + "main": "MariaDB credential data source schema.", "id": "Terraform's internal data source. identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".", "credentials_id": "The credentials ID.", "instance_id": "ID of the MariaDB instance.", @@ -144,7 +144,7 @@ func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaReq } // Read refreshes the Terraform state with the latest data. -func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.Config.Get(ctx, &model) resp.Diagnostics.Append(diags...) diff --git a/stackit/internal/services/mariadb/credentials/resource.go b/stackit/internal/services/mariadb/credentials/resource.go index 73cd5e56..a46b1bc7 100644 --- a/stackit/internal/services/mariadb/credentials/resource.go +++ b/stackit/internal/services/mariadb/credentials/resource.go @@ -26,9 +26,9 @@ import ( // Ensure the implementation satisfies the expected interfaces. var ( - _ resource.Resource = &credentialsResource{} - _ resource.ResourceWithConfigure = &credentialsResource{} - _ resource.ResourceWithImportState = &credentialsResource{} + _ resource.Resource = &credentialResource{} + _ resource.ResourceWithConfigure = &credentialResource{} + _ resource.ResourceWithImportState = &credentialResource{} ) type Model struct { @@ -46,23 +46,23 @@ type Model struct { Username types.String `tfsdk:"username"` } -// NewCredentialsResource is a helper function to simplify the provider implementation. -func NewCredentialsResource() resource.Resource { - return &credentialsResource{} +// NewCredentialResource is a helper function to simplify the provider implementation. +func NewCredentialResource() resource.Resource { + return &credentialResource{} } -// credentialsResource is the resource implementation. -type credentialsResource struct { +// credentialResource is the resource implementation. +type credentialResource struct { client *mariadb.APIClient } // Metadata returns the resource type name. -func (r *credentialsResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_mariadb_credentials" +func (r *credentialResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_mariadb_credential" } // Configure adds the provider configured client to the resource. -func (r *credentialsResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { +func (r *credentialResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -98,9 +98,9 @@ func (r *credentialsResource) Configure(ctx context.Context, req resource.Config } // Schema defines the schema for the resource. -func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { descriptions := map[string]string{ - "main": "MariaDB credentials resource schema.", + "main": "MariaDB credential resource schema.", "id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".", "credentials_id": "The credentials ID.", "instance_id": "ID of the MariaDB instance.", @@ -183,7 +183,7 @@ func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest } // Create creates the resource and sets the initial Terraform state. -func (r *credentialsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.Plan.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -234,7 +234,7 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq } // Read refreshes the Terraform state with the latest data. -func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.State.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -271,13 +271,13 @@ func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest } // Update updates the resource and sets the updated Terraform state on success. -func (r *credentialsResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform // Update shouldn't be called core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated") } // Delete deletes the resource and removes the Terraform state on success. -func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.State.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -307,7 +307,7 @@ func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteReq // ImportState imports a resource into the Terraform state on success. // The expected format of the resource import identifier is: project_id,instance_id,credentials_id -func (r *credentialsResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { +func (r *credentialResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" { core.LogAndAddError(ctx, &resp.Diagnostics, diff --git a/stackit/internal/services/mariadb/credentials/resource_test.go b/stackit/internal/services/mariadb/credentials/resource_test.go index 01a050fd..ac05d210 100644 --- a/stackit/internal/services/mariadb/credentials/resource_test.go +++ b/stackit/internal/services/mariadb/credentials/resource_test.go @@ -124,7 +124,7 @@ func TestMapFields(t *testing.T) { false, }, { - "nil_raw_credentials", + "nil_raw_credential", &mariadb.CredentialsResponse{ Id: utils.Ptr("cid"), }, diff --git a/stackit/internal/services/mariadb/mariadb_acc_test.go b/stackit/internal/services/mariadb/mariadb_acc_test.go index cc445cff..9fff4ff7 100644 --- a/stackit/internal/services/mariadb/mariadb_acc_test.go +++ b/stackit/internal/services/mariadb/mariadb_acc_test.go @@ -41,7 +41,7 @@ func resourceConfig(acls string) string { } } - resource "stackit_mariadb_credentials" "credentials" { + resource "stackit_mariadb_credential" "credentials" { project_id = stackit_mariadb_instance.instance.project_id instance_id = stackit_mariadb_instance.instance.instance_id } @@ -75,15 +75,15 @@ func TestAccMariaDBResource(t *testing.T) { // Credentials data resource.TestCheckResourceAttrPair( - "stackit_mariadb_credentials.credentials", "project_id", + "stackit_mariadb_credential.credentials", "project_id", "stackit_mariadb_instance.instance", "project_id", ), resource.TestCheckResourceAttrPair( - "stackit_mariadb_credentials.credentials", "instance_id", + "stackit_mariadb_credential.credentials", "instance_id", "stackit_mariadb_instance.instance", "instance_id", ), - resource.TestCheckResourceAttrSet("stackit_mariadb_credentials.credentials", "credentials_id"), - resource.TestCheckResourceAttrSet("stackit_mariadb_credentials.credentials", "host"), + resource.TestCheckResourceAttrSet("stackit_mariadb_credential.credentials", "credentials_id"), + resource.TestCheckResourceAttrSet("stackit_mariadb_credential.credentials", "host"), ), }, // Data source @@ -96,10 +96,10 @@ func TestAccMariaDBResource(t *testing.T) { instance_id = stackit_mariadb_instance.instance.instance_id } - data "stackit_mariadb_credentials" "credentials" { - project_id = stackit_mariadb_credentials.credentials.project_id - instance_id = stackit_mariadb_credentials.credentials.instance_id - credentials_id = stackit_mariadb_credentials.credentials.credentials_id + data "stackit_mariadb_credential" "credentials" { + project_id = stackit_mariadb_credential.credentials.project_id + instance_id = stackit_mariadb_credential.credentials.instance_id + credentials_id = stackit_mariadb_credential.credentials.credentials_id }`, resourceConfig(instanceResource["sgw_acl-1"]), ), @@ -108,18 +108,18 @@ func TestAccMariaDBResource(t *testing.T) { resource.TestCheckResourceAttr("data.stackit_mariadb_instance.instance", "project_id", instanceResource["project_id"]), resource.TestCheckResourceAttrPair("stackit_mariadb_instance.instance", "instance_id", "data.stackit_mariadb_instance.instance", "instance_id"), - resource.TestCheckResourceAttrPair("stackit_mariadb_credentials.credentials", "credentials_id", - "data.stackit_mariadb_credentials.credentials", "credentials_id"), + resource.TestCheckResourceAttrPair("stackit_mariadb_credential.credentials", "credentials_id", + "data.stackit_mariadb_credential.credentials", "credentials_id"), resource.TestCheckResourceAttr("data.stackit_mariadb_instance.instance", "plan_id", instanceResource["plan_id"]), resource.TestCheckResourceAttr("data.stackit_mariadb_instance.instance", "name", instanceResource["name"]), resource.TestCheckResourceAttr("data.stackit_mariadb_instance.instance", "parameters.sgw_acl", instanceResource["sgw_acl-1"]), // Credentials data - resource.TestCheckResourceAttr("data.stackit_mariadb_credentials.credentials", "project_id", instanceResource["project_id"]), - resource.TestCheckResourceAttrSet("data.stackit_mariadb_credentials.credentials", "credentials_id"), - resource.TestCheckResourceAttrSet("data.stackit_mariadb_credentials.credentials", "host"), - resource.TestCheckResourceAttrSet("data.stackit_mariadb_credentials.credentials", "port"), - resource.TestCheckResourceAttrSet("data.stackit_mariadb_credentials.credentials", "uri"), + resource.TestCheckResourceAttr("data.stackit_mariadb_credential.credentials", "project_id", instanceResource["project_id"]), + resource.TestCheckResourceAttrSet("data.stackit_mariadb_credential.credentials", "credentials_id"), + resource.TestCheckResourceAttrSet("data.stackit_mariadb_credential.credentials", "host"), + resource.TestCheckResourceAttrSet("data.stackit_mariadb_credential.credentials", "port"), + resource.TestCheckResourceAttrSet("data.stackit_mariadb_credential.credentials", "uri"), ), }, // Import @@ -140,11 +140,11 @@ func TestAccMariaDBResource(t *testing.T) { ImportStateVerify: true, }, { - ResourceName: "stackit_mariadb_credentials.credentials", + ResourceName: "stackit_mariadb_credential.credentials", ImportStateIdFunc: func(s *terraform.State) (string, error) { - r, ok := s.RootModule().Resources["stackit_mariadb_credentials.credentials"] + r, ok := s.RootModule().Resources["stackit_mariadb_credential.credentials"] if !ok { - return "", fmt.Errorf("couldn't find resource stackit_mariadb_credentials.credentials") + return "", fmt.Errorf("couldn't find resource stackit_mariadb_credential.credentials") } instanceId, ok := r.Primary.Attributes["instance_id"] if !ok { diff --git a/stackit/internal/services/objectstorage/bucket/datasource.go b/stackit/internal/services/objectstorage/bucket/datasource.go index aea28f98..b7f72835 100644 --- a/stackit/internal/services/objectstorage/bucket/datasource.go +++ b/stackit/internal/services/objectstorage/bucket/datasource.go @@ -74,7 +74,7 @@ func (r *bucketDataSource) Configure(ctx context.Context, req datasource.Configu // Schema defines the schema for the data source. func (r *bucketDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { descriptions := map[string]string{ - "main": "ObjectStorage credentials data source schema.", + "main": "ObjectStorage credential data source schema.", "id": "Terraform's internal data source identifier. It is structured as \"`project_id`,`bucket_name`\".", "bucket_name": "The bucket name. It must be DNS conform.", "project_id": "STACKIT Project ID to which the bucket is associated.", diff --git a/stackit/internal/services/opensearch/credentials/datasource.go b/stackit/internal/services/opensearch/credentials/datasource.go index 41916770..bb240574 100644 --- a/stackit/internal/services/opensearch/credentials/datasource.go +++ b/stackit/internal/services/opensearch/credentials/datasource.go @@ -18,26 +18,26 @@ import ( // Ensure the implementation satisfies the expected interfaces. var ( - _ datasource.DataSource = &credentialsDataSource{} + _ datasource.DataSource = &credentialDataSource{} ) -// NewCredentialsDataSource is a helper function to simplify the provider implementation. -func NewCredentialsDataSource() datasource.DataSource { - return &credentialsDataSource{} +// NewCredentialDataSource is a helper function to simplify the provider implementation. +func NewCredentialDataSource() datasource.DataSource { + return &credentialDataSource{} } -// credentialsDataSource is the data source implementation. -type credentialsDataSource struct { +// credentialDataSource is the data source implementation. +type credentialDataSource struct { client *opensearch.APIClient } // Metadata returns the data source type name. -func (r *credentialsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_opensearch_credentials" +func (r *credentialDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_opensearch_credential" } // Configure adds the provider configured client to the data source. -func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { +func (r *credentialDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -73,9 +73,9 @@ func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.Co } // Schema defines the schema for the data source. -func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { +func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { descriptions := map[string]string{ - "main": "OpenSearch credentials data source schema.", + "main": "OpenSearch credential data source schema.", "id": "Terraform's internal data source. identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".", "credentials_id": "The credentials ID.", "instance_id": "ID of the OpenSearch instance.", @@ -144,7 +144,7 @@ func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaReq } // Read refreshes the Terraform state with the latest data. -func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.Config.Get(ctx, &model) resp.Diagnostics.Append(diags...) diff --git a/stackit/internal/services/opensearch/credentials/resource.go b/stackit/internal/services/opensearch/credentials/resource.go index beb9669f..3b9c9cde 100644 --- a/stackit/internal/services/opensearch/credentials/resource.go +++ b/stackit/internal/services/opensearch/credentials/resource.go @@ -26,9 +26,9 @@ import ( // Ensure the implementation satisfies the expected interfaces. var ( - _ resource.Resource = &credentialsResource{} - _ resource.ResourceWithConfigure = &credentialsResource{} - _ resource.ResourceWithImportState = &credentialsResource{} + _ resource.Resource = &credentialResource{} + _ resource.ResourceWithConfigure = &credentialResource{} + _ resource.ResourceWithImportState = &credentialResource{} ) type Model struct { @@ -46,23 +46,23 @@ type Model struct { Username types.String `tfsdk:"username"` } -// NewCredentialsResource is a helper function to simplify the provider implementation. -func NewCredentialsResource() resource.Resource { - return &credentialsResource{} +// NewCredentialResource is a helper function to simplify the provider implementation. +func NewCredentialResource() resource.Resource { + return &credentialResource{} } -// credentialsResource is the resource implementation. -type credentialsResource struct { +// credentialResource is the resource implementation. +type credentialResource struct { client *opensearch.APIClient } // Metadata returns the resource type name. -func (r *credentialsResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_opensearch_credentials" +func (r *credentialResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_opensearch_credential" } // Configure adds the provider configured client to the resource. -func (r *credentialsResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { +func (r *credentialResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -98,9 +98,9 @@ func (r *credentialsResource) Configure(ctx context.Context, req resource.Config } // Schema defines the schema for the resource. -func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { descriptions := map[string]string{ - "main": "OpenSearch credentials resource schema.", + "main": "OpenSearch credential resource schema.", "id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".", "credentials_id": "The credentials ID.", "instance_id": "ID of the OpenSearch instance.", @@ -183,7 +183,7 @@ func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest } // Create creates the resource and sets the initial Terraform state. -func (r *credentialsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.Plan.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -234,7 +234,7 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq } // Read refreshes the Terraform state with the latest data. -func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.State.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -271,13 +271,13 @@ func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest } // Update updates the resource and sets the updated Terraform state on success. -func (r *credentialsResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform // Update shouldn't be called core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated") } // Delete deletes the resource and removes the Terraform state on success. -func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.State.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -307,7 +307,7 @@ func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteReq // ImportState imports a resource into the Terraform state on success. // The expected format of the resource import identifier is: project_id,instance_id,credentials_id -func (r *credentialsResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { +func (r *credentialResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" { core.LogAndAddError(ctx, &resp.Diagnostics, diff --git a/stackit/internal/services/opensearch/credentials/resource_test.go b/stackit/internal/services/opensearch/credentials/resource_test.go index bf890038..5b653d38 100644 --- a/stackit/internal/services/opensearch/credentials/resource_test.go +++ b/stackit/internal/services/opensearch/credentials/resource_test.go @@ -124,7 +124,7 @@ func TestMapFields(t *testing.T) { false, }, { - "nil_raw_credentials", + "nil_raw_credential", &opensearch.CredentialsResponse{ Id: utils.Ptr("cid"), }, diff --git a/stackit/internal/services/opensearch/opensearch_acc_test.go b/stackit/internal/services/opensearch/opensearch_acc_test.go index 1562bf4e..e31751e5 100644 --- a/stackit/internal/services/opensearch/opensearch_acc_test.go +++ b/stackit/internal/services/opensearch/opensearch_acc_test.go @@ -37,7 +37,7 @@ func resourceConfig() string { version = "%s" } - resource "stackit_opensearch_credentials" "credentials" { + resource "stackit_opensearch_credential" "credentials" { project_id = stackit_opensearch_instance.instance.project_id instance_id = stackit_opensearch_instance.instance.instance_id } @@ -64,7 +64,7 @@ func resourceConfigUpdate() string { } } - resource "stackit_opensearch_credentials" "credentials" { + resource "stackit_opensearch_credential" "credentials" { project_id = stackit_opensearch_instance.instance.project_id instance_id = stackit_opensearch_instance.instance.instance_id } @@ -99,15 +99,15 @@ func TestAccOpenSearchResource(t *testing.T) { // Credentials data resource.TestCheckResourceAttrPair( - "stackit_opensearch_credentials.credentials", "project_id", + "stackit_opensearch_credential.credentials", "project_id", "stackit_opensearch_instance.instance", "project_id", ), resource.TestCheckResourceAttrPair( - "stackit_opensearch_credentials.credentials", "instance_id", + "stackit_opensearch_credential.credentials", "instance_id", "stackit_opensearch_instance.instance", "instance_id", ), - resource.TestCheckResourceAttrSet("stackit_opensearch_credentials.credentials", "credentials_id"), - resource.TestCheckResourceAttrSet("stackit_opensearch_credentials.credentials", "host"), + resource.TestCheckResourceAttrSet("stackit_opensearch_credential.credentials", "credentials_id"), + resource.TestCheckResourceAttrSet("stackit_opensearch_credential.credentials", "host"), ), }, // Data source @@ -120,10 +120,10 @@ func TestAccOpenSearchResource(t *testing.T) { instance_id = stackit_opensearch_instance.instance.instance_id } - data "stackit_opensearch_credentials" "credentials" { - project_id = stackit_opensearch_credentials.credentials.project_id - instance_id = stackit_opensearch_credentials.credentials.instance_id - credentials_id = stackit_opensearch_credentials.credentials.credentials_id + data "stackit_opensearch_credential" "credentials" { + project_id = stackit_opensearch_credential.credentials.project_id + instance_id = stackit_opensearch_credential.credentials.instance_id + credentials_id = stackit_opensearch_credential.credentials.credentials_id }`, resourceConfig(), ), @@ -132,18 +132,18 @@ func TestAccOpenSearchResource(t *testing.T) { resource.TestCheckResourceAttr("data.stackit_opensearch_instance.instance", "project_id", instanceResource["project_id"]), resource.TestCheckResourceAttrPair("stackit_opensearch_instance.instance", "instance_id", "data.stackit_opensearch_instance.instance", "instance_id"), - resource.TestCheckResourceAttrPair("stackit_opensearch_credentials.credentials", "credentials_id", - "data.stackit_opensearch_credentials.credentials", "credentials_id"), + resource.TestCheckResourceAttrPair("stackit_opensearch_credential.credentials", "credentials_id", + "data.stackit_opensearch_credential.credentials", "credentials_id"), resource.TestCheckResourceAttr("data.stackit_opensearch_instance.instance", "plan_id", instanceResource["plan_id"]), resource.TestCheckResourceAttr("data.stackit_opensearch_instance.instance", "name", instanceResource["name"]), resource.TestCheckResourceAttrSet("data.stackit_opensearch_instance.instance", "parameters.sgw_acl"), // Credentials data - resource.TestCheckResourceAttr("data.stackit_opensearch_credentials.credentials", "project_id", instanceResource["project_id"]), - resource.TestCheckResourceAttrSet("data.stackit_opensearch_credentials.credentials", "credentials_id"), - resource.TestCheckResourceAttrSet("data.stackit_opensearch_credentials.credentials", "host"), - resource.TestCheckResourceAttrSet("data.stackit_opensearch_credentials.credentials", "port"), - resource.TestCheckResourceAttrSet("data.stackit_opensearch_credentials.credentials", "uri"), + resource.TestCheckResourceAttr("data.stackit_opensearch_credential.credentials", "project_id", instanceResource["project_id"]), + resource.TestCheckResourceAttrSet("data.stackit_opensearch_credential.credentials", "credentials_id"), + resource.TestCheckResourceAttrSet("data.stackit_opensearch_credential.credentials", "host"), + resource.TestCheckResourceAttrSet("data.stackit_opensearch_credential.credentials", "port"), + resource.TestCheckResourceAttrSet("data.stackit_opensearch_credential.credentials", "uri"), ), }, // Import @@ -165,11 +165,11 @@ func TestAccOpenSearchResource(t *testing.T) { ImportStateVerify: true, }, { - ResourceName: "stackit_opensearch_credentials.credentials", + ResourceName: "stackit_opensearch_credential.credentials", ImportStateIdFunc: func(s *terraform.State) (string, error) { - r, ok := s.RootModule().Resources["stackit_opensearch_credentials.credentials"] + r, ok := s.RootModule().Resources["stackit_opensearch_credential.credentials"] if !ok { - return "", fmt.Errorf("couldn't find resource stackit_opensearch_credentials.credentials") + return "", fmt.Errorf("couldn't find resource stackit_opensearch_credential.credentials") } instanceId, ok := r.Primary.Attributes["instance_id"] if !ok { diff --git a/stackit/internal/services/postgresql/credentials/datasource.go b/stackit/internal/services/postgresql/credentials/datasource.go index cc808120..1e6c7a27 100644 --- a/stackit/internal/services/postgresql/credentials/datasource.go +++ b/stackit/internal/services/postgresql/credentials/datasource.go @@ -18,26 +18,26 @@ import ( // Ensure the implementation satisfies the expected interfaces. var ( - _ datasource.DataSource = &credentialsDataSource{} + _ datasource.DataSource = &credentialDataSource{} ) -// NewCredentialsDataSource is a helper function to simplify the provider implementation. -func NewCredentialsDataSource() datasource.DataSource { - return &credentialsDataSource{} +// NewCredentialDataSource is a helper function to simplify the provider implementation. +func NewCredentialDataSource() datasource.DataSource { + return &credentialDataSource{} } -// credentialsDataSource is the data source implementation. -type credentialsDataSource struct { +// credentialDataSource is the data source implementation. +type credentialDataSource struct { client *postgresql.APIClient } // Metadata returns the data source type name. -func (r *credentialsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_postgresql_credentials" +func (r *credentialDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_postgresql_credential" } // Configure adds the provider configured client to the data source. -func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { +func (r *credentialDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -73,9 +73,9 @@ func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.Co } // Schema defines the schema for the data source. -func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { +func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { descriptions := map[string]string{ - "main": "PostgreSQL credentials data source schema.", + "main": "PostgreSQL credential data source schema.", "id": "Terraform's internal data source. identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".", "credentials_id": "The credentials ID.", "instance_id": "ID of the PostgreSQL instance.", @@ -144,7 +144,7 @@ func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaReq } // Read refreshes the Terraform state with the latest data. -func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.Config.Get(ctx, &model) resp.Diagnostics.Append(diags...) diff --git a/stackit/internal/services/postgresql/credentials/resource.go b/stackit/internal/services/postgresql/credentials/resource.go index 8a58eaaf..17756e6c 100644 --- a/stackit/internal/services/postgresql/credentials/resource.go +++ b/stackit/internal/services/postgresql/credentials/resource.go @@ -26,9 +26,9 @@ import ( // Ensure the implementation satisfies the expected interfaces. var ( - _ resource.Resource = &credentialsResource{} - _ resource.ResourceWithConfigure = &credentialsResource{} - _ resource.ResourceWithImportState = &credentialsResource{} + _ resource.Resource = &credentialResource{} + _ resource.ResourceWithConfigure = &credentialResource{} + _ resource.ResourceWithImportState = &credentialResource{} ) type Model struct { @@ -46,23 +46,23 @@ type Model struct { Username types.String `tfsdk:"username"` } -// NewCredentialsResource is a helper function to simplify the provider implementation. -func NewCredentialsResource() resource.Resource { - return &credentialsResource{} +// NewCredentialResource is a helper function to simplify the provider implementation. +func NewCredentialResource() resource.Resource { + return &credentialResource{} } -// credentialsResource is the resource implementation. -type credentialsResource struct { +// credentialResource is the resource implementation. +type credentialResource struct { client *postgresql.APIClient } // Metadata returns the resource type name. -func (r *credentialsResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_postgresql_credentials" +func (r *credentialResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_postgresql_credential" } // Configure adds the provider configured client to the resource. -func (r *credentialsResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { +func (r *credentialResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -98,9 +98,9 @@ func (r *credentialsResource) Configure(ctx context.Context, req resource.Config } // Schema defines the schema for the resource. -func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { descriptions := map[string]string{ - "main": "PostgreSQL credentials resource schema.", + "main": "PostgreSQL credential resource schema.", "id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".", "credentials_id": "The credentials ID.", "instance_id": "ID of the PostgreSQL instance.", @@ -183,7 +183,7 @@ func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest } // Create creates the resource and sets the initial Terraform state. -func (r *credentialsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.Plan.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -234,7 +234,7 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq } // Read refreshes the Terraform state with the latest data. -func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.State.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -271,13 +271,13 @@ func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest } // Update updates the resource and sets the updated Terraform state on success. -func (r *credentialsResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform // Update shouldn't be called core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated") } // Delete deletes the resource and removes the Terraform state on success. -func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.State.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -307,7 +307,7 @@ func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteReq // ImportState imports a resource into the Terraform state on success. // The expected format of the resource import identifier is: project_id,instance_id,credentials_id -func (r *credentialsResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { +func (r *credentialResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" { core.LogAndAddError(ctx, &resp.Diagnostics, diff --git a/stackit/internal/services/postgresql/credentials/resource_test.go b/stackit/internal/services/postgresql/credentials/resource_test.go index b9c9e9b9..075f426f 100644 --- a/stackit/internal/services/postgresql/credentials/resource_test.go +++ b/stackit/internal/services/postgresql/credentials/resource_test.go @@ -124,7 +124,7 @@ func TestMapFields(t *testing.T) { false, }, { - "nil_raw_credentials", + "nil_raw_credential", &postgresql.CredentialsResponse{ Id: utils.Ptr("cid"), }, diff --git a/stackit/internal/services/postgresql/postgresql_acc_test.go b/stackit/internal/services/postgresql/postgresql_acc_test.go index 06a12ac7..f250a8cb 100644 --- a/stackit/internal/services/postgresql/postgresql_acc_test.go +++ b/stackit/internal/services/postgresql/postgresql_acc_test.go @@ -47,7 +47,7 @@ func resourceConfig(acls, frequency, plugins string) string { } } - resource "stackit_postgresql_credentials" "credentials" { + resource "stackit_postgresql_credential" "credentials" { project_id = stackit_postgresql_instance.instance.project_id instance_id = stackit_postgresql_instance.instance.instance_id } @@ -83,15 +83,15 @@ func TestAccPostgreSQLResource(t *testing.T) { // Credentials data resource.TestCheckResourceAttrPair( - "stackit_postgresql_credentials.credentials", "project_id", + "stackit_postgresql_credential.credentials", "project_id", "stackit_postgresql_instance.instance", "project_id", ), resource.TestCheckResourceAttrPair( - "stackit_postgresql_credentials.credentials", "instance_id", + "stackit_postgresql_credential.credentials", "instance_id", "stackit_postgresql_instance.instance", "instance_id", ), - resource.TestCheckResourceAttrSet("stackit_postgresql_credentials.credentials", "credentials_id"), - resource.TestCheckResourceAttrSet("stackit_postgresql_credentials.credentials", "host"), + resource.TestCheckResourceAttrSet("stackit_postgresql_credential.credentials", "credentials_id"), + resource.TestCheckResourceAttrSet("stackit_postgresql_credential.credentials", "host"), ), }, { // Data source @@ -103,10 +103,10 @@ func TestAccPostgreSQLResource(t *testing.T) { instance_id = stackit_postgresql_instance.instance.instance_id } - data "stackit_postgresql_credentials" "credentials" { - project_id = stackit_postgresql_credentials.credentials.project_id - instance_id = stackit_postgresql_credentials.credentials.instance_id - credentials_id = stackit_postgresql_credentials.credentials.credentials_id + data "stackit_postgresql_credential" "credentials" { + project_id = stackit_postgresql_credential.credentials.project_id + instance_id = stackit_postgresql_credential.credentials.instance_id + credentials_id = stackit_postgresql_credential.credentials.credentials_id }`, resourceConfig(instanceResource["sgw_acl"], instanceResource["metrics_frequency"], instanceResource["plugins"]), ), @@ -115,8 +115,8 @@ func TestAccPostgreSQLResource(t *testing.T) { resource.TestCheckResourceAttr("data.stackit_postgresql_instance.instance", "project_id", instanceResource["project_id"]), resource.TestCheckResourceAttrPair("stackit_postgresql_instance.instance", "instance_id", "data.stackit_postgresql_instance.instance", "instance_id"), - resource.TestCheckResourceAttrPair("stackit_postgresql_credentials.credentials", "credentials_id", - "data.stackit_postgresql_credentials.credentials", "credentials_id"), + resource.TestCheckResourceAttrPair("stackit_postgresql_credential.credentials", "credentials_id", + "data.stackit_postgresql_credential.credentials", "credentials_id"), resource.TestCheckResourceAttr("data.stackit_postgresql_instance.instance", "plan_id", instanceResource["plan_id"]), resource.TestCheckResourceAttr("data.stackit_postgresql_instance.instance", "name", instanceResource["name"]), resource.TestCheckResourceAttr("data.stackit_postgresql_instance.instance", "parameters.sgw_acl", instanceResource["sgw_acl"]), @@ -124,11 +124,11 @@ func TestAccPostgreSQLResource(t *testing.T) { resource.TestCheckResourceAttr("data.stackit_postgresql_instance.instance", "parameters.plugins.0", instanceResource["plugins"]), // Credentials data - resource.TestCheckResourceAttr("data.stackit_postgresql_credentials.credentials", "project_id", instanceResource["project_id"]), - resource.TestCheckResourceAttrSet("data.stackit_postgresql_credentials.credentials", "credentials_id"), - resource.TestCheckResourceAttrSet("data.stackit_postgresql_credentials.credentials", "host"), - resource.TestCheckResourceAttrSet("data.stackit_postgresql_credentials.credentials", "port"), - resource.TestCheckResourceAttrSet("data.stackit_postgresql_credentials.credentials", "uri"), + resource.TestCheckResourceAttr("data.stackit_postgresql_credential.credentials", "project_id", instanceResource["project_id"]), + resource.TestCheckResourceAttrSet("data.stackit_postgresql_credential.credentials", "credentials_id"), + resource.TestCheckResourceAttrSet("data.stackit_postgresql_credential.credentials", "host"), + resource.TestCheckResourceAttrSet("data.stackit_postgresql_credential.credentials", "port"), + resource.TestCheckResourceAttrSet("data.stackit_postgresql_credential.credentials", "uri"), ), }, // Import @@ -149,11 +149,11 @@ func TestAccPostgreSQLResource(t *testing.T) { ImportStateVerify: true, }, { - ResourceName: "stackit_postgresql_credentials.credentials", + ResourceName: "stackit_postgresql_credential.credentials", ImportStateIdFunc: func(s *terraform.State) (string, error) { - r, ok := s.RootModule().Resources["stackit_postgresql_credentials.credentials"] + r, ok := s.RootModule().Resources["stackit_postgresql_credential.credentials"] if !ok { - return "", fmt.Errorf("couldn't find resource stackit_postgresql_credentials.credentials") + return "", fmt.Errorf("couldn't find resource stackit_postgresql_credential.credentials") } instanceId, ok := r.Primary.Attributes["instance_id"] if !ok { diff --git a/stackit/internal/services/rabbitmq/credentials/datasource.go b/stackit/internal/services/rabbitmq/credentials/datasource.go index de5dfd5c..c299af41 100644 --- a/stackit/internal/services/rabbitmq/credentials/datasource.go +++ b/stackit/internal/services/rabbitmq/credentials/datasource.go @@ -18,26 +18,26 @@ import ( // Ensure the implementation satisfies the expected interfaces. var ( - _ datasource.DataSource = &credentialsDataSource{} + _ datasource.DataSource = &credentialDataSource{} ) -// NewCredentialsDataSource is a helper function to simplify the provider implementation. -func NewCredentialsDataSource() datasource.DataSource { - return &credentialsDataSource{} +// NewCredentialDataSource is a helper function to simplify the provider implementation. +func NewCredentialDataSource() datasource.DataSource { + return &credentialDataSource{} } -// credentialsDataSource is the data source implementation. -type credentialsDataSource struct { +// credentialDataSource is the data source implementation. +type credentialDataSource struct { client *rabbitmq.APIClient } // Metadata returns the data source type name. -func (r *credentialsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_rabbitmq_credentials" +func (r *credentialDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_rabbitmq_credential" } // Configure adds the provider configured client to the data source. -func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { +func (r *credentialDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -73,9 +73,9 @@ func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.Co } // Schema defines the schema for the data source. -func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { +func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { descriptions := map[string]string{ - "main": "RabbitMQ credentials data source schema.", + "main": "RabbitMQ credential data source schema.", "id": "Terraform's internal data source. identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".", "credentials_id": "The credentials ID.", "instance_id": "ID of the RabbitMQ instance.", @@ -144,7 +144,7 @@ func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaReq } // Read refreshes the Terraform state with the latest data. -func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.Config.Get(ctx, &model) resp.Diagnostics.Append(diags...) diff --git a/stackit/internal/services/rabbitmq/credentials/resource.go b/stackit/internal/services/rabbitmq/credentials/resource.go index d9104a27..7f60deb9 100644 --- a/stackit/internal/services/rabbitmq/credentials/resource.go +++ b/stackit/internal/services/rabbitmq/credentials/resource.go @@ -26,9 +26,9 @@ import ( // Ensure the implementation satisfies the expected interfaces. var ( - _ resource.Resource = &credentialsResource{} - _ resource.ResourceWithConfigure = &credentialsResource{} - _ resource.ResourceWithImportState = &credentialsResource{} + _ resource.Resource = &credentialResource{} + _ resource.ResourceWithConfigure = &credentialResource{} + _ resource.ResourceWithImportState = &credentialResource{} ) type Model struct { @@ -46,23 +46,23 @@ type Model struct { Username types.String `tfsdk:"username"` } -// NewCredentialsResource is a helper function to simplify the provider implementation. -func NewCredentialsResource() resource.Resource { - return &credentialsResource{} +// NewCredentialResource is a helper function to simplify the provider implementation. +func NewCredentialResource() resource.Resource { + return &credentialResource{} } -// credentialsResource is the resource implementation. -type credentialsResource struct { +// credentialResource is the resource implementation. +type credentialResource struct { client *rabbitmq.APIClient } // Metadata returns the resource type name. -func (r *credentialsResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_rabbitmq_credentials" +func (r *credentialResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_rabbitmq_credential" } // Configure adds the provider configured client to the resource. -func (r *credentialsResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { +func (r *credentialResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -98,9 +98,9 @@ func (r *credentialsResource) Configure(ctx context.Context, req resource.Config } // Schema defines the schema for the resource. -func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { descriptions := map[string]string{ - "main": "RabbitMQ credentials resource schema.", + "main": "RabbitMQ credential resource schema.", "id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".", "credentials_id": "The credentials ID.", "instance_id": "ID of the RabbitMQ instance.", @@ -183,7 +183,7 @@ func (r *credentialsResource) Schema(_ context.Context, _ resource.SchemaRequest } // Create creates the resource and sets the initial Terraform state. -func (r *credentialsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.Plan.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -234,7 +234,7 @@ func (r *credentialsResource) Create(ctx context.Context, req resource.CreateReq } // Read refreshes the Terraform state with the latest data. -func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.State.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -271,13 +271,13 @@ func (r *credentialsResource) Read(ctx context.Context, req resource.ReadRequest } // Update updates the resource and sets the updated Terraform state on success. -func (r *credentialsResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform // Update shouldn't be called core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated") } // Delete deletes the resource and removes the Terraform state on success. -func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.State.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -307,7 +307,7 @@ func (r *credentialsResource) Delete(ctx context.Context, req resource.DeleteReq // ImportState imports a resource into the Terraform state on success. // The expected format of the resource import identifier is: project_id,instance_id,credentials_id -func (r *credentialsResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { +func (r *credentialResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" { core.LogAndAddError(ctx, &resp.Diagnostics, diff --git a/stackit/internal/services/rabbitmq/credentials/resource_test.go b/stackit/internal/services/rabbitmq/credentials/resource_test.go index 02dac499..5e6e3c44 100644 --- a/stackit/internal/services/rabbitmq/credentials/resource_test.go +++ b/stackit/internal/services/rabbitmq/credentials/resource_test.go @@ -124,7 +124,7 @@ func TestMapFields(t *testing.T) { false, }, { - "nil_raw_credentials", + "nil_raw_credential", &rabbitmq.CredentialsResponse{ Id: utils.Ptr("cid"), }, diff --git a/stackit/internal/services/rabbitmq/rabbitmq_acc_test.go b/stackit/internal/services/rabbitmq/rabbitmq_acc_test.go index 9f067332..e9eb0b61 100644 --- a/stackit/internal/services/rabbitmq/rabbitmq_acc_test.go +++ b/stackit/internal/services/rabbitmq/rabbitmq_acc_test.go @@ -88,7 +88,7 @@ func resourceConfigWithUpdate() string { func resourceConfigCredentials() string { return ` - resource "stackit_rabbitmq_credentials" "credentials" { + resource "stackit_rabbitmq_credential" "credentials" { project_id = stackit_rabbitmq_instance.instance.project_id instance_id = stackit_rabbitmq_instance.instance.instance_id } @@ -121,15 +121,15 @@ func TestAccRabbitMQResource(t *testing.T) { // Credentials data resource.TestCheckResourceAttrPair( - "stackit_rabbitmq_credentials.credentials", "project_id", + "stackit_rabbitmq_credential.credentials", "project_id", "stackit_rabbitmq_instance.instance", "project_id", ), resource.TestCheckResourceAttrPair( - "stackit_rabbitmq_credentials.credentials", "instance_id", + "stackit_rabbitmq_credential.credentials", "instance_id", "stackit_rabbitmq_instance.instance", "instance_id", ), - resource.TestCheckResourceAttrSet("stackit_rabbitmq_credentials.credentials", "credentials_id"), - resource.TestCheckResourceAttrSet("stackit_rabbitmq_credentials.credentials", "host"), + resource.TestCheckResourceAttrSet("stackit_rabbitmq_credential.credentials", "credentials_id"), + resource.TestCheckResourceAttrSet("stackit_rabbitmq_credential.credentials", "host"), ), }, // data source @@ -142,10 +142,10 @@ func TestAccRabbitMQResource(t *testing.T) { instance_id = stackit_rabbitmq_instance.instance.instance_id } - data "stackit_rabbitmq_credentials" "credentials" { - project_id = stackit_rabbitmq_credentials.credentials.project_id - instance_id = stackit_rabbitmq_credentials.credentials.instance_id - credentials_id = stackit_rabbitmq_credentials.credentials.credentials_id + data "stackit_rabbitmq_credential" "credentials" { + project_id = stackit_rabbitmq_credential.credentials.project_id + instance_id = stackit_rabbitmq_credential.credentials.instance_id + credentials_id = stackit_rabbitmq_credential.credentials.credentials_id }`, resourceConfig(nil), ), @@ -153,19 +153,19 @@ func TestAccRabbitMQResource(t *testing.T) { // Instance data resource.TestCheckResourceAttr("data.stackit_rabbitmq_instance.instance", "project_id", instanceResource["project_id"]), resource.TestCheckResourceAttrPair("stackit_rabbitmq_instance.instance", "instance_id", - "data.stackit_rabbitmq_credentials.credentials", "instance_id"), + "data.stackit_rabbitmq_credential.credentials", "instance_id"), resource.TestCheckResourceAttrPair("data.stackit_rabbitmq_instance.instance", "instance_id", - "data.stackit_rabbitmq_credentials.credentials", "instance_id"), + "data.stackit_rabbitmq_credential.credentials", "instance_id"), resource.TestCheckResourceAttr("data.stackit_rabbitmq_instance.instance", "plan_id", instanceResource["plan_id"]), resource.TestCheckResourceAttr("data.stackit_rabbitmq_instance.instance", "name", instanceResource["name"]), resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_instance.instance", "parameters.sgw_acl"), // Credentials data - resource.TestCheckResourceAttr("data.stackit_rabbitmq_credentials.credentials", "project_id", instanceResource["project_id"]), - resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credentials.credentials", "credentials_id"), - resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credentials.credentials", "host"), - resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credentials.credentials", "port"), - resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credentials.credentials", "uri"), + resource.TestCheckResourceAttr("data.stackit_rabbitmq_credential.credentials", "project_id", instanceResource["project_id"]), + resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credential.credentials", "credentials_id"), + resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credential.credentials", "host"), + resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credential.credentials", "port"), + resource.TestCheckResourceAttrSet("data.stackit_rabbitmq_credential.credentials", "uri"), ), }, // Import @@ -186,11 +186,11 @@ func TestAccRabbitMQResource(t *testing.T) { ImportStateVerify: true, }, { - ResourceName: "stackit_rabbitmq_credentials.credentials", + ResourceName: "stackit_rabbitmq_credential.credentials", ImportStateIdFunc: func(s *terraform.State) (string, error) { - r, ok := s.RootModule().Resources["stackit_rabbitmq_credentials.credentials"] + r, ok := s.RootModule().Resources["stackit_rabbitmq_credential.credentials"] if !ok { - return "", fmt.Errorf("couldn't find resource stackit_rabbitmq_credentials.credentials") + return "", fmt.Errorf("couldn't find resource stackit_rabbitmq_credential.credentials") } instanceId, ok := r.Primary.Attributes["instance_id"] if !ok { diff --git a/stackit/internal/services/redis/credentials/datasource.go b/stackit/internal/services/redis/credentials/datasource.go index d0f96676..25026e15 100644 --- a/stackit/internal/services/redis/credentials/datasource.go +++ b/stackit/internal/services/redis/credentials/datasource.go @@ -18,26 +18,26 @@ import ( // Ensure the implementation satisfies the expected interfaces. var ( - _ datasource.DataSource = &credentialsDataSource{} + _ datasource.DataSource = &credentialDataSource{} ) -// NewCredentialsDataSource is a helper function to simplify the provider implementation. -func NewCredentialsDataSource() datasource.DataSource { - return &credentialsDataSource{} +// NewCredentialDataSource is a helper function to simplify the provider implementation. +func NewCredentialDataSource() datasource.DataSource { + return &credentialDataSource{} } -// credentialsDataSource is the data source implementation. -type credentialsDataSource struct { +// credentialDataSource is the data source implementation. +type credentialDataSource struct { client *redis.APIClient } // Metadata returns the data source type name. -func (r *credentialsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_redis_credentials" +func (r *credentialDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_redis_credential" } // Configure adds the provider configured client to the data source. -func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { +func (r *credentialDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -73,9 +73,9 @@ func (r *credentialsDataSource) Configure(ctx context.Context, req datasource.Co } // Schema defines the schema for the data source. -func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { +func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { descriptions := map[string]string{ - "main": "Redis credentials data source schema.", + "main": "Redis credential data source schema.", "id": "Terraform's internal data source. identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".", "credentials_id": "The credentials ID.", "instance_id": "ID of the Redis instance.", @@ -144,7 +144,7 @@ func (r *credentialsDataSource) Schema(_ context.Context, _ datasource.SchemaReq } // Read refreshes the Terraform state with the latest data. -func (r *credentialsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.Config.Get(ctx, &model) resp.Diagnostics.Append(diags...) diff --git a/stackit/internal/services/redis/credentials/resource.go b/stackit/internal/services/redis/credentials/resource.go index 0dff7b1b..d09724d2 100644 --- a/stackit/internal/services/redis/credentials/resource.go +++ b/stackit/internal/services/redis/credentials/resource.go @@ -26,9 +26,9 @@ import ( // Ensure the implementation satisfies the expected interfaces. var ( - _ resource.Resource = &redisCredentialsResource{} - _ resource.ResourceWithConfigure = &redisCredentialsResource{} - _ resource.ResourceWithImportState = &redisCredentialsResource{} + _ resource.Resource = &credentialResource{} + _ resource.ResourceWithConfigure = &credentialResource{} + _ resource.ResourceWithImportState = &credentialResource{} ) type Model struct { @@ -46,23 +46,23 @@ type Model struct { Username types.String `tfsdk:"username"` } -// NewCredentialsResource is a helper function to simplify the provider implementation. -func NewCredentialsResource() resource.Resource { - return &redisCredentialsResource{} +// NewCredentialResource is a helper function to simplify the provider implementation. +func NewCredentialResource() resource.Resource { + return &credentialResource{} } -// credentialsResource is the resource implementation. -type redisCredentialsResource struct { +// credentialResource is the resource implementation. +type credentialResource struct { client *redis.APIClient } // Metadata returns the resource type name. -func (r *redisCredentialsResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_redis_credentials" +func (r *credentialResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_redis_credential" } // Configure adds the provider configured client to the resource. -func (r *redisCredentialsResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { +func (r *credentialResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -98,9 +98,9 @@ func (r *redisCredentialsResource) Configure(ctx context.Context, req resource.C } // Schema defines the schema for the resource. -func (r *redisCredentialsResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { descriptions := map[string]string{ - "main": "Redis credentials resource schema.", + "main": "Redis credential resource schema.", "id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`instance_id`,`credentials_id`\".", "credentials_id": "The credentials ID.", "instance_id": "ID of the Redis instance.", @@ -183,7 +183,7 @@ func (r *redisCredentialsResource) Schema(_ context.Context, _ resource.SchemaRe } // Create creates the resource and sets the initial Terraform state. -func (r *redisCredentialsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.Plan.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -234,7 +234,7 @@ func (r *redisCredentialsResource) Create(ctx context.Context, req resource.Crea } // Read refreshes the Terraform state with the latest data. -func (r *redisCredentialsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.State.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -271,13 +271,13 @@ func (r *redisCredentialsResource) Read(ctx context.Context, req resource.ReadRe } // Update updates the resource and sets the updated Terraform state on success. -func (r *redisCredentialsResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform // Update shouldn't be called core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated") } // Delete deletes the resource and removes the Terraform state on success. -func (r *redisCredentialsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform +func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform var model Model diags := req.State.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -307,7 +307,7 @@ func (r *redisCredentialsResource) Delete(ctx context.Context, req resource.Dele // ImportState imports a resource into the Terraform state on success. // The expected format of the resource import identifier is: project_id,instance_id,credentials_id -func (r *redisCredentialsResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { +func (r *credentialResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" { core.LogAndAddError(ctx, &resp.Diagnostics, diff --git a/stackit/internal/services/redis/credentials/resource_test.go b/stackit/internal/services/redis/credentials/resource_test.go index 04bc3a5c..b601dbed 100644 --- a/stackit/internal/services/redis/credentials/resource_test.go +++ b/stackit/internal/services/redis/credentials/resource_test.go @@ -124,7 +124,7 @@ func TestMapFields(t *testing.T) { false, }, { - "nil_raw_credentials", + "nil_raw_credential", &redis.CredentialsResponse{ Id: utils.Ptr("cid"), }, diff --git a/stackit/internal/services/redis/redis_acc_test.go b/stackit/internal/services/redis/redis_acc_test.go index fa654bd4..06ecc53c 100644 --- a/stackit/internal/services/redis/redis_acc_test.go +++ b/stackit/internal/services/redis/redis_acc_test.go @@ -88,7 +88,7 @@ func resourceConfigWithUpdate() string { func resourceConfigCredentials() string { return ` - resource "stackit_redis_credentials" "credentials" { + resource "stackit_redis_credential" "credentials" { project_id = stackit_redis_instance.instance.project_id instance_id = stackit_redis_instance.instance.instance_id } @@ -121,15 +121,15 @@ func TestAccRedisResource(t *testing.T) { // Credentials data resource.TestCheckResourceAttrPair( - "stackit_redis_credentials.credentials", "project_id", + "stackit_redis_credential.credentials", "project_id", "stackit_redis_instance.instance", "project_id", ), resource.TestCheckResourceAttrPair( - "stackit_redis_credentials.credentials", "instance_id", + "stackit_redis_credential.credentials", "instance_id", "stackit_redis_instance.instance", "instance_id", ), - resource.TestCheckResourceAttrSet("stackit_redis_credentials.credentials", "credentials_id"), - resource.TestCheckResourceAttrSet("stackit_redis_credentials.credentials", "host"), + resource.TestCheckResourceAttrSet("stackit_redis_credential.credentials", "credentials_id"), + resource.TestCheckResourceAttrSet("stackit_redis_credential.credentials", "host"), ), }, // data source @@ -142,10 +142,10 @@ func TestAccRedisResource(t *testing.T) { instance_id = stackit_redis_instance.instance.instance_id } - data "stackit_redis_credentials" "credentials" { - project_id = stackit_redis_credentials.credentials.project_id - instance_id = stackit_redis_credentials.credentials.instance_id - credentials_id = stackit_redis_credentials.credentials.credentials_id + data "stackit_redis_credential" "credentials" { + project_id = stackit_redis_credential.credentials.project_id + instance_id = stackit_redis_credential.credentials.instance_id + credentials_id = stackit_redis_credential.credentials.credentials_id }`, resourceConfig(nil), ), @@ -153,19 +153,19 @@ func TestAccRedisResource(t *testing.T) { // Instance data resource.TestCheckResourceAttr("data.stackit_redis_instance.instance", "project_id", instanceResource["project_id"]), resource.TestCheckResourceAttrPair("stackit_redis_instance.instance", "instance_id", - "data.stackit_redis_credentials.credentials", "instance_id"), + "data.stackit_redis_credential.credentials", "instance_id"), resource.TestCheckResourceAttrPair("data.stackit_redis_instance.instance", "instance_id", - "data.stackit_redis_credentials.credentials", "instance_id"), + "data.stackit_redis_credential.credentials", "instance_id"), resource.TestCheckResourceAttr("data.stackit_redis_instance.instance", "plan_id", instanceResource["plan_id"]), resource.TestCheckResourceAttr("data.stackit_redis_instance.instance", "name", instanceResource["name"]), resource.TestCheckResourceAttrSet("data.stackit_redis_instance.instance", "parameters.sgw_acl"), // Credentials data - resource.TestCheckResourceAttr("data.stackit_redis_credentials.credentials", "project_id", instanceResource["project_id"]), - resource.TestCheckResourceAttrSet("data.stackit_redis_credentials.credentials", "credentials_id"), - resource.TestCheckResourceAttrSet("data.stackit_redis_credentials.credentials", "host"), - resource.TestCheckResourceAttrSet("data.stackit_redis_credentials.credentials", "port"), - resource.TestCheckResourceAttrSet("data.stackit_redis_credentials.credentials", "uri"), + resource.TestCheckResourceAttr("data.stackit_redis_credential.credentials", "project_id", instanceResource["project_id"]), + resource.TestCheckResourceAttrSet("data.stackit_redis_credential.credentials", "credentials_id"), + resource.TestCheckResourceAttrSet("data.stackit_redis_credential.credentials", "host"), + resource.TestCheckResourceAttrSet("data.stackit_redis_credential.credentials", "port"), + resource.TestCheckResourceAttrSet("data.stackit_redis_credential.credentials", "uri"), ), }, // Import @@ -186,11 +186,11 @@ func TestAccRedisResource(t *testing.T) { ImportStateVerify: true, }, { - ResourceName: "stackit_redis_credentials.credentials", + ResourceName: "stackit_redis_credential.credentials", ImportStateIdFunc: func(s *terraform.State) (string, error) { - r, ok := s.RootModule().Resources["stackit_redis_credentials.credentials"] + r, ok := s.RootModule().Resources["stackit_redis_credential.credentials"] if !ok { - return "", fmt.Errorf("couldn't find resource stackit_redis_credentials.credentials") + return "", fmt.Errorf("couldn't find resource stackit_redis_credential.credentials") } instanceId, ok := r.Primary.Attributes["instance_id"] if !ok { diff --git a/stackit/provider.go b/stackit/provider.go index 79138c03..8db68a59 100644 --- a/stackit/provider.go +++ b/stackit/provider.go @@ -16,18 +16,18 @@ import ( dnsZone "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/dns/zone" logMeCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/logme/credential" logMeInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/logme/instance" - mariaDBCredentials "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/mariadb/credentials" + mariaDBCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/mariadb/credentials" mariaDBInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/mariadb/instance" objectStorageBucket "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/objectstorage/bucket" - openSearchCredentials "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/opensearch/credentials" + openSearchCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/opensearch/credentials" openSearchInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/opensearch/instance" postgresFlexInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresflex/instance" postgresFlexUser "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresflex/user" - postgresCredentials "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresql/credentials" + postgresCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresql/credentials" postgresInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresql/instance" - rabbitMQCredentials "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/rabbitmq/credentials" + rabbitMQCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/rabbitmq/credentials" rabbitMQInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/rabbitmq/instance" - redisCredentials "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/redis/credentials" + redisCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/redis/credentials" redisInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/redis/instance" resourceManagerProject "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/resourcemanager/project" skeCluster "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/ske/cluster" @@ -307,18 +307,18 @@ func (p *Provider) DataSources(_ context.Context) []func() datasource.DataSource dnsZone.NewZoneDataSource, dnsRecordSet.NewRecordSetDataSource, postgresInstance.NewInstanceDataSource, - postgresCredentials.NewCredentialsDataSource, + postgresCredential.NewCredentialDataSource, logMeInstance.NewInstanceDataSource, logMeCredential.NewCredentialDataSource, mariaDBInstance.NewInstanceDataSource, - mariaDBCredentials.NewCredentialsDataSource, + mariaDBCredential.NewCredentialDataSource, objectStorageBucket.NewBucketDataSource, openSearchInstance.NewInstanceDataSource, - openSearchCredentials.NewCredentialsDataSource, + openSearchCredential.NewCredentialDataSource, rabbitMQInstance.NewInstanceDataSource, - rabbitMQCredentials.NewCredentialsDataSource, + rabbitMQCredential.NewCredentialDataSource, redisInstance.NewInstanceDataSource, - redisCredentials.NewCredentialsDataSource, + redisCredential.NewCredentialDataSource, argusInstance.NewInstanceDataSource, argusScrapeConfig.NewScrapeConfigDataSource, resourceManagerProject.NewProjectDataSource, @@ -335,18 +335,18 @@ func (p *Provider) Resources(_ context.Context) []func() resource.Resource { dnsZone.NewZoneResource, dnsRecordSet.NewRecordSetResource, postgresInstance.NewInstanceResource, - postgresCredentials.NewCredentialsResource, + postgresCredential.NewCredentialResource, logMeInstance.NewInstanceResource, logMeCredential.NewCredentialResource, mariaDBInstance.NewInstanceResource, - mariaDBCredentials.NewCredentialsResource, + mariaDBCredential.NewCredentialResource, objectStorageBucket.NewBucketResource, openSearchInstance.NewInstanceResource, - openSearchCredentials.NewCredentialsResource, + openSearchCredential.NewCredentialResource, rabbitMQInstance.NewInstanceResource, - rabbitMQCredentials.NewCredentialsResource, + rabbitMQCredential.NewCredentialResource, redisInstance.NewInstanceResource, - redisCredentials.NewCredentialsResource, + redisCredential.NewCredentialResource, argusInstance.NewInstanceResource, argusScrapeConfig.NewScrapeConfigResource, resourceManagerProject.NewProjectResource, From db12b56fc3986a088eb045c94303dc0773f40b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Palet?= Date: Tue, 10 Oct 2023 18:31:27 +0100 Subject: [PATCH 3/5] Rename examples --- docs/data-sources/logme_credential.md | 10 +++++++++- docs/data-sources/mariadb_credential.md | 10 +++++++++- docs/data-sources/opensearch_credential.md | 10 +++++++++- docs/data-sources/postgresql_credential.md | 10 +++++++++- docs/data-sources/rabbitmq_credential.md | 10 +++++++++- docs/data-sources/redis_credential.md | 10 +++++++++- docs/resources/logme_credential.md | 9 ++++++++- docs/resources/mariadb_credential.md | 9 ++++++++- docs/resources/opensearch_credential.md | 9 ++++++++- docs/resources/postgresql_credential.md | 9 ++++++++- docs/resources/rabbitmq_credential.md | 9 ++++++++- docs/resources/redis_credential.md | 9 ++++++++- .../data-source.tf | 0 .../data-source.tf | 0 .../data-source.tf | 0 .../data-source.tf | 0 .../data-source.tf | 0 .../data-source.tf | 0 .../resource.tf | 0 .../resource.tf | 0 .../resource.tf | 0 .../resource.tf | 0 .../resource.tf | 0 .../resource.tf | 0 24 files changed, 102 insertions(+), 12 deletions(-) rename examples/data-sources/{stackit_logme_credentials => stackit_logme_credential}/data-source.tf (100%) rename examples/data-sources/{stackit_mariadb_credentials => stackit_mariadb_credential}/data-source.tf (100%) rename examples/data-sources/{stackit_opensearch_credentials => stackit_opensearch_credential}/data-source.tf (100%) rename examples/data-sources/{stackit_postgresql_credentials => stackit_postgresql_credential}/data-source.tf (100%) rename examples/data-sources/{stackit_rabbitmq_credentials => stackit_rabbitmq_credential}/data-source.tf (100%) rename examples/data-sources/{stackit_redis_credentials => stackit_redis_credential}/data-source.tf (100%) rename examples/resources/{stackit_logme_credentials => stackit_logme_credential}/resource.tf (100%) rename examples/resources/{stackit_mariadb_credentials => stackit_mariadb_credential}/resource.tf (100%) rename examples/resources/{stackit_opensearch_credentials => stackit_opensearch_credential}/resource.tf (100%) rename examples/resources/{stackit_postgresql_credentials => stackit_postgresql_credential}/resource.tf (100%) rename examples/resources/{stackit_rabbitmq_credentials => stackit_rabbitmq_credential}/resource.tf (100%) rename examples/resources/{stackit_redis_credentials => stackit_redis_credential}/resource.tf (100%) diff --git a/docs/data-sources/logme_credential.md b/docs/data-sources/logme_credential.md index 40d38f57..8c781108 100644 --- a/docs/data-sources/logme_credential.md +++ b/docs/data-sources/logme_credential.md @@ -10,7 +10,15 @@ description: |- LogMe credential data source schema. - +## Example Usage + +```terraform +data "stackit_logme_credential" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` ## Schema diff --git a/docs/data-sources/mariadb_credential.md b/docs/data-sources/mariadb_credential.md index 0fb323a3..a72ab8ac 100644 --- a/docs/data-sources/mariadb_credential.md +++ b/docs/data-sources/mariadb_credential.md @@ -10,7 +10,15 @@ description: |- MariaDB credential data source schema. - +## Example Usage + +```terraform +data "stackit_mariadb_credential" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` ## Schema diff --git a/docs/data-sources/opensearch_credential.md b/docs/data-sources/opensearch_credential.md index 35fbf236..a2ae3f89 100644 --- a/docs/data-sources/opensearch_credential.md +++ b/docs/data-sources/opensearch_credential.md @@ -10,7 +10,15 @@ description: |- OpenSearch credential data source schema. - +## Example Usage + +```terraform +data "stackit_opensearch_credential" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` ## Schema diff --git a/docs/data-sources/postgresql_credential.md b/docs/data-sources/postgresql_credential.md index 25754726..e65f5ce0 100644 --- a/docs/data-sources/postgresql_credential.md +++ b/docs/data-sources/postgresql_credential.md @@ -10,7 +10,15 @@ description: |- PostgreSQL credential data source schema. - +## Example Usage + +```terraform +data "stackit_postgresql_credential" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` ## Schema diff --git a/docs/data-sources/rabbitmq_credential.md b/docs/data-sources/rabbitmq_credential.md index 692206bf..2e5eef28 100644 --- a/docs/data-sources/rabbitmq_credential.md +++ b/docs/data-sources/rabbitmq_credential.md @@ -10,7 +10,15 @@ description: |- RabbitMQ credential data source schema. - +## Example Usage + +```terraform +data "stackit_rabbitmq_credential" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` ## Schema diff --git a/docs/data-sources/redis_credential.md b/docs/data-sources/redis_credential.md index 7089eb1a..66ce4e27 100644 --- a/docs/data-sources/redis_credential.md +++ b/docs/data-sources/redis_credential.md @@ -10,7 +10,15 @@ description: |- Redis credential data source schema. - +## Example Usage + +```terraform +data "stackit_redis_credential" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + credentials_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` ## Schema diff --git a/docs/resources/logme_credential.md b/docs/resources/logme_credential.md index ad63185b..cfc8d30c 100644 --- a/docs/resources/logme_credential.md +++ b/docs/resources/logme_credential.md @@ -10,7 +10,14 @@ description: |- LogMe credential resource schema. - +## Example Usage + +```terraform +resource "stackit_logme_credential" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` ## Schema diff --git a/docs/resources/mariadb_credential.md b/docs/resources/mariadb_credential.md index 2819fe28..8e0b24e8 100644 --- a/docs/resources/mariadb_credential.md +++ b/docs/resources/mariadb_credential.md @@ -10,7 +10,14 @@ description: |- MariaDB credential resource schema. - +## Example Usage + +```terraform +resource "stackit_mariadb_credential" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` ## Schema diff --git a/docs/resources/opensearch_credential.md b/docs/resources/opensearch_credential.md index d8adef7a..6c6ff442 100644 --- a/docs/resources/opensearch_credential.md +++ b/docs/resources/opensearch_credential.md @@ -10,7 +10,14 @@ description: |- OpenSearch credential resource schema. - +## Example Usage + +```terraform +resource "stackit_opensearch_credential" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` ## Schema diff --git a/docs/resources/postgresql_credential.md b/docs/resources/postgresql_credential.md index c3b8a61f..8d587f75 100644 --- a/docs/resources/postgresql_credential.md +++ b/docs/resources/postgresql_credential.md @@ -10,7 +10,14 @@ description: |- PostgreSQL credential resource schema. - +## Example Usage + +```terraform +resource "stackit_postgresql_credential" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` ## Schema diff --git a/docs/resources/rabbitmq_credential.md b/docs/resources/rabbitmq_credential.md index 8a872c76..e37efe47 100644 --- a/docs/resources/rabbitmq_credential.md +++ b/docs/resources/rabbitmq_credential.md @@ -10,7 +10,14 @@ description: |- RabbitMQ credential resource schema. - +## Example Usage + +```terraform +resource "stackit_rabbitmq_credential" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` ## Schema diff --git a/docs/resources/redis_credential.md b/docs/resources/redis_credential.md index 27a1575a..87e4911f 100644 --- a/docs/resources/redis_credential.md +++ b/docs/resources/redis_credential.md @@ -10,7 +10,14 @@ description: |- Redis credential resource schema. - +## Example Usage + +```terraform +resource "stackit_redis_credential" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` ## Schema diff --git a/examples/data-sources/stackit_logme_credentials/data-source.tf b/examples/data-sources/stackit_logme_credential/data-source.tf similarity index 100% rename from examples/data-sources/stackit_logme_credentials/data-source.tf rename to examples/data-sources/stackit_logme_credential/data-source.tf diff --git a/examples/data-sources/stackit_mariadb_credentials/data-source.tf b/examples/data-sources/stackit_mariadb_credential/data-source.tf similarity index 100% rename from examples/data-sources/stackit_mariadb_credentials/data-source.tf rename to examples/data-sources/stackit_mariadb_credential/data-source.tf diff --git a/examples/data-sources/stackit_opensearch_credentials/data-source.tf b/examples/data-sources/stackit_opensearch_credential/data-source.tf similarity index 100% rename from examples/data-sources/stackit_opensearch_credentials/data-source.tf rename to examples/data-sources/stackit_opensearch_credential/data-source.tf diff --git a/examples/data-sources/stackit_postgresql_credentials/data-source.tf b/examples/data-sources/stackit_postgresql_credential/data-source.tf similarity index 100% rename from examples/data-sources/stackit_postgresql_credentials/data-source.tf rename to examples/data-sources/stackit_postgresql_credential/data-source.tf diff --git a/examples/data-sources/stackit_rabbitmq_credentials/data-source.tf b/examples/data-sources/stackit_rabbitmq_credential/data-source.tf similarity index 100% rename from examples/data-sources/stackit_rabbitmq_credentials/data-source.tf rename to examples/data-sources/stackit_rabbitmq_credential/data-source.tf diff --git a/examples/data-sources/stackit_redis_credentials/data-source.tf b/examples/data-sources/stackit_redis_credential/data-source.tf similarity index 100% rename from examples/data-sources/stackit_redis_credentials/data-source.tf rename to examples/data-sources/stackit_redis_credential/data-source.tf diff --git a/examples/resources/stackit_logme_credentials /resource.tf b/examples/resources/stackit_logme_credential/resource.tf similarity index 100% rename from examples/resources/stackit_logme_credentials /resource.tf rename to examples/resources/stackit_logme_credential/resource.tf diff --git a/examples/resources/stackit_mariadb_credentials/resource.tf b/examples/resources/stackit_mariadb_credential/resource.tf similarity index 100% rename from examples/resources/stackit_mariadb_credentials/resource.tf rename to examples/resources/stackit_mariadb_credential/resource.tf diff --git a/examples/resources/stackit_opensearch_credentials/resource.tf b/examples/resources/stackit_opensearch_credential/resource.tf similarity index 100% rename from examples/resources/stackit_opensearch_credentials/resource.tf rename to examples/resources/stackit_opensearch_credential/resource.tf diff --git a/examples/resources/stackit_postgresql_credentials/resource.tf b/examples/resources/stackit_postgresql_credential/resource.tf similarity index 100% rename from examples/resources/stackit_postgresql_credentials/resource.tf rename to examples/resources/stackit_postgresql_credential/resource.tf diff --git a/examples/resources/stackit_rabbitmq_credentials/resource.tf b/examples/resources/stackit_rabbitmq_credential/resource.tf similarity index 100% rename from examples/resources/stackit_rabbitmq_credentials/resource.tf rename to examples/resources/stackit_rabbitmq_credential/resource.tf diff --git a/examples/resources/stackit_redis_credentials/resource.tf b/examples/resources/stackit_redis_credential/resource.tf similarity index 100% rename from examples/resources/stackit_redis_credentials/resource.tf rename to examples/resources/stackit_redis_credential/resource.tf From d38dec397a7fdba40db6cedeb49c89fb920cfef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Palet?= Date: Wed, 11 Oct 2023 08:33:39 +0100 Subject: [PATCH 4/5] Rename folder names --- .../mariadb/{credentials => credential}/datasource.go | 0 .../mariadb/{credentials => credential}/resource.go | 0 .../{credentials => credential}/resource_test.go | 0 .../{credentials => credential}/datasource.go | 0 .../opensearch/{credentials => credential}/resource.go | 0 .../{credentials => credential}/resource_test.go | 0 .../{credentials => credential}/datasource.go | 0 .../postgresql/{credentials => credential}/resource.go | 0 .../{credentials => credential}/resource_test.go | 0 .../rabbitmq/{credentials => credential}/datasource.go | 0 .../rabbitmq/{credentials => credential}/resource.go | 0 .../{credentials => credential}/resource_test.go | 0 .../redis/{credentials => credential}/datasource.go | 0 .../redis/{credentials => credential}/resource.go | 0 .../redis/{credentials => credential}/resource_test.go | 0 stackit/provider.go | 10 +++++----- 16 files changed, 5 insertions(+), 5 deletions(-) rename stackit/internal/services/mariadb/{credentials => credential}/datasource.go (100%) rename stackit/internal/services/mariadb/{credentials => credential}/resource.go (100%) rename stackit/internal/services/mariadb/{credentials => credential}/resource_test.go (100%) rename stackit/internal/services/opensearch/{credentials => credential}/datasource.go (100%) rename stackit/internal/services/opensearch/{credentials => credential}/resource.go (100%) rename stackit/internal/services/opensearch/{credentials => credential}/resource_test.go (100%) rename stackit/internal/services/postgresql/{credentials => credential}/datasource.go (100%) rename stackit/internal/services/postgresql/{credentials => credential}/resource.go (100%) rename stackit/internal/services/postgresql/{credentials => credential}/resource_test.go (100%) rename stackit/internal/services/rabbitmq/{credentials => credential}/datasource.go (100%) rename stackit/internal/services/rabbitmq/{credentials => credential}/resource.go (100%) rename stackit/internal/services/rabbitmq/{credentials => credential}/resource_test.go (100%) rename stackit/internal/services/redis/{credentials => credential}/datasource.go (100%) rename stackit/internal/services/redis/{credentials => credential}/resource.go (100%) rename stackit/internal/services/redis/{credentials => credential}/resource_test.go (100%) diff --git a/stackit/internal/services/mariadb/credentials/datasource.go b/stackit/internal/services/mariadb/credential/datasource.go similarity index 100% rename from stackit/internal/services/mariadb/credentials/datasource.go rename to stackit/internal/services/mariadb/credential/datasource.go diff --git a/stackit/internal/services/mariadb/credentials/resource.go b/stackit/internal/services/mariadb/credential/resource.go similarity index 100% rename from stackit/internal/services/mariadb/credentials/resource.go rename to stackit/internal/services/mariadb/credential/resource.go diff --git a/stackit/internal/services/mariadb/credentials/resource_test.go b/stackit/internal/services/mariadb/credential/resource_test.go similarity index 100% rename from stackit/internal/services/mariadb/credentials/resource_test.go rename to stackit/internal/services/mariadb/credential/resource_test.go diff --git a/stackit/internal/services/opensearch/credentials/datasource.go b/stackit/internal/services/opensearch/credential/datasource.go similarity index 100% rename from stackit/internal/services/opensearch/credentials/datasource.go rename to stackit/internal/services/opensearch/credential/datasource.go diff --git a/stackit/internal/services/opensearch/credentials/resource.go b/stackit/internal/services/opensearch/credential/resource.go similarity index 100% rename from stackit/internal/services/opensearch/credentials/resource.go rename to stackit/internal/services/opensearch/credential/resource.go diff --git a/stackit/internal/services/opensearch/credentials/resource_test.go b/stackit/internal/services/opensearch/credential/resource_test.go similarity index 100% rename from stackit/internal/services/opensearch/credentials/resource_test.go rename to stackit/internal/services/opensearch/credential/resource_test.go diff --git a/stackit/internal/services/postgresql/credentials/datasource.go b/stackit/internal/services/postgresql/credential/datasource.go similarity index 100% rename from stackit/internal/services/postgresql/credentials/datasource.go rename to stackit/internal/services/postgresql/credential/datasource.go diff --git a/stackit/internal/services/postgresql/credentials/resource.go b/stackit/internal/services/postgresql/credential/resource.go similarity index 100% rename from stackit/internal/services/postgresql/credentials/resource.go rename to stackit/internal/services/postgresql/credential/resource.go diff --git a/stackit/internal/services/postgresql/credentials/resource_test.go b/stackit/internal/services/postgresql/credential/resource_test.go similarity index 100% rename from stackit/internal/services/postgresql/credentials/resource_test.go rename to stackit/internal/services/postgresql/credential/resource_test.go diff --git a/stackit/internal/services/rabbitmq/credentials/datasource.go b/stackit/internal/services/rabbitmq/credential/datasource.go similarity index 100% rename from stackit/internal/services/rabbitmq/credentials/datasource.go rename to stackit/internal/services/rabbitmq/credential/datasource.go diff --git a/stackit/internal/services/rabbitmq/credentials/resource.go b/stackit/internal/services/rabbitmq/credential/resource.go similarity index 100% rename from stackit/internal/services/rabbitmq/credentials/resource.go rename to stackit/internal/services/rabbitmq/credential/resource.go diff --git a/stackit/internal/services/rabbitmq/credentials/resource_test.go b/stackit/internal/services/rabbitmq/credential/resource_test.go similarity index 100% rename from stackit/internal/services/rabbitmq/credentials/resource_test.go rename to stackit/internal/services/rabbitmq/credential/resource_test.go diff --git a/stackit/internal/services/redis/credentials/datasource.go b/stackit/internal/services/redis/credential/datasource.go similarity index 100% rename from stackit/internal/services/redis/credentials/datasource.go rename to stackit/internal/services/redis/credential/datasource.go diff --git a/stackit/internal/services/redis/credentials/resource.go b/stackit/internal/services/redis/credential/resource.go similarity index 100% rename from stackit/internal/services/redis/credentials/resource.go rename to stackit/internal/services/redis/credential/resource.go diff --git a/stackit/internal/services/redis/credentials/resource_test.go b/stackit/internal/services/redis/credential/resource_test.go similarity index 100% rename from stackit/internal/services/redis/credentials/resource_test.go rename to stackit/internal/services/redis/credential/resource_test.go diff --git a/stackit/provider.go b/stackit/provider.go index 8db68a59..00f3f0b2 100644 --- a/stackit/provider.go +++ b/stackit/provider.go @@ -16,18 +16,18 @@ import ( dnsZone "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/dns/zone" logMeCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/logme/credential" logMeInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/logme/instance" - mariaDBCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/mariadb/credentials" + mariaDBCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/mariadb/credential" mariaDBInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/mariadb/instance" objectStorageBucket "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/objectstorage/bucket" - openSearchCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/opensearch/credentials" + openSearchCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/opensearch/credential" openSearchInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/opensearch/instance" postgresFlexInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresflex/instance" postgresFlexUser "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresflex/user" - postgresCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresql/credentials" + postgresCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresql/credential" postgresInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresql/instance" - rabbitMQCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/rabbitmq/credentials" + rabbitMQCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/rabbitmq/credential" rabbitMQInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/rabbitmq/instance" - redisCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/redis/credentials" + redisCredential "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/redis/credential" redisInstance "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/redis/instance" resourceManagerProject "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/resourcemanager/project" skeCluster "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/ske/cluster" From fc14c9f49ecc278c399fc1adf74be31f8fad5672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Palet?= Date: Wed, 11 Oct 2023 08:43:32 +0100 Subject: [PATCH 5/5] Rename in error messages --- .../services/logme/credential/datasource.go | 4 ++-- .../services/logme/credential/resource.go | 22 +++++++++---------- .../services/mariadb/credential/datasource.go | 4 ++-- .../services/mariadb/credential/resource.go | 22 +++++++++---------- .../opensearch/credential/datasource.go | 4 ++-- .../opensearch/credential/resource.go | 22 +++++++++---------- .../postgresql/credential/datasource.go | 4 ++-- .../postgresql/credential/resource.go | 22 +++++++++---------- .../rabbitmq/credential/datasource.go | 4 ++-- .../services/rabbitmq/credential/resource.go | 22 +++++++++---------- .../services/redis/credential/datasource.go | 4 ++-- .../services/redis/credential/resource.go | 22 +++++++++---------- 12 files changed, 78 insertions(+), 78 deletions(-) diff --git a/stackit/internal/services/logme/credential/datasource.go b/stackit/internal/services/logme/credential/datasource.go index 248c4f3e..7d633f51 100644 --- a/stackit/internal/services/logme/credential/datasource.go +++ b/stackit/internal/services/logme/credential/datasource.go @@ -160,14 +160,14 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err)) return } // Map response body to schema err = mapFields(recordSetResp, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err)) return } diff --git a/stackit/internal/services/logme/credential/resource.go b/stackit/internal/services/logme/credential/resource.go index 7890f034..369661b1 100644 --- a/stackit/internal/services/logme/credential/resource.go +++ b/stackit/internal/services/logme/credential/resource.go @@ -198,11 +198,11 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ // Create new recordset credentialsResp, err := r.client.CreateCredentials(ctx, projectId, instanceId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err)) return } if credentialsResp.Id == nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", "Got empty credentials id") + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credentials id") return } credentialsId := *credentialsResp.Id @@ -210,19 +210,19 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ wr, err := wait.CreateCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Instance creation waiting: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Instance creation waiting: %v", err)) return } got, ok := wr.(*logme.CredentialsResponse) if !ok { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Wait result conversion, got %+v", wr)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Wait result conversion, got %+v", wr)) return } // Map response body to schema err = mapFields(got, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Processing API payload: %v", err)) return } diags = resp.State.Set(ctx, model) @@ -250,14 +250,14 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err)) return } // Map response body to schema err = mapFields(recordSetResp, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err)) return } @@ -273,7 +273,7 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, // Update updates the resource and sets the updated Terraform state on success. func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform // Update shouldn't be called - core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "credential can't be updated") + core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credential", "Credential can't be updated") } // Delete deletes the resource and removes the Terraform state on success. @@ -295,11 +295,11 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ // Delete existing record set err := r.client.DeleteCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err)) } _, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Instance deletion waiting: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err)) return } tflog.Info(ctx, "LogMe credentials deleted") @@ -311,7 +311,7 @@ func (r *credentialResource) ImportState(ctx context.Context, req resource.Impor idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" { core.LogAndAddError(ctx, &resp.Diagnostics, - "Error importing credentials", + "Error importing credential", fmt.Sprintf("Expected import identifier with format [project_id],[instance_id],[credentials_id], got %q", req.ID), ) return diff --git a/stackit/internal/services/mariadb/credential/datasource.go b/stackit/internal/services/mariadb/credential/datasource.go index 659ccbea..be81fc81 100644 --- a/stackit/internal/services/mariadb/credential/datasource.go +++ b/stackit/internal/services/mariadb/credential/datasource.go @@ -160,14 +160,14 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err)) return } // Map response body to schema err = mapFields(recordSetResp, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err)) return } diff --git a/stackit/internal/services/mariadb/credential/resource.go b/stackit/internal/services/mariadb/credential/resource.go index a46b1bc7..7ad7f02b 100644 --- a/stackit/internal/services/mariadb/credential/resource.go +++ b/stackit/internal/services/mariadb/credential/resource.go @@ -198,11 +198,11 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ // Create new recordset credentialsResp, err := r.client.CreateCredentials(ctx, projectId, instanceId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err)) return } if credentialsResp.Id == nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", "Got empty credentials id") + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credentials id") return } credentialsId := *credentialsResp.Id @@ -210,19 +210,19 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ wr, err := wait.CreateCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Instance creation waiting: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Instance creation waiting: %v", err)) return } got, ok := wr.(*mariadb.CredentialsResponse) if !ok { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Wait result conversion, got %+v", wr)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Wait result conversion, got %+v", wr)) return } // Map response body to schema err = mapFields(got, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Processing API payload: %v", err)) return } diags = resp.State.Set(ctx, model) @@ -250,14 +250,14 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err)) return } // Map response body to schema err = mapFields(recordSetResp, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err)) return } @@ -273,7 +273,7 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, // Update updates the resource and sets the updated Terraform state on success. func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform // Update shouldn't be called - core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated") + core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credential", "Credential can't be updated") } // Delete deletes the resource and removes the Terraform state on success. @@ -295,11 +295,11 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ // Delete existing record set err := r.client.DeleteCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err)) } _, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Instance deletion waiting: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err)) return } tflog.Info(ctx, "MariaDB credentials deleted") @@ -311,7 +311,7 @@ func (r *credentialResource) ImportState(ctx context.Context, req resource.Impor idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" { core.LogAndAddError(ctx, &resp.Diagnostics, - "Error importing credentials", + "Error importing credential", fmt.Sprintf("Expected import identifier with format [project_id],[instance_id],[credentials_id], got %q", req.ID), ) return diff --git a/stackit/internal/services/opensearch/credential/datasource.go b/stackit/internal/services/opensearch/credential/datasource.go index bb240574..89299828 100644 --- a/stackit/internal/services/opensearch/credential/datasource.go +++ b/stackit/internal/services/opensearch/credential/datasource.go @@ -160,14 +160,14 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err)) return } // Map response body to schema err = mapFields(recordSetResp, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err)) return } diff --git a/stackit/internal/services/opensearch/credential/resource.go b/stackit/internal/services/opensearch/credential/resource.go index 3b9c9cde..d636111d 100644 --- a/stackit/internal/services/opensearch/credential/resource.go +++ b/stackit/internal/services/opensearch/credential/resource.go @@ -198,11 +198,11 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ // Create new recordset credentialsResp, err := r.client.CreateCredentials(ctx, projectId, instanceId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err)) return } if credentialsResp.Id == nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", "Got empty credentials id") + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credentials id") return } credentialsId := *credentialsResp.Id @@ -210,19 +210,19 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ wr, err := wait.CreateCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Instance creation waiting: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Instance creation waiting: %v", err)) return } got, ok := wr.(*opensearch.CredentialsResponse) if !ok { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Wait result conversion, got %+v", wr)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Wait result conversion, got %+v", wr)) return } // Map response body to schema err = mapFields(got, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Processing API payload: %v", err)) return } diags = resp.State.Set(ctx, model) @@ -250,14 +250,14 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err)) return } // Map response body to schema err = mapFields(recordSetResp, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err)) return } @@ -273,7 +273,7 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, // Update updates the resource and sets the updated Terraform state on success. func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform // Update shouldn't be called - core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated") + core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credential", "Credential can't be updated") } // Delete deletes the resource and removes the Terraform state on success. @@ -295,11 +295,11 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ // Delete existing record set err := r.client.DeleteCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err)) } _, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Instance deletion waiting: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err)) return } tflog.Info(ctx, "OpenSearch credentials deleted") @@ -311,7 +311,7 @@ func (r *credentialResource) ImportState(ctx context.Context, req resource.Impor idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" { core.LogAndAddError(ctx, &resp.Diagnostics, - "Error importing credentials", + "Error importing credential", fmt.Sprintf("Expected import identifier with format [project_id],[instance_id],[credentials_id], got %q", req.ID), ) return diff --git a/stackit/internal/services/postgresql/credential/datasource.go b/stackit/internal/services/postgresql/credential/datasource.go index 1e6c7a27..2bc0f3ee 100644 --- a/stackit/internal/services/postgresql/credential/datasource.go +++ b/stackit/internal/services/postgresql/credential/datasource.go @@ -160,14 +160,14 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err)) return } // Map response body to schema err = mapFields(recordSetResp, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err)) return } diff --git a/stackit/internal/services/postgresql/credential/resource.go b/stackit/internal/services/postgresql/credential/resource.go index 17756e6c..bceb7e97 100644 --- a/stackit/internal/services/postgresql/credential/resource.go +++ b/stackit/internal/services/postgresql/credential/resource.go @@ -198,11 +198,11 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ // Create new recordset credentialsResp, err := r.client.CreateCredentials(ctx, projectId, instanceId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err)) return } if credentialsResp.Id == nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", "Got empty credentials id") + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credentials id") return } credentialsId := *credentialsResp.Id @@ -210,19 +210,19 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ wr, err := wait.CreateCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Instance creation waiting: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Instance creation waiting: %v", err)) return } got, ok := wr.(*postgresql.CredentialsResponse) if !ok { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Wait result conversion, got %+v", wr)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Wait result conversion, got %+v", wr)) return } // Map response body to schema err = mapFields(got, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Processing API payload: %v", err)) return } diags = resp.State.Set(ctx, model) @@ -250,14 +250,14 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err)) return } // Map response body to schema err = mapFields(recordSetResp, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err)) return } @@ -273,7 +273,7 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, // Update updates the resource and sets the updated Terraform state on success. func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform // Update shouldn't be called - core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated") + core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credential", "Credential can't be updated") } // Delete deletes the resource and removes the Terraform state on success. @@ -295,11 +295,11 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ // Delete existing record set err := r.client.DeleteCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err)) } _, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Instance deletion waiting: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err)) return } tflog.Info(ctx, "PostgreSQL credentials deleted") @@ -311,7 +311,7 @@ func (r *credentialResource) ImportState(ctx context.Context, req resource.Impor idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" { core.LogAndAddError(ctx, &resp.Diagnostics, - "Error importing credentials", + "Error importing credential", fmt.Sprintf("Expected import identifier with format [project_id],[instance_id],[credentials_id], got %q", req.ID), ) return diff --git a/stackit/internal/services/rabbitmq/credential/datasource.go b/stackit/internal/services/rabbitmq/credential/datasource.go index c299af41..2d0c458e 100644 --- a/stackit/internal/services/rabbitmq/credential/datasource.go +++ b/stackit/internal/services/rabbitmq/credential/datasource.go @@ -160,14 +160,14 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err)) return } // Map response body to schema err = mapFields(recordSetResp, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err)) return } diff --git a/stackit/internal/services/rabbitmq/credential/resource.go b/stackit/internal/services/rabbitmq/credential/resource.go index 7f60deb9..372fc893 100644 --- a/stackit/internal/services/rabbitmq/credential/resource.go +++ b/stackit/internal/services/rabbitmq/credential/resource.go @@ -198,11 +198,11 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ // Create new recordset credentialsResp, err := r.client.CreateCredentials(ctx, projectId, instanceId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err)) return } if credentialsResp.Id == nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", "Got empty credentials id") + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credentials id") return } credentialsId := *credentialsResp.Id @@ -210,19 +210,19 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ wr, err := wait.CreateCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Instance creation waiting: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Instance creation waiting: %v", err)) return } got, ok := wr.(*rabbitmq.CredentialsResponse) if !ok { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Wait result conversion, got %+v", wr)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Wait result conversion, got %+v", wr)) return } // Map response body to schema err = mapFields(got, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Processing API payload: %v", err)) return } diags = resp.State.Set(ctx, model) @@ -250,14 +250,14 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err)) return } // Map response body to schema err = mapFields(recordSetResp, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err)) return } @@ -273,7 +273,7 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, // Update updates the resource and sets the updated Terraform state on success. func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform // Update shouldn't be called - core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated") + core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credential", "Credential can't be updated") } // Delete deletes the resource and removes the Terraform state on success. @@ -295,11 +295,11 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ // Delete existing record set err := r.client.DeleteCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err)) } _, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Instance deletion waiting: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err)) return } tflog.Info(ctx, "RabbitMQ credentials deleted") @@ -311,7 +311,7 @@ func (r *credentialResource) ImportState(ctx context.Context, req resource.Impor idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" { core.LogAndAddError(ctx, &resp.Diagnostics, - "Error importing credentials", + "Error importing credential", fmt.Sprintf("Expected import identifier with format [project_id],[instance_id],[credentials_id], got %q", req.ID), ) return diff --git a/stackit/internal/services/redis/credential/datasource.go b/stackit/internal/services/redis/credential/datasource.go index 25026e15..1a6f2166 100644 --- a/stackit/internal/services/redis/credential/datasource.go +++ b/stackit/internal/services/redis/credential/datasource.go @@ -160,14 +160,14 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err)) return } // Map response body to schema err = mapFields(recordSetResp, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err)) return } diff --git a/stackit/internal/services/redis/credential/resource.go b/stackit/internal/services/redis/credential/resource.go index d09724d2..d953d499 100644 --- a/stackit/internal/services/redis/credential/resource.go +++ b/stackit/internal/services/redis/credential/resource.go @@ -198,11 +198,11 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ // Create new recordset credentialsResp, err := r.client.CreateCredentials(ctx, projectId, instanceId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err)) return } if credentialsResp.Id == nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", "Got empty credentials id") + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credentials id") return } credentialsId := *credentialsResp.Id @@ -210,19 +210,19 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ wr, err := wait.CreateCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Instance creation waiting: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Instance creation waiting: %v", err)) return } got, ok := wr.(*redis.CredentialsResponse) if !ok { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Wait result conversion, got %+v", wr)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Wait result conversion, got %+v", wr)) return } // Map response body to schema err = mapFields(got, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Processing API payload: %v", err)) return } diags = resp.State.Set(ctx, model) @@ -250,14 +250,14 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, recordSetResp, err := r.client.GetCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Calling API: %v", err)) return } // Map response body to schema err = mapFields(recordSetResp, &model) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials", fmt.Sprintf("Processing API payload: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Processing API payload: %v", err)) return } @@ -273,7 +273,7 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest, // Update updates the resource and sets the updated Terraform state on success. func (r *credentialResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform // Update shouldn't be called - core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credentials", "Credentials can't be updated") + core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating credential", "Credential can't be updated") } // Delete deletes the resource and removes the Terraform state on success. @@ -295,11 +295,11 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ // Delete existing record set err := r.client.DeleteCredentials(ctx, projectId, instanceId, credentialsId).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err)) } _, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialsId).SetTimeout(1 * time.Minute).WaitWithContext(ctx) if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials", fmt.Sprintf("Instance deletion waiting: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err)) return } tflog.Info(ctx, "Redis credentials deleted") @@ -311,7 +311,7 @@ func (r *credentialResource) ImportState(ctx context.Context, req resource.Impor idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" { core.LogAndAddError(ctx, &resp.Diagnostics, - "Error importing credentials", + "Error importing credential", fmt.Sprintf("Expected import identifier with format [project_id],[instance_id],[credentials_id], got %q", req.ID), ) return