fix: remove identity from sqlserverbeta and postresflexalpha
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 6s
TF Acceptance Tests Workflow / Acceptance Tests (pull_request) Failing after 4m51s
CI Workflow / Prepare GO cache (pull_request) Successful in 6m12s
CI Workflow / Code coverage report (pull_request) Has been cancelled
CI Workflow / Test readiness for publishing provider (pull_request) Has been cancelled
CI Workflow / CI run tests (pull_request) Has been cancelled
CI Workflow / CI run build and linting (pull_request) Has been cancelled

This commit is contained in:
Marcel S. Henselin 2026-03-17 14:31:25 +01:00
parent 042e8115a6
commit 746f7cdfbd
13 changed files with 1438 additions and 259 deletions

View file

@ -160,7 +160,7 @@ func TestMapResourceFields(t *testing.T) {
},
expected: expected{
model: &resourceModel{
Id: types.Int64Value(1),
Id: types.StringValue("1"),
Name: types.StringValue("my-db"),
Owner: types.StringValue("my-owner"),
DatabaseId: types.Int64Value(1),

View file

@ -30,10 +30,6 @@ var (
_ resource.ResourceWithConfigure = &databaseResource{}
_ resource.ResourceWithImportState = &databaseResource{}
_ resource.ResourceWithModifyPlan = &databaseResource{}
// Error message constants
extractErrorSummary = "extracting failed"
extractErrorMessage = "Extracting identity data: %v"
)
// NewDatabaseResource is a helper function to simplify the provider implementation.

View file

@ -55,13 +55,11 @@ func mapGetInstanceResponseToModel(
}
m.FlavorId = types.StringValue(resp.GetFlavorId())
//if m.Id.IsNull() || m.Id.IsUnknown() {
m.Id = utils.BuildInternalTerraformId(
m.ProjectId.ValueString(),
m.Region.ValueString(),
m.InstanceId.ValueString(),
resp.Id,
)
//}
m.InstanceId = types.StringValue(resp.Id)
m.IsDeletable = types.BoolValue(resp.GetIsDeletable())

View file

@ -163,16 +163,16 @@ func TestAccInstance(t *testing.T) {
t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
t.Logf(" ... working on instance %s", exData.TfName)
t.Logf(" ... %s - %s", t.Name(), exData.TfName)
},
CheckDestroy: testAccCheckPostgresFlexDestroy,
ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and verify
{
//PreConfig: func() {
// //
// },
PreConfig: func() {
t.Logf("testing: %s - %s", t.Name(), "create and verify")
},
Config: testutils.StringFromTemplateMust(
"testdata/instance_template.gompl",
exData,
@ -210,9 +210,9 @@ func TestAccInstance(t *testing.T) {
},
// Second apply should not have changes
{
//PreConfig: func() {
// //
// },
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "second apply")
},
Config: testutils.StringFromTemplateMust(
"testdata/instance_template.gompl",
exData,
@ -236,10 +236,16 @@ func TestAccInstance(t *testing.T) {
},
// Refresh state test
{
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "refresh state")
},
RefreshState: true,
},
// Update name and verify
{
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "update name")
},
Config: testutils.StringFromTemplateMust(
"testdata/instance_template.gompl",
updNameData,
@ -259,6 +265,9 @@ func TestAccInstance(t *testing.T) {
},
// Update size and verify
{
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "update storage.size")
},
Config: testutils.StringFromTemplateMust(
"testdata/instance_template.gompl",
updSizeData,
@ -275,6 +284,9 @@ func TestAccInstance(t *testing.T) {
},
// Update backup schedule
{
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "update backup schedule")
},
Config: testutils.StringFromTemplateMust(
"testdata/instance_template.gompl",
updBackupSched,
@ -291,6 +303,9 @@ func TestAccInstance(t *testing.T) {
},
// Update network ACL
{
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "update network.acl")
},
Config: testutils.StringFromTemplateMust(
"testdata/instance_template.gompl",
updNetACL,
@ -307,6 +322,9 @@ func TestAccInstance(t *testing.T) {
},
// Update version
{
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "update version")
},
Config: testutils.StringFromTemplateMust(
"testdata/instance_template.gompl",
updVersion,
@ -322,6 +340,9 @@ func TestAccInstance(t *testing.T) {
// Import test
// test instance imports
{
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "import instance")
},
ResourceName: testItemID,
// ImportStateIdPrefix: "",
// ImportStateVerifyIdentifierAttribute: "id",
@ -346,13 +367,16 @@ func TestAccInstanceHA(t *testing.T) {
t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
t.Logf(" ... working on instance %s", data.TfName)
t.Logf(" ... %s - %s", t.Name(), data.TfName)
},
CheckDestroy: testAccCheckPostgresFlexDestroy,
ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and verify
{
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "create and verify")
},
Config: testutils.StringFromTemplateMust(
"testdata/instance_template.gompl",
data,
@ -384,13 +408,16 @@ func TestAccInstanceWithUsers(t *testing.T) {
t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
t.Logf(" ... working on instance %s", data.TfName)
t.Logf(" ... %s - %s", t.Name(), data.TfName)
},
CheckDestroy: testAccCheckPostgresFlexDestroy,
ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and verify
{
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "create and verify")
},
Config: testutils.StringFromTemplateMust(
"testdata/instance_template.gompl",
data,
@ -435,13 +462,16 @@ func TestAccInstanceWithDatabases(t *testing.T) {
t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
t.Logf(" ... working on instance %s", data.TfName)
t.Logf(" ... %s - %s", t.Name(), data.TfName)
},
CheckDestroy: testAccCheckPostgresFlexDestroy,
ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and verify
{
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "create and verify")
},
Config: testutils.StringFromTemplateMust(
"testdata/instance_template.gompl",
data,
@ -449,6 +479,7 @@ func TestAccInstanceWithDatabases(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
defaultNoEncInstanceTestChecks(testItemID, data),
// TODO - extract also to functions
resource.TestCheckResourceAttr(testutils.ResStr(pfx, "user", userName), "name", userName),
resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "user", userName), "id"),
resource.TestCheckResourceAttrPair(
@ -460,6 +491,7 @@ func TestAccInstanceWithDatabases(t *testing.T) {
testutils.ResStr(pfx, "user", userName), "instance_id",
),
// TODO - extract also to functions
resource.TestCheckResourceAttr(testutils.ResStr(pfx, "database", dbName), "name", dbName),
resource.TestCheckResourceAttr(testutils.ResStr(pfx, "database", dbName), "owner", userName),
resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "database", dbName), "id"),
@ -475,6 +507,9 @@ func TestAccInstanceWithDatabases(t *testing.T) {
},
// data source
{
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "datasource")
},
Config: testutils.StringFromTemplateMust(
"testdata/instance_template.gompl",
data,
@ -561,6 +596,9 @@ func TestAccInstanceWithDatabases(t *testing.T) {
},
// test instance imports
{
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "import instance")
},
ResourceName: testItemID,
// ImportStateIdPrefix: "",
ImportStateVerifyIdentifierAttribute: "id",
@ -571,6 +609,9 @@ func TestAccInstanceWithDatabases(t *testing.T) {
},
// test database imports
{
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "import database")
},
ResourceName: testutils.ResStr(pfx, "database", dbName),
// ImportStateIdPrefix: "",
// ImportStateVerifyIdentifierAttribute: "id",
@ -581,6 +622,9 @@ func TestAccInstanceWithDatabases(t *testing.T) {
},
// test user imports
{
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "import user")
},
ResourceName: testutils.ResStr(pfx, "user", userName),
// ImportStateIdPrefix: "",
// ImportStateVerifyIdentifierAttribute: "id",
@ -653,13 +697,16 @@ func TestAccEncryptedInstanceWithDatabases(t *testing.T) {
t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
t.Logf(" ... working on instance %s", data.TfName)
t.Logf(" ... %s - %s", t.Name(), data.TfName)
},
CheckDestroy: testAccCheckPostgresFlexDestroy,
ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and verify
{
PreConfig: func() {
t.Logf(" ... %s - %s", t.Name(), "create and verify")
},
Config: testutils.StringFromTemplateMust(
"testdata/instance_template.gompl",
data,

View file

@ -26,7 +26,9 @@ resource "stackitprivatepreview_postgresflexalpha_instance" "{{ .TfName }}" {
acl = [{{ range $i, $v := .ACLStrings }}{{if $i}},{{end}}"{{$v}}"{{end}}]
access_scope = "{{ .AccessScope }}"
}
version = {{ .Version }}
{{ if .Version }}
version = "{{ .Version }}"
{{ end }}
}
{{ if .Users }}

View file

@ -165,7 +165,7 @@ func TestMapFieldsCreate(t *testing.T) {
},
testRegion,
resourceModel{
Id: types.Int64Value(1),
Id: types.StringValue("1"),
UserId: types.Int64Value(1),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
@ -187,7 +187,7 @@ func TestMapFieldsCreate(t *testing.T) {
},
testRegion,
resourceModel{
Id: types.Int64Value(1),
Id: types.StringValue("1"),
UserId: types.Int64Value(1),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
@ -209,7 +209,7 @@ func TestMapFieldsCreate(t *testing.T) {
},
testRegion,
resourceModel{
Id: types.Int64Value(1),
Id: types.StringValue("1"),
UserId: types.Int64Value(1),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
@ -286,7 +286,7 @@ func TestMapFields(t *testing.T) {
},
testRegion,
resourceModel{
Id: types.Int64Value(1),
Id: types.StringValue("1"),
UserId: types.Int64Value(int64(1)),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
@ -311,7 +311,7 @@ func TestMapFields(t *testing.T) {
},
testRegion,
resourceModel{
Id: types.Int64Value(1),
Id: types.StringValue("1"),
UserId: types.Int64Value(1),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),
@ -339,7 +339,7 @@ func TestMapFields(t *testing.T) {
},
testRegion,
resourceModel{
Id: types.Int64Value(1),
Id: types.StringValue("1"),
UserId: types.Int64Value(1),
InstanceId: types.StringValue("iid"),
ProjectId: types.StringValue("pid"),

View file

@ -35,10 +35,6 @@ var (
_ resource.ResourceWithImportState = &userResource{}
_ resource.ResourceWithModifyPlan = &userResource{}
_ resource.ResourceWithValidateConfig = &userResource{}
// Error message constants
extractErrorSummary = "extracting failed"
extractErrorMessage = "Extracting identity data: %v"
)
// NewUserResource is a helper function to simplify the provider implementation.