Skip to content

Commit

Permalink
Update account_parameter.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard-Barrett authored Oct 1, 2024
1 parent ad5fa11 commit c714f01
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pkg/resources/account_parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,28 @@ func DeleteAccountParameter(d *schema.ResourceData, meta interface{}) error {
client := meta.(*provider.Context).Client
key := d.Get("key").(string)
ctx := context.Background()

// Identify the parameter
parameter := sdk.AccountParameter(key)
defaultParameter, err := client.Parameters.ShowAccountParameter(ctx, sdk.AccountParameter(key))

// Retrieve the current default value for the parameter
defaultParameter, err := client.Parameters.ShowAccountParameter(ctx, parameter)
if err != nil {
return err
return fmt.Errorf("error retrieving default value for account parameter %s: %w", key, err)
}

defaultValue := defaultParameter.Default
if defaultValue == "" {
return fmt.Errorf("no default value found for account parameter %s", key)
}

// Reset the account parameter to its default value
err = client.Parameters.SetAccountParameter(ctx, parameter, defaultValue)
if err != nil {
return fmt.Errorf("error resetting account parameter err = %w", err)
return fmt.Errorf("error resetting account parameter %s: %w", key, err)
}

// Successfully reset the parameter, clear the ID
d.SetId("")
return nil
}

0 comments on commit c714f01

Please sign in to comment.