diff --git a/internal/testutils/testutils.go b/internal/testutils/testutils.go index 2e8ba9d4..142efe13 100644 --- a/internal/testutils/testutils.go +++ b/internal/testutils/testutils.go @@ -19,8 +19,7 @@ import ( ) const ( - // Default location of credentials JSON - // credentialsFilePath = ".stackit/credentials.json" //nolint:gosec // linter false positive + // Default location of service account JSON serviceAccountFilePath = "service_account.json" ) diff --git a/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go b/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go index 64b7e901..b5707376 100644 --- a/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go +++ b/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go @@ -54,14 +54,6 @@ func TestInstanceResourceSchema(t *testing.T) { } } -var ( - //go:embed testdata/resource-no-enc.tf - resourceConfigNoEnc string //nolint:unused // needs implementation - - //go:embed testdata/resource-enc.tf - resourceConfigEnc string //nolint:unused // needs implementation -) - func TestMain(m *testing.M) { testutils.Setup() code := m.Run() diff --git a/stackit/internal/services/postgresflexalpha/testdata/resource-enc.tf b/stackit/internal/services/postgresflexalpha/testdata/resource-enc.tf deleted file mode 100644 index 65fd46d9..00000000 --- a/stackit/internal/services/postgresflexalpha/testdata/resource-enc.tf +++ /dev/null @@ -1,27 +0,0 @@ -variable "project_id" {} -variable "kek_key_id" {} -variable "kek_key_ring_id" {} - -resource "stackitprivatepreview_postgresflexalpha_instance" "msh-instance-only" { - project_id = var.project_id - name = "example-instance" - backup_schedule = "0 0 * * *" - retention_days = 30 - flavor_id = "2.4" - replicas = 1 - storage = { - performance_class = "premium-perf2-stackit" - size = 10 - } - encryption = { - kek_key_id = var.kek_key_id - kek_key_ring_id = var.kek_key_ring_id - kek_key_version = 1 - service_account = "service@account.email" - } - network = { - acl = ["0.0.0.0/0"] - access_scope = "PUBLIC" - } - version = 17 -} diff --git a/stackit/internal/services/postgresflexalpha/testdata/resource-no-enc.tf b/stackit/internal/services/postgresflexalpha/testdata/resource-no-enc.tf deleted file mode 100644 index 79ce16e3..00000000 --- a/stackit/internal/services/postgresflexalpha/testdata/resource-no-enc.tf +++ /dev/null @@ -1,19 +0,0 @@ -variable "project_id" {} - -resource "stackitprivatepreview_postgresflexalpha_instance" "msh-instance-only" { - project_id = var.project_id - name = "example-instance" - backup_schedule = "0 0 * * *" - retention_days = 30 - flavor_id = "2.4" - replicas = 1 - storage = { - performance_class = "premium-perf2-stackit" - size = 10 - } - network = { - acl = ["0.0.0.0/0"] - access_scope = "PUBLIC" - } - version = 17 -} diff --git a/stackit/provider.go b/stackit/provider.go index 47c42a6a..62990050 100644 --- a/stackit/provider.go +++ b/stackit/provider.go @@ -6,7 +6,6 @@ import ( "context" "fmt" "strings" - "time" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -45,7 +44,10 @@ var ( _ provider.Provider = &Provider{} ) +const providerConfigError = "Error configuring provider" + //nolint:unused // These constants are defined for future use in retry logic for HTTP requests, which is not yet implemented. +/* const ( // maxRetries is the maximum number of retries for a failed HTTP request. maxRetries = 3 @@ -56,6 +58,7 @@ const ( // perTryTimeout is the timeout for each individual HTTP request attempt. perTryTimeout = 30 * time.Second ) +*/ // Provider is the provider implementation. type Provider struct { @@ -91,7 +94,7 @@ type providerModel struct { // Custom endpoints AuthorizationCustomEndpoint types.String `tfsdk:"authorization_custom_endpoint"` CdnCustomEndpoint types.String `tfsdk:"cdn_custom_endpoint"` - DnsCustomEndpoint types.String `tfsdk:"dns_custom_endpoint"` + DNSCustomEndpoint types.String `tfsdk:"dns_custom_endpoint"` GitCustomEndpoint types.String `tfsdk:"git_custom_endpoint"` IaaSCustomEndpoint types.String `tfsdk:"iaas_custom_endpoint"` KmsCustomEndpoint types.String `tfsdk:"kms_custom_endpoint"` @@ -369,7 +372,7 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, core.LogAndAddError( ctx, &resp.Diagnostics, - "Error configuring provider", + providerConfigError, fmt.Sprintf("Setting up bool value: %v", diags.Errors()), ) } @@ -388,7 +391,7 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, setStringField(providerConfig.DefaultRegion, func(v string) { providerData.DefaultRegion = v }) setStringField( - providerConfig.Region, + providerConfig.Region, // nolint:staticcheck // preliminary handling of deprecated attribute func(v string) { providerData.Region = v }, // nolint:staticcheck // preliminary handling of deprecated attribute ) setBoolField(providerConfig.EnableBetaResources, func(v bool) { providerData.EnableBetaResources = v }) @@ -398,7 +401,7 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, func(v string) { providerData.AuthorizationCustomEndpoint = v }, ) setStringField(providerConfig.CdnCustomEndpoint, func(v string) { providerData.CdnCustomEndpoint = v }) - setStringField(providerConfig.DnsCustomEndpoint, func(v string) { providerData.DnsCustomEndpoint = v }) + setStringField(providerConfig.DNSCustomEndpoint, func(v string) { providerData.DnsCustomEndpoint = v }) setStringField(providerConfig.GitCustomEndpoint, func(v string) { providerData.GitCustomEndpoint = v }) setStringField(providerConfig.IaaSCustomEndpoint, func(v string) { providerData.IaaSCustomEndpoint = v }) setStringField(providerConfig.KmsCustomEndpoint, func(v string) { providerData.KMSCustomEndpoint = v }) @@ -472,7 +475,7 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, core.LogAndAddError( ctx, &resp.Diagnostics, - "Error configuring provider", + providerConfigError, fmt.Sprintf("Setting up experiments: %v", diags.Errors()), ) } @@ -484,7 +487,7 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, core.LogAndAddError( ctx, &resp.Diagnostics, - "Error configuring provider", + providerConfigError, fmt.Sprintf("Setting up authentication: %v", err), ) return