Skip to content

Commit

Permalink
Fix for frontegg_tenant deserialization when upstream tenant metadata…
Browse files Browse the repository at this point in the history
… keys contian non-string values (#125)
  • Loading branch information
rjobanp authored Nov 21, 2023
1 parent 2dbbc3c commit 3c741f1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions provider/resource_frontegg_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,18 @@ func resourceFronteggTenantDeserialize(d *schema.ResourceData, f fronteggTenant)
func resourceFronteggTenantMetadataDeserialize(d *schema.ResourceData, metadata string) error {
// We only manage keys that are explicitly selected.
selectedMetadata := castResourceStringMap(d.Get("selected_metadata"))
var allUpstreamMetadata map[string]string
var allUpstreamMetadata map[string]interface{}
if err := json.Unmarshal([]byte(metadata), &allUpstreamMetadata); err != nil {
return err
}
for key := range selectedMetadata {
if newValue, ok := allUpstreamMetadata[key]; ok {
selectedMetadata[key] = newValue
// All metadata keys managed by this provider must use string values
// so ignore the upstream value if it is not a string
newValueString, ok := newValue.(string)
if ok {
selectedMetadata[key] = newValueString
}
} else {
delete(selectedMetadata, key)
}
Expand Down

0 comments on commit 3c741f1

Please sign in to comment.