Skip to content

Commit

Permalink
fix: set secret refs always if no value is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
delca85 committed May 16, 2024
1 parent 490929b commit b8880d0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions internal/provider/resource_definition_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"strings"
"time"

"github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts"
Expand Down Expand Up @@ -255,15 +256,17 @@ func parseResourceDefinitionResponse(ctx context.Context, driverInputSchema map[
data.DriverInputs.ValuesString = types.StringValue(string(b))
}

if data.DriverInputs != nil && data.DriverInputs.SecretRefs.IsUnknown() {
if data.DriverInputs != nil {
if driverInputs.SecretRefs == nil {
data.DriverInputs.SecretRefs = types.StringNull()
} else {
b, err := json.Marshal(driverInputs.SecretRefs)
if err != nil {
diags.AddError(HUM_API_ERR, fmt.Sprintf("Failed to marshal secret_refs: %s", err.Error()))
if !strings.Contains(data.DriverInputs.SecretRefs.ValueString(), `{"value":"`) {
b, err := json.Marshal(driverInputs.SecretRefs)
if err != nil {
diags.AddError(HUM_API_ERR, fmt.Sprintf("Failed to marshal secret_refs: %s", err.Error()))
}
data.DriverInputs.SecretRefs = types.StringValue(string(b))
}
data.DriverInputs.SecretRefs = types.StringValue(string(b))
}
}
return diags
Expand Down

0 comments on commit b8880d0

Please sign in to comment.