Skip to content

Commit 6f3c81a

Browse files
committed
Fix logic to create/delete/update sensitive variables
1 parent a2bb11d commit 6f3c81a

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

internal/provider/organization_variable_resource.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ func (r *OrganizationVariableResource) Create(ctx context.Context, req resource.
180180

181181
tflog.Info(ctx, "Body Response", map[string]any{"bodyResponse": string(bodyResponse)})
182182

183-
b := *organizationVariable.Sensitive
184-
if b == true {
183+
if *organizationVariable.Sensitive {
185184
tflog.Info(ctx, "Variable value is not included in response, setting values the same as the plan for sensitive=true...")
186185
plan.Value = types.StringValue(plan.Value.ValueString())
187186
} else {
@@ -239,8 +238,7 @@ func (r *OrganizationVariableResource) Read(ctx context.Context, req resource.Re
239238

240239
tflog.Info(ctx, "Body Response", map[string]any{"bodyResponse": string(bodyResponse)})
241240

242-
b := *organizationVariable.Sensitive
243-
if b == true {
241+
if *organizationVariable.Sensitive {
244242
tflog.Info(ctx, "Variable value is not included in response, setting values the same as the current state value")
245243
state.Value = types.StringValue(state.Value.ValueString())
246244
} else {
@@ -346,8 +344,8 @@ func (r *OrganizationVariableResource) Update(ctx context.Context, req resource.
346344

347345
plan.ID = types.StringValue(state.ID.ValueString())
348346
plan.Key = types.StringValue(organizationVariable.Key)
349-
b := *organizationVariable.Sensitive
350-
if b == true {
347+
348+
if *organizationVariable.Sensitive {
351349
tflog.Info(ctx, "Variable value is not included in response, setting values the same as the plan for sensitive=true...")
352350
plan.Value = types.StringValue(plan.Value.ValueString())
353351
} else {

internal/provider/workspace_variable_resource.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ func (r *WorkspaceVariableResource) Create(ctx context.Context, req resource.Cre
184184

185185
tflog.Info(ctx, "Body Response", map[string]any{"bodyResponse": string(bodyResponse)})
186186

187-
b := workspaceVariable.Sensitive
188-
if b == true {
187+
if workspaceVariable.Sensitive {
189188
tflog.Info(ctx, "Variable value is not included in response, setting values the same as the plan for sensitive=true...")
190189
plan.Value = types.StringValue(plan.Value.ValueString())
191190
} else {
@@ -243,8 +242,7 @@ func (r *WorkspaceVariableResource) Read(ctx context.Context, req resource.ReadR
243242

244243
tflog.Info(ctx, "Body Response", map[string]any{"bodyResponse": string(bodyResponse)})
245244

246-
b := workspaceVariable.Sensitive
247-
if b == true {
245+
if workspaceVariable.Sensitive {
248246
tflog.Info(ctx, "Variable value is not included in response, setting values the same as the current state value")
249247
state.Value = types.StringValue(state.Value.ValueString())
250248
} else {
@@ -347,8 +345,7 @@ func (r *WorkspaceVariableResource) Update(ctx context.Context, req resource.Upd
347345
return
348346
}
349347

350-
b := workspaceVariable.Sensitive
351-
if b == true {
348+
if workspaceVariable.Sensitive {
352349
tflog.Info(ctx, "Variable value is not included in response, setting values the same as the plan for sensitive=true...")
353350
plan.Value = types.StringValue(plan.Value.ValueString())
354351
} else {

0 commit comments

Comments
 (0)