Skip to content

Commit

Permalink
feat(key transaction): add error return check for d.Set function for …
Browse files Browse the repository at this point in the history
…lint verification
  • Loading branch information
vagrawal-newrelic committed Sep 25, 2024
1 parent 7ae266e commit 867880d
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions newrelic/resource_newrelic_key_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ func resourceNewRelicKeyTransactionRead(ctx context.Context, d *schema.ResourceD
switch (*resp).(type) {
case *entities.KeyTransactionEntity:
entity := (*resp).(*entities.KeyTransactionEntity)
d.Set("apdex_index", entity.ApdexTarget)
d.Set("application_guid", entity.Application.GUID)
d.Set("browser_apdex_target", entity.BrowserApdexTarget)
d.Set("metric_name", entity.MetricName)
d.Set("name", entity.Name)
_ = d.Set("apdex_index", entity.ApdexTarget)
_ = d.Set("application_guid", entity.Application.GUID)
_ = d.Set("browser_apdex_target", entity.BrowserApdexTarget)
_ = d.Set("metric_name", entity.MetricName)
_ = d.Set("name", entity.Name)
default:
return diag.FromErr(fmt.Errorf("entity with GUID %s was not a key transaction", guid))

Expand All @@ -98,12 +98,12 @@ func resourceNewRelicKeyTransactionRead(ctx context.Context, d *schema.ResourceD
func resourceNewRelickeyTransactionCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(*ProviderConfig).NewClient
apdexIndex := d.Get("apdex_index").(float64)
applicationGuid := d.Get("application_guid").(string)
applicationGUID := d.Get("application_guid").(string)
browserApdexTarget := d.Get("browser_apdex_target").(float64)
metricName := d.Get("metric_name").(string)
name := d.Get("name").(string)
log.Printf("[INFO] Creating New Relic Key Transaction %s", name)
createKeyTransactionResult, err := client.KeyTransaction.KeyTransactionCreate(apdexIndex, keytransaction.EntityGUID(applicationGuid), browserApdexTarget, metricName, name)
createKeyTransactionResult, err := client.KeyTransaction.KeyTransactionCreate(apdexIndex, keytransaction.EntityGUID(applicationGUID), browserApdexTarget, metricName, name)
if err != nil {
return diag.FromErr(err)
}
Expand All @@ -114,14 +114,14 @@ func resourceNewRelickeyTransactionCreate(ctx context.Context, d *schema.Resourc
}

d.SetId(string(createKeyTransactionResult.GUID))
d.Set("apdex_index", createKeyTransactionResult.ApdexTarget)
d.Set("application_guid", createKeyTransactionResult.Application.GUID)
d.Set("browser_apdex_target", createKeyTransactionResult.BrowserApdexTarget)
d.Set("metric_name", createKeyTransactionResult.MetricName)
d.Set("name", createKeyTransactionResult.Name)
_ = d.Set("apdex_index", createKeyTransactionResult.ApdexTarget)
_ = d.Set("application_guid", createKeyTransactionResult.Application.GUID)
_ = d.Set("browser_apdex_target", createKeyTransactionResult.BrowserApdexTarget)
_ = d.Set("metric_name", createKeyTransactionResult.MetricName)
_ = d.Set("name", createKeyTransactionResult.Name)
entity := createKeyTransactionResult.Application.Entity.(*keytransaction.ApmApplicationEntityOutline)
d.Set("domain", entity.Domain)
d.Set("type", entity.Type)
_ = d.Set("domain", entity.Domain)
_ = d.Set("type", entity.Type)

return nil

Expand All @@ -142,13 +142,13 @@ func resourceNewRelicKeyTransactionUpdate(ctx context.Context, d *schema.Resourc
return diag.FromErr(fmt.Errorf("something went wrong while updating the key transaction"))
}

d.Set("apdex_index", updateKeyTransactionResult.ApdexTarget)
d.Set("application_guid", updateKeyTransactionResult.Application.GUID)
d.Set("browser_apdex_target", updateKeyTransactionResult.BrowserApdexTarget)
d.Set("name", updateKeyTransactionResult.Name)
_ = d.Set("apdex_index", updateKeyTransactionResult.ApdexTarget)
_ = d.Set("application_guid", updateKeyTransactionResult.Application.GUID)
_ = d.Set("browser_apdex_target", updateKeyTransactionResult.BrowserApdexTarget)
_ = d.Set("name", updateKeyTransactionResult.Name)
entity := updateKeyTransactionResult.Application.Entity.(*keytransaction.ApmApplicationEntityOutline)
d.Set("domain", entity.Domain)
d.Set("type", entity.Type)
_ = d.Set("domain", entity.Domain)
_ = d.Set("type", entity.Type)

return nil
}
Expand Down

0 comments on commit 867880d

Please sign in to comment.