Skip to content

Commit

Permalink
fix typing error
Browse files Browse the repository at this point in the history
needs to be a string otherwise it causes a panic for nil.
  • Loading branch information
jacobbednarz committed Sep 20, 2023
1 parent b051547 commit 077c387
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ func resourceCloudflareAccessIdentityProviderRead(ctx context.Context, d *schema
return diag.FromErr(fmt.Errorf("error setting Access Identity Provider configuration: %w", configErr))
}

// We need to get the current secret and set that in the state as it is only returned initially when the resource
// was created. The value read from the server will always be redacted.
scimConfig := convertAccessIDPScimConfigStructToSchema(d.Get("scim_config.0.secret"), accessIdentityProvider.ScimConfig)
// We need to get the current secret and set that in the state as it is only
// returned initially when the resource was created. The value read from the
// server will always be redacted.
scimConfig := convertAccessIDPScimConfigStructToSchema(d.Get("scim_config.0.secret").(string), accessIdentityProvider.ScimConfig)
if scimConfigErr := d.Set("scim_config", scimConfig); scimConfigErr != nil {
return diag.FromErr(fmt.Errorf("error setting Access Identity Provider scim configuration: %w", scimConfigErr))
}
Expand Down Expand Up @@ -143,7 +144,7 @@ func resourceCloudflareAccessIdentityProviderUpdate(ctx context.Context, d *sche
return diag.FromErr(fmt.Errorf("failed to find Access Identity Provider ID in update response; resource was empty"))
}

scimSecret := d.Get("scim_config.0.secret")
scimSecret := d.Get("scim_config.0.secret").(string)
checkRedactedRegex := regexp.MustCompile(`^\*+$`)
if accessIdentityProvider.ScimConfig.Secret != "" && !checkRedactedRegex.MatchString(accessIdentityProvider.ScimConfig.Secret) {
scimSecret = accessIdentityProvider.ScimConfig.Secret
Expand Down Expand Up @@ -306,7 +307,7 @@ func convertAccessIDPConfigStructToSchema(options cloudflare.AccessIdentityProvi
return []interface{}{m}
}

func convertAccessIDPScimConfigStructToSchema(secret interface{}, options cloudflare.AccessIdentityProviderScimConfiguration) []interface{} {
func convertAccessIDPScimConfigStructToSchema(secret string, options cloudflare.AccessIdentityProviderScimConfiguration) []interface{} {
m := map[string]interface{}{
"enabled": options.Enabled,
"secret": secret,
Expand Down

0 comments on commit 077c387

Please sign in to comment.