Skip to content

Commit e8ac5c9

Browse files
committed
fix: use bool pointer type for 'locked' attribute, to allow for explicitly setting it to false
Signed-off-by: Achim Christ <achim.christ@sva.de>
1 parent 1658e7e commit e8ac5c9

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

internal/interfaces/security_account.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type SecurityAccountResourceBodyDataModelONTAP struct {
1717
Role SecurityAccountRole `mapstructure:"role,omitempty"`
1818
Password string `mapstructure:"password,omitempty"`
1919
Comment string `mapstructure:"comment,omitempty"`
20-
Locked bool `mapstructure:"locked,omitempty"`
20+
Locked *bool `mapstructure:"locked,omitempty"`
2121
}
2222

2323
// SecurityAccountGetDataModelONTAP describes the GET record data model using go types for mapping.
@@ -38,7 +38,7 @@ type SecurityAccountResourceUpdateBodyDataModelONTAP struct {
3838
Role SecurityAccountRole `mapstructure:"role,omitempty"`
3939
Password string `mapstructure:"password,omitempty"`
4040
Comment string `mapstructure:"comment,omitempty"`
41-
Locked bool `mapstructure:"locked,omitempty"`
41+
Locked *bool `mapstructure:"locked,omitempty"`
4242
}
4343

4444
// SecurityAccountApplication describes the application data model using go types for mapping.

internal/provider/security/security_account_resource.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99
"github.com/hashicorp/terraform-plugin-framework/path"
1010
"github.com/hashicorp/terraform-plugin-framework/resource"
1111
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
12-
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
13-
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
1412
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
1513
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
1614
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
@@ -166,8 +164,6 @@ func (r *SecurityAccountResource) Schema(ctx context.Context, req resource.Schem
166164
MarkdownDescription: "Account locked",
167165
Optional: true,
168166
Computed: true,
169-
Default: booldefault.StaticBool(false),
170-
PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()},
171167
},
172168
"id": schema.StringAttribute{
173169
MarkdownDescription: "SecurityAccount id",
@@ -346,7 +342,7 @@ func (r *SecurityAccountResource) Create(ctx context.Context, req resource.Creat
346342
body.Comment = data.Comment.ValueString()
347343
}
348344
if !data.Locked.IsNull() {
349-
body.Locked = data.Locked.ValueBool()
345+
body.Locked = data.Locked.ValueBoolPointer()
350346
}
351347

352348
client, err := connection.GetRestClient(errorHandler, r.config, data.CxProfileName)
@@ -410,6 +406,7 @@ func (r *SecurityAccountResource) Create(ctx context.Context, req resource.Creat
410406

411407
data.ID = types.StringValue(resource.Name)
412408
data.OwnerID = types.StringValue(resource.Owner.UUID)
409+
data.Locked = types.BoolValue(resource.Locked)
413410

414411
tflog.Trace(ctx, "created a resource")
415412

@@ -472,7 +469,7 @@ func (r *SecurityAccountResource) Update(ctx context.Context, req resource.Updat
472469

473470
// locked update
474471
if !plan.Locked.IsNull() {
475-
request.Locked = plan.Locked.ValueBool()
472+
request.Locked = plan.Locked.ValueBoolPointer()
476473
}
477474

478475
// comment update

0 commit comments

Comments
 (0)