-
Notifications
You must be signed in to change notification settings - Fork 666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: CBR regenerate provider #5724
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial feedback.
} | ||
|
||
d.SetId(fmt.Sprintf("%s", *getRuleOptions.RuleID)) | ||
|
||
if err = d.Set("crn", rule.CRN); err != nil { | ||
return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) | ||
return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting crn: %s", err), "(Data) ibm_cbr_rule", "read", "set-crn").GetDiag() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not log the debug message for this error? What determines when a debug message is logged vs when it is not?
This comment/question applies to everywhere you construct a TerraformProblem
and had to decide whether or not to log the value of GetDebugMessage()
.
} | ||
|
||
var zone *contextbasedrestrictionsv1.Zone | ||
var found bool | ||
zone, _, found, err = getZone(contextBasedRestrictionsClient, context, zoneId) | ||
if err != nil { | ||
return diag.FromErr(err) | ||
tfErr := flex.TerraformErrorf(err, fmt.Sprintf("getZone failed: %s", err.Error()), "(Data) ibm_cbr_zone_addresses", "read") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels wrong to include the local function (getZone
) in the error message.
@@ -152,7 +153,9 @@ func resourceIBMCbrZoneAddressesCreate(context context.Context, d *schema.Resour | |||
addressesId := fmt.Sprintf("TF-%s", newUuid) | |||
err := resourceReplaceZoneAddresses(context, d, meta, zoneId, addressesId, false) | |||
if err != nil { | |||
return diag.FromErr(err) | |||
tfErr := flex.TerraformErrorf(err, fmt.Sprintf(" resourceReplaceZoneAddresses failed: %s", err.Error()), "ibm_cbr_zone_addresses", "create") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels wrong to include the local function (resourceReplaceZoneAddresses
) in the error message.
@@ -171,29 +176,31 @@ func resourceIBMCbrZoneAddressesRead(context context.Context, d *schema.Resource | |||
var found bool | |||
zone, _, found, err = getZone(contextBasedRestrictionsClient, context, zoneId) | |||
if err != nil { | |||
return diag.FromErr(err) | |||
tfErr := flex.TerraformErrorf(err, fmt.Sprintf("getZone failed: %s", err.Error()), "ibm_cbr_zone_addresses", "read") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels wrong to include the local function (getZone
) in the error message.
@@ -203,7 +210,9 @@ func resourceIBMCbrZoneAddressesUpdate(context context.Context, d *schema.Resour | |||
zoneId, addressesId := decomposeZoneAddressesId(d.Id()) | |||
err := resourceReplaceZoneAddresses(context, d, meta, zoneId, addressesId, false) | |||
if err != nil { | |||
return diag.FromErr(err) | |||
tfErr := flex.TerraformErrorf(err, fmt.Sprintf("resourceReplaceZoneAddresses failed: %s", err.Error()), "ibm_cbr_zone_addresses", "update") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels wrong to include the local function (resourceReplaceZoneAddresses
) in the error message.
} | ||
contexts = append(contexts, *contextsItem) | ||
} | ||
replaceRuleOptions.SetContexts(contexts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for this change? The API won't accept a zone create with missing contexts. The previous code ensured that it is present (and empty) if no contexts are specified.
} | ||
|
||
zone, response, found, err := getZone(contextBasedRestrictionsClient, context, d.Id()) | ||
if err != nil { | ||
return diag.FromErr(err) | ||
tfErr := flex.TerraformErrorf(err, fmt.Sprintf("getZone failed: %s", err.Error()), "ibm_cbr_zone", "read") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels wrong to include the local function (getZone
) in the error message.
@@ -412,7 +364,9 @@ func resourceIBMCbrZoneUpdate(context context.Context, d *schema.ResourceData, m | |||
|
|||
currentZone, response, found, err := getZone(contextBasedRestrictionsClient, context, zoneId) | |||
if err != nil { | |||
return diag.FromErr(err) | |||
tfErr := flex.TerraformErrorf(err, fmt.Sprintf("getZone failed: %s", err.Error()), "ibm_cbr_zone", "update") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels wrong to include the local function (getZone
) in the error message.
} | ||
|
||
if err := ResourceIBMCbrZoneSetData(zone, response, d); err != nil { | ||
return diag.FromErr(fmt.Errorf("Error setting zone's resource data: %s", err)) | ||
return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_cbr_zone", "read", "ResourceIBMCbrZoneSetData").GetDiag() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be "update"
if err = d.Set("etag", response.Headers.Get("Etag")); err != nil { | ||
return fmt.Errorf("Error setting etag: %s", err) | ||
} | ||
if err = d.Set("etag", response.Headers.Get("Etag")); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"etag" is set twice here
Per request from https://ibm-cloudplatform.slack.com/archives/C05CL2TVBC6/p1712696668957339
Acceptance Tests: