Skip to content

Commit

Permalink
Fix logic to create/delete/update sensitive variables
Browse files Browse the repository at this point in the history
  • Loading branch information
alfespa17 committed May 13, 2024
1 parent a2bb11d commit 6f3c81a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
10 changes: 4 additions & 6 deletions internal/provider/organization_variable_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ func (r *OrganizationVariableResource) Create(ctx context.Context, req resource.

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

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

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

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

plan.ID = types.StringValue(state.ID.ValueString())
plan.Key = types.StringValue(organizationVariable.Key)
b := *organizationVariable.Sensitive
if b == true {

if *organizationVariable.Sensitive {
tflog.Info(ctx, "Variable value is not included in response, setting values the same as the plan for sensitive=true...")
plan.Value = types.StringValue(plan.Value.ValueString())
} else {
Expand Down
9 changes: 3 additions & 6 deletions internal/provider/workspace_variable_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ func (r *WorkspaceVariableResource) Create(ctx context.Context, req resource.Cre

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

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

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

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

b := workspaceVariable.Sensitive
if b == true {
if workspaceVariable.Sensitive {
tflog.Info(ctx, "Variable value is not included in response, setting values the same as the plan for sensitive=true...")
plan.Value = types.StringValue(plan.Value.ValueString())
} else {
Expand Down

0 comments on commit 6f3c81a

Please sign in to comment.