Skip to content

Commit b60fb6c

Browse files
Merge branch 'main' into feat/STACKITTPR-388_store_ids_opensearch
2 parents bcbdd65 + cf68327 commit b60fb6c

4 files changed

Lines changed: 25 additions & 14 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ require (
5454
github.com/ProtonMail/go-crypto v1.1.6 // indirect
5555
github.com/agext/levenshtein v1.2.2 // indirect
5656
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
57-
github.com/cloudflare/circl v1.6.1 // indirect
57+
github.com/cloudflare/circl v1.6.3 // indirect
5858
github.com/fatih/color v1.18.0 // indirect
5959
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
6060
github.com/golang/protobuf v1.5.4 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew
1111
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
1212
github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw=
1313
github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c=
14-
github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
15-
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
14+
github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg8=
15+
github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4=
1616
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
1717
github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s=
1818
github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=

stackit/internal/services/secretsmanager/instance/resource.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
2020
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
2121

22-
"github.com/hashicorp/terraform-plugin-framework/path"
2322
"github.com/hashicorp/terraform-plugin-framework/resource"
2423
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
2524
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
@@ -180,8 +179,15 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
180179

181180
ctx = core.LogResponse(ctx)
182181

182+
if createResp.Id == nil {
183+
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", "Got empty instance id")
184+
return
185+
}
183186
instanceId := *createResp.Id
184-
ctx = tflog.SetField(ctx, "instance_id", instanceId)
187+
ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{
188+
"project_id": projectId,
189+
"instance_id": instanceId,
190+
})
185191

186192
// Create ACLs
187193
err = updateACLs(ctx, projectId, instanceId, acls, r.client)
@@ -364,9 +370,10 @@ func (r *instanceResource) ImportState(ctx context.Context, req resource.ImportS
364370
)
365371
return
366372
}
367-
368-
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
369-
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[1])...)
373+
ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{
374+
"project_id": idParts[0],
375+
"instance_id": idParts[1],
376+
})
370377
tflog.Info(ctx, "Secrets Manager instance state imported")
371378
}
372379

stackit/internal/services/secretsmanager/user/resource.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
1717
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
1818

19-
"github.com/hashicorp/terraform-plugin-framework/path"
2019
"github.com/hashicorp/terraform-plugin-framework/resource"
2120
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
2221
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
@@ -191,7 +190,11 @@ func (r *userResource) Create(ctx context.Context, req resource.CreateRequest, r
191190
return
192191
}
193192
userId := *userResp.Id
194-
ctx = tflog.SetField(ctx, "user_id", userId)
193+
ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{
194+
"project_id": projectId,
195+
"instance_id": instanceId,
196+
"user_id": userId,
197+
})
195198

196199
// Map response body to schema
197200
err = mapFields(userResp, &model)
@@ -354,10 +357,11 @@ func (r *userResource) ImportState(ctx context.Context, req resource.ImportState
354357
)
355358
return
356359
}
357-
358-
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
359-
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[1])...)
360-
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("user_id"), idParts[2])...)
360+
ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{
361+
"project_id": idParts[0],
362+
"instance_id": idParts[1],
363+
"user_id": idParts[2],
364+
})
361365
core.LogAndAddWarning(ctx, &resp.Diagnostics,
362366
"Secrets Manager user imported with empty password",
363367
"The user password is not imported as it is only available upon creation of a new user. The password field will be empty.",

0 commit comments

Comments
 (0)