fix: fix linting errors and test
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 6s
CI Workflow / Test readiness for publishing provider (pull_request) Failing after 14s
CI Workflow / CI run build and linting (pull_request) Failing after 23s
CI Workflow / Code coverage report (pull_request) Has been skipped
CI Workflow / CI run tests (pull_request) Failing after 6m9s

This commit is contained in:
Marcel S. Henselin 2026-03-02 09:45:31 +01:00
parent c15f21a16d
commit 55427f7a48
3 changed files with 36 additions and 31 deletions

View file

@ -1,4 +1,3 @@
version: "2" version: "2"
run: run:
concurrency: 4 concurrency: 4

View file

@ -76,21 +76,21 @@ func testAccPreCheck(t *testing.T) {
type resData struct { type resData struct {
ServiceAccountFilePath string ServiceAccountFilePath string
ProjectId string ProjectID string
Region string Region string
Name string Name string
TfName string TfName string
FlavorId string FlavorID string
BackupSchedule string BackupSchedule string
UseEncryption bool UseEncryption bool
KekKeyId string KekKeyID string
KekKeyRingId string KekKeyRingID string
KekKeyVersion uint8 KekKeyVersion uint8
KekServiceAccount string KekServiceAccount string
PerformanceClass string PerformanceClass string
Replicas uint32 Replicas uint32
Size uint32 Size uint32
AclString string ACLString string
AccessScope string AccessScope string
RetentionDays uint32 RetentionDays uint32
Version string Version string
@ -100,13 +100,13 @@ type resData struct {
type User struct { type User struct {
Name string Name string
ProjectId string ProjectID string
Roles []string Roles []string
} }
type Database struct { type Database struct {
Name string Name string
ProjectId string ProjectID string
Owner string Owner string
} }
@ -115,17 +115,17 @@ func getExample() resData {
return resData{ return resData{
Region: os.Getenv("TF_ACC_REGION"), Region: os.Getenv("TF_ACC_REGION"),
ServiceAccountFilePath: os.Getenv("TF_ACC_SERVICE_ACCOUNT_FILE"), ServiceAccountFilePath: os.Getenv("TF_ACC_SERVICE_ACCOUNT_FILE"),
ProjectId: os.Getenv("TF_ACC_PROJECT_ID"), ProjectID: os.Getenv("TF_ACC_PROJECT_ID"),
Name: name, Name: name,
TfName: name, TfName: name,
FlavorId: "2.4", FlavorID: "2.4",
BackupSchedule: "0 0 * * *", BackupSchedule: "0 0 * * *",
UseEncryption: false, UseEncryption: false,
RetentionDays: 33, RetentionDays: 33,
Replicas: 1, Replicas: 1,
PerformanceClass: "premium-perf2-stackit", PerformanceClass: "premium-perf2-stackit",
Size: 10, Size: 10,
AclString: "0.0.0.0/0", ACLString: "0.0.0.0/0",
AccessScope: "PUBLIC", AccessScope: "PUBLIC",
Version: "17", Version: "17",
} }
@ -162,7 +162,8 @@ func TestAccInstance(t *testing.T) {
} }
*/ */
var testItemID string testItemID := testutils.ResStr(pfx, "instance", exData.TfName)
resource.ParallelTest( resource.ParallelTest(
t, resource.TestCase{ t, resource.TestCase{
PreCheck: func() { PreCheck: func() {
@ -174,9 +175,9 @@ func TestAccInstance(t *testing.T) {
Steps: []resource.TestStep{ Steps: []resource.TestStep{
// Create and verify // Create and verify
{ {
PreConfig: func() { //PreConfig: func() {
testItemID = testutils.ResStr(pfx, "instance", exData.TfName) // //
}, //},
Config: testutils.StringFromTemplateMust( Config: testutils.StringFromTemplateMust(
"testdata/instance_template.gompl", "testdata/instance_template.gompl",
exData, exData,
@ -249,7 +250,7 @@ func TestAccInstanceWithUsers(t *testing.T) {
data.Users = []User{ data.Users = []User{
{ {
Name: userName, Name: userName,
ProjectId: os.Getenv("TF_ACC_PROJECT_ID"), ProjectID: os.Getenv("TF_ACC_PROJECT_ID"),
Roles: []string{"login"}, Roles: []string{"login"},
}, },
} }
@ -293,7 +294,7 @@ func TestAccInstanceWithDatabases(t *testing.T) {
data.Users = []User{ data.Users = []User{
{ {
Name: userName, Name: userName,
ProjectId: os.Getenv("TF_ACC_PROJECT_ID"), ProjectID: os.Getenv("TF_ACC_PROJECT_ID"),
Roles: []string{"login"}, Roles: []string{"login"},
}, },
} }
@ -301,7 +302,7 @@ func TestAccInstanceWithDatabases(t *testing.T) {
data.Databases = []Database{ data.Databases = []Database{
{ {
Name: dbName, Name: dbName,
ProjectId: os.Getenv("TF_ACC_PROJECT_ID"), ProjectID: os.Getenv("TF_ACC_PROJECT_ID"),
Owner: userName, Owner: userName,
}, },
} }
@ -996,18 +997,23 @@ func TestAccInstanceWithDatabases(t *testing.T) {
func testAccCheckPostgresFlexDestroy(s *terraform.State) error { func testAccCheckPostgresFlexDestroy(s *terraform.State) error {
testutils.Setup() testutils.Setup()
pID, ok := os.LookupEnv("TF_ACC_PROJECT_ID")
if !ok {
log.Fatalln("unable to read TF_ACC_PROJECT_ID")
}
ctx := context.Background() ctx := context.Background()
var client *postgresflexalphaPkgGen.APIClient var client *postgresflexalphaPkgGen.APIClient
var err error var err error
var region, projectId string var region, projectID string
region = testutils.Region region = testutils.Region
if region == "" { if region == "" {
region = "eu01" region = "eu01"
} }
projectId = testutils.ProjectId projectID = pID
if projectId == "" { if projectID == "" {
return fmt.Errorf("projectID could not be determined in destroy function") return fmt.Errorf("projectID could not be determined in destroy function")
} }
@ -1034,11 +1040,11 @@ func testAccCheckPostgresFlexDestroy(s *terraform.State) error {
} }
// instance terraform ID: = "[project_id],[region],[instance_id]" // instance terraform ID: = "[project_id],[region],[instance_id]"
instanceId := strings.Split(rs.Primary.ID, core.Separator)[2] instanceID := strings.Split(rs.Primary.ID, core.Separator)[2]
instancesToDestroy = append(instancesToDestroy, instanceId) instancesToDestroy = append(instancesToDestroy, instanceID)
} }
instancesResp, err := client.ListInstancesRequest(ctx, projectId, region). instancesResp, err := client.ListInstancesRequest(ctx, projectID, region).
Size(100). Size(100).
Execute() Execute()
if err != nil { if err != nil {

View file

@ -4,11 +4,11 @@ provider "stackitprivatepreview" {
} }
resource "stackitprivatepreview_postgresflexalpha_instance" "{{ .TfName }}" { resource "stackitprivatepreview_postgresflexalpha_instance" "{{ .TfName }}" {
project_id = "{{ .ProjectId }}" project_id = "{{ .ProjectID }}"
name = "{{ .Name }}" name = "{{ .Name }}"
backup_schedule = "{{ .BackupSchedule }}" backup_schedule = "{{ .BackupSchedule }}"
retention_days = {{ .RetentionDays }} retention_days = {{ .RetentionDays }}
flavor_id = "{{ .FlavorId }}" flavor_id = "{{ .FlavorID }}"
replicas = {{ .Replicas }} replicas = {{ .Replicas }}
storage = { storage = {
performance_class = "{{ .PerformanceClass }}" performance_class = "{{ .PerformanceClass }}"
@ -16,14 +16,14 @@ resource "stackitprivatepreview_postgresflexalpha_instance" "{{ .TfName }}" {
} }
{{ if .UseEncryption }} {{ if .UseEncryption }}
encryption = { encryption = {
kek_key_id = {{ .KekKeyId }} kek_key_id = {{ .KekKeyID }}
kek_key_ring_id = {{ .KekKeyRingId }} kek_key_ring_id = {{ .KekKeyRingID }}
kek_key_version = {{ .KekKeyVersion }} kek_key_version = {{ .KekKeyVersion }}
service_account = "{{ .KekServiceAccount }}" service_account = "{{ .KekServiceAccount }}"
} }
{{ end }} {{ end }}
network = { network = {
acl = ["{{ .AclString }}"] acl = ["{{ .ACLString }}"]
access_scope = "{{ .AccessScope }}" access_scope = "{{ .AccessScope }}"
} }
version = {{ .Version }} version = {{ .Version }}
@ -33,7 +33,7 @@ resource "stackitprivatepreview_postgresflexalpha_instance" "{{ .TfName }}" {
{{ $tfName := .TfName }} {{ $tfName := .TfName }}
{{ range $user := .Users }} {{ range $user := .Users }}
resource "stackitprivatepreview_postgresflexalpha_user" "{{ $user.Name }}" { resource "stackitprivatepreview_postgresflexalpha_user" "{{ $user.Name }}" {
project_id = "{{ $user.ProjectId }}" project_id = "{{ $user.ProjectID }}"
instance_id = stackitprivatepreview_postgresflexalpha_instance.{{ $tfName }}.instance_id instance_id = stackitprivatepreview_postgresflexalpha_instance.{{ $tfName }}.instance_id
name = "{{ $user.Name }}" name = "{{ $user.Name }}"
roles = [{{ range $i, $v := $user.Roles }}{{if $i}},{{end}}"{{$v}}"{{end}}] roles = [{{ range $i, $v := $user.Roles }}{{if $i}},{{end}}"{{$v}}"{{end}}]
@ -45,7 +45,7 @@ resource "stackitprivatepreview_postgresflexalpha_user" "{{ $user.Name }}" {
{{ $tfName := .TfName }} {{ $tfName := .TfName }}
{{ range $db := .Databases }} {{ range $db := .Databases }}
resource "stackitprivatepreview_postgresflexalpha_database" "{{ $db.Name }}" { resource "stackitprivatepreview_postgresflexalpha_database" "{{ $db.Name }}" {
project_id = "{{ $db.ProjectId }}" project_id = "{{ $db.ProjectID }}"
instance_id = stackitprivatepreview_postgresflexalpha_instance.{{ $tfName }}.instance_id instance_id = stackitprivatepreview_postgresflexalpha_instance.{{ $tfName }}.instance_id
name = "{{ $db.Name }}" name = "{{ $db.Name }}"
owner = stackitprivatepreview_postgresflexalpha_user.{{ $db.Owner }}.name owner = stackitprivatepreview_postgresflexalpha_user.{{ $db.Owner }}.name