fix: builder and sdk changes #81
5 changed files with 11 additions and 63 deletions
|
|
@ -19,8 +19,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Default location of credentials JSON
|
// Default location of service account JSON
|
||||||
// credentialsFilePath = ".stackit/credentials.json" //nolint:gosec // linter false positive
|
|
||||||
serviceAccountFilePath = "service_account.json"
|
serviceAccountFilePath = "service_account.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
func TestMain(m *testing.M) {
|
||||||
testutils.Setup()
|
testutils.Setup()
|
||||||
code := m.Run()
|
code := m.Run()
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
}
|
|
||||||
|
|
@ -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
|
|
||||||
}
|
|
||||||
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
|
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
|
||||||
"github.com/hashicorp/terraform-plugin-framework/datasource"
|
"github.com/hashicorp/terraform-plugin-framework/datasource"
|
||||||
|
|
@ -45,7 +44,10 @@ var (
|
||||||
_ provider.Provider = &Provider{}
|
_ 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.
|
//nolint:unused // These constants are defined for future use in retry logic for HTTP requests, which is not yet implemented.
|
||||||
|
/*
|
||||||
const (
|
const (
|
||||||
// maxRetries is the maximum number of retries for a failed HTTP request.
|
// maxRetries is the maximum number of retries for a failed HTTP request.
|
||||||
maxRetries = 3
|
maxRetries = 3
|
||||||
|
|
@ -56,6 +58,7 @@ const (
|
||||||
// perTryTimeout is the timeout for each individual HTTP request attempt.
|
// perTryTimeout is the timeout for each individual HTTP request attempt.
|
||||||
perTryTimeout = 30 * time.Second
|
perTryTimeout = 30 * time.Second
|
||||||
)
|
)
|
||||||
|
*/
|
||||||
|
|
||||||
// Provider is the provider implementation.
|
// Provider is the provider implementation.
|
||||||
type Provider struct {
|
type Provider struct {
|
||||||
|
|
@ -91,7 +94,7 @@ type providerModel struct {
|
||||||
// Custom endpoints
|
// Custom endpoints
|
||||||
AuthorizationCustomEndpoint types.String `tfsdk:"authorization_custom_endpoint"`
|
AuthorizationCustomEndpoint types.String `tfsdk:"authorization_custom_endpoint"`
|
||||||
CdnCustomEndpoint types.String `tfsdk:"cdn_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"`
|
GitCustomEndpoint types.String `tfsdk:"git_custom_endpoint"`
|
||||||
IaaSCustomEndpoint types.String `tfsdk:"iaas_custom_endpoint"`
|
IaaSCustomEndpoint types.String `tfsdk:"iaas_custom_endpoint"`
|
||||||
KmsCustomEndpoint types.String `tfsdk:"kms_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(
|
core.LogAndAddError(
|
||||||
ctx,
|
ctx,
|
||||||
&resp.Diagnostics,
|
&resp.Diagnostics,
|
||||||
"Error configuring provider",
|
providerConfigError,
|
||||||
fmt.Sprintf("Setting up bool value: %v", diags.Errors()),
|
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.DefaultRegion, func(v string) { providerData.DefaultRegion = v })
|
||||||
setStringField(
|
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
|
func(v string) { providerData.Region = v }, // nolint:staticcheck // preliminary handling of deprecated attribute
|
||||||
)
|
)
|
||||||
setBoolField(providerConfig.EnableBetaResources, func(v bool) { providerData.EnableBetaResources = v })
|
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 },
|
func(v string) { providerData.AuthorizationCustomEndpoint = v },
|
||||||
)
|
)
|
||||||
setStringField(providerConfig.CdnCustomEndpoint, func(v string) { providerData.CdnCustomEndpoint = 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.GitCustomEndpoint, func(v string) { providerData.GitCustomEndpoint = v })
|
||||||
setStringField(providerConfig.IaaSCustomEndpoint, func(v string) { providerData.IaaSCustomEndpoint = v })
|
setStringField(providerConfig.IaaSCustomEndpoint, func(v string) { providerData.IaaSCustomEndpoint = v })
|
||||||
setStringField(providerConfig.KmsCustomEndpoint, func(v string) { providerData.KMSCustomEndpoint = 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(
|
core.LogAndAddError(
|
||||||
ctx,
|
ctx,
|
||||||
&resp.Diagnostics,
|
&resp.Diagnostics,
|
||||||
"Error configuring provider",
|
providerConfigError,
|
||||||
fmt.Sprintf("Setting up experiments: %v", diags.Errors()),
|
fmt.Sprintf("Setting up experiments: %v", diags.Errors()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -484,7 +487,7 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest,
|
||||||
core.LogAndAddError(
|
core.LogAndAddError(
|
||||||
ctx,
|
ctx,
|
||||||
&resp.Diagnostics,
|
&resp.Diagnostics,
|
||||||
"Error configuring provider",
|
providerConfigError,
|
||||||
fmt.Sprintf("Setting up authentication: %v", err),
|
fmt.Sprintf("Setting up authentication: %v", err),
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue