Skip to content

Commit

Permalink
Merge pull request #1439 from newrelic/jthurman/update-nr-client
Browse files Browse the repository at this point in the history
Update newrelic-client-go v0.63.0
  • Loading branch information
Jonathan Thurman authored Sep 21, 2021
2 parents 54b36fb + 517b2c8 commit 6ca4df1
Show file tree
Hide file tree
Showing 65 changed files with 143 additions and 82 deletions.
5 changes: 1 addition & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ linters-settings:
errcheck:
ignoretests: true
ignore: github.com/hashicorp/terraform-plugin-sdk/helper/schema:ForceNew|Set,github.com/hashicorp/terraform-plugin-sdk/helper/schema:Set,github.com/newrelic/terraform-provider-newrelic/newrelic:Set,io:Close|Write
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.5
gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 20
Expand All @@ -34,11 +31,11 @@ linters:
- errcheck
- gocyclo
- gofmt
- golint
- gosimple
- govet
- ineffassign
- misspell
- revive
- staticcheck
- structcheck
- unconvert
Expand Down
6 changes: 3 additions & 3 deletions build/compile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ compile-all: deps-only
compile-only: deps-only
@echo "=== $(PROJECT_NAME) === [ compile ]: building commands:"
@mkdir -p $(BUILD_DIR)/$(GOOS)
echo "=== $(PROJECT_NAME) === [ compile ]: $(BUILD_DIR)$(GOOS)/$(BINARY)"; \
BUILD_FILES=`find $(SRCDIR)/newrelic -type f -name "*.go"` ; \
GOOS=$(GOOS) $(GO) build -ldflags=$(LDFLAGS) -o $(BUILD_DIR)/$(GOOS)/$(BINARY) $$BUILD_FILES ; \
@echo "=== $(PROJECT_NAME) === [ compile ]: $(BUILD_DIR)$(GOOS)/$(BINARY)"
@BUILD_FILES=`find $(SRCDIR)/newrelic -type f -name "*.go"` ; \
GOOS=$(GOOS) $(GO) build -ldflags=$(LDFLAGS) -o $(BUILD_DIR)/$(GOOS)/$(BINARY) $$BUILD_FILES ; \

# Override GOOS for these specific targets
compile-darwin: GOOS=darwin
Expand Down
2 changes: 2 additions & 0 deletions build/document.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ GODOC_HTTP ?= "localhost:6060"
CHANGELOG_CMD ?= git-chglog
CHANGELOG_FILE ?= CHANGELOG.md
RELEASE_NOTES_FILE ?= relnotes.md
MISSPELL ?= misspell

changelog: tools
@echo "=== $(PROJECT_NAME) === [ changelog ]: Generating changelog..."
Expand All @@ -26,5 +27,6 @@ release-notes: tools
@echo "=== $(PROJECT_NAME) === [ release-notes ]: Generating release notes..."
@mkdir -p $(SRCDIR)/tmp
@$(CHANGELOG_CMD) --silent -o $(SRCDIR)/tmp/$(RELEASE_NOTES_FILE) v$(PROJECT_VER_TAGGED)
@$(MISSPELL) -source text -w $(SRCDIR)/tmp/$(RELEASE_NOTES_FILE)

.PHONY: docs changelog release-notes
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/newrelic/go-agent/v3 v3.15.0
github.com/newrelic/go-insights v1.0.3
github.com/newrelic/newrelic-client-go v0.62.1
github.com/newrelic/newrelic-client-go v0.63.0
github.com/stretchr/testify v1.7.0
golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb // indirect
google.golang.org/api v0.34.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZX
github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag=
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.4.2 h1:6h7AQ0yhTcIsmFmnAwQls75jp2Gzs4iB8W7pjMO+rqo=
github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
Expand All @@ -388,8 +388,8 @@ github.com/newrelic/go-agent/v3 v3.15.0 h1:XKF81YOkkO5cCEtQmguamOVMVmeWnv7X3+mkR
github.com/newrelic/go-agent/v3 v3.15.0/go.mod h1:1A1dssWBwzB7UemzRU6ZVaGDsI+cEn5/bNxI0wiYlIc=
github.com/newrelic/go-insights v1.0.3 h1:zSNp1CEZnXktzSIEsbHJk8v6ZihdPFP2WsO/fzau3OQ=
github.com/newrelic/go-insights v1.0.3/go.mod h1:A20BoT8TNkqPGX2nS/Z2fYmKl3Cqa3iKZd4whzedCY4=
github.com/newrelic/newrelic-client-go v0.62.1 h1:3EtnALMolln8G2EdDWx2TUYgh8VqAGJmoqFE46rBoeE=
github.com/newrelic/newrelic-client-go v0.62.1/go.mod h1:rJrNRX5HzgCnxJm2Hcn6IXmN1KCP/ppmvwkUbnm2Kto=
github.com/newrelic/newrelic-client-go v0.63.0 h1:FqM9GPLYeSah9m3iU4oe5Obm8Ty/EN+G4XaNlcrqU8o=
github.com/newrelic/newrelic-client-go v0.63.0/go.mod h1:VXjhsfui0rvhM9cVwnKwlidF8NbXlHZvh63ZKi6fImA=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758=
github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4v2r9jz+c9i1IfIttS/OkmLfrk1jne5hs=
Expand Down
1 change: 1 addition & 0 deletions newrelic/data_source_newrelic_account_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/data_source_newrelic_alert_channel_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/data_source_newrelic_alert_policy_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/data_source_newrelic_application_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/data_source_newrelic_entity_integration_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/data_source_newrelic_entity_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build unit
// +build unit

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/data_source_newrelic_key_transaction_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/data_source_newrelic_synthetics_monitor_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
2 changes: 2 additions & 0 deletions newrelic/helpers_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//go:build integration || unit
// +build integration unit

//
// Test Helpers
//
Expand Down
1 change: 1 addition & 0 deletions newrelic/helpers_unit_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build unit
// +build unit

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/import_resource_newrelic_api_access_key_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/provider_integration_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
2 changes: 2 additions & 0 deletions newrelic/provider_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//go:build integration || unit
// +build integration unit

//
// Test helpers
//
Expand Down
1 change: 1 addition & 0 deletions newrelic/provider_unit_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build unit
// +build unit

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/resource_newrelic_alert_channel_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
2 changes: 2 additions & 0 deletions newrelic/resource_newrelic_alert_condition_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//go:build integration || unit
// +build integration unit

//
// Test helpers
//
Expand Down
1 change: 1 addition & 0 deletions newrelic/resource_newrelic_alert_condition_unit_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build unit
// +build unit

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/resource_newrelic_alert_muting_rule_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/resource_newrelic_alert_policy_channel_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
2 changes: 2 additions & 0 deletions newrelic/resource_newrelic_alert_policy_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//go:build integration || unit
// +build integration unit

//
// Test helpers
//
Expand Down
1 change: 1 addition & 0 deletions newrelic/resource_newrelic_alert_policy_unit_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build unit
// +build unit

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/resource_newrelic_api_access_key_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/resource_newrelic_application_settings_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
11 changes: 6 additions & 5 deletions newrelic/resource_newrelic_entity_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/newrelic/newrelic-client-go/pkg/common"
"github.com/newrelic/newrelic-client-go/pkg/entities"
nrErrors "github.com/newrelic/newrelic-client-go/pkg/errors"
)
Expand Down Expand Up @@ -77,7 +78,7 @@ func resourceNewRelicEntityTagsCreate(ctx context.Context, d *schema.ResourceDat

client := providerConfig.NewClient

guid := entities.EntityGUID(d.Get("guid").(string))
guid := common.EntityGUID(d.Get("guid").(string))
tags := expandEntityTags(d.Get("tag").(*schema.Set).List())

_, err := client.Entities.TaggingAddTagsToEntityWithContext(ctx, guid, tags)
Expand Down Expand Up @@ -132,7 +133,7 @@ func resourceNewRelicEntityTagsRead(ctx context.Context, d *schema.ResourceData,

log.Printf("[INFO] Reading New Relic entity tags for entity guid %s", d.Id())

t, err := client.Entities.GetTagsForEntity(entities.EntityGUID(d.Id()))
t, err := client.Entities.GetTagsForEntity(common.EntityGUID(d.Id()))

if err != nil {
if _, ok := err.(*nrErrors.NotFound); ok {
Expand Down Expand Up @@ -161,13 +162,13 @@ func resourceNewRelicEntityTagsUpdate(ctx context.Context, d *schema.ResourceDat

tags := expandEntityTags(d.Get("tag").(*schema.Set).List())

_, err := client.Entities.TaggingReplaceTagsOnEntityWithContext(ctx, entities.EntityGUID(d.Id()), tags)
_, err := client.Entities.TaggingReplaceTagsOnEntityWithContext(ctx, common.EntityGUID(d.Id()), tags)
if err != nil {
return diag.FromErr(err)
}

retryErr := resource.RetryContext(ctx, d.Timeout(schema.TimeoutCreate), func() *resource.RetryError {
t, err := client.Entities.GetTagsForEntity(entities.EntityGUID(d.Id()))
t, err := client.Entities.GetTagsForEntity(common.EntityGUID(d.Id()))
if err != nil {
return resource.NonRetryableError(fmt.Errorf("error retrieving entity tags for guid %s: %s", d.Id(), err))
}
Expand Down Expand Up @@ -232,7 +233,7 @@ func resourceNewRelicEntityTagsDelete(ctx context.Context, d *schema.ResourceDat
tags := expandEntityTags(d.Get("tag").(*schema.Set).List())
tagKeys := getTagKeys(tags)

_, err := client.Entities.TaggingDeleteTagFromEntityWithContext(ctx, entities.EntityGUID(d.Id()), tagKeys)
_, err := client.Entities.TaggingDeleteTagFromEntityWithContext(ctx, common.EntityGUID(d.Id()), tagKeys)
if err != nil {
return diag.FromErr(err)
}
Expand Down
7 changes: 4 additions & 3 deletions newrelic/resource_newrelic_entity_tags_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand All @@ -8,7 +9,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/newrelic/newrelic-client-go/pkg/entities"
"github.com/newrelic/newrelic-client-go/pkg/common"
)

func TestAccNewRelicEntityTags_Basic(t *testing.T) {
Expand Down Expand Up @@ -50,7 +51,7 @@ func testAccCheckNewRelicEntityTagsDestroy(s *terraform.State) error {
continue
}

_, err := client.Entities.ListTags(entities.EntityGUID(r.Primary.ID))
_, err := client.Entities.ListTags(common.EntityGUID(r.Primary.ID))

if err != nil {
return fmt.Errorf("entity tags still exist: %s", err)
Expand All @@ -73,7 +74,7 @@ func testAccCheckNewRelicEntityTagsExist(n string, keysToCheck []string) resourc

client := testAccProvider.Meta().(*ProviderConfig).NewClient

t, err := client.Entities.GetTagsForEntity(entities.EntityGUID(rs.Primary.ID))
t, err := client.Entities.GetTagsForEntity(common.EntityGUID(rs.Primary.ID))
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions newrelic/resource_newrelic_events_to_metrics_rule_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/resource_newrelic_infra_alert_condition_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/resource_newrelic_insights_event_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/resource_newrelic_nrql_alert_condition_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
1 change: 1 addition & 0 deletions newrelic/resource_newrelic_nrql_drop_rule_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

package newrelic
Expand Down
8 changes: 4 additions & 4 deletions newrelic/resource_newrelic_one_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/newrelic/newrelic-client-go/pkg/entities"
"github.com/newrelic/newrelic-client-go/pkg/common"
"github.com/newrelic/newrelic-client-go/pkg/errors"
)

Expand Down Expand Up @@ -415,7 +415,7 @@ func resourceNewRelicOneDashboardRead(ctx context.Context, d *schema.ResourceDat

log.Printf("[INFO] Reading New Relic One dashboard %s", d.Id())

dashboard, err := client.Dashboards.GetDashboardEntityWithContext(ctx, entities.EntityGUID(d.Id()))
dashboard, err := client.Dashboards.GetDashboardEntityWithContext(ctx, common.EntityGUID(d.Id()))
if err != nil {
if _, ok := err.(*errors.NotFound); ok {
d.SetId("")
Expand Down Expand Up @@ -448,7 +448,7 @@ func resourceNewRelicOneDashboardUpdate(ctx context.Context, d *schema.ResourceD

log.Printf("[INFO] Updating New Relic One dashboard '%s' (%s)", dashboard.Name, d.Id())

result, err := client.Dashboards.DashboardUpdateWithContext(ctx, *dashboard, entities.EntityGUID(d.Id()))
result, err := client.Dashboards.DashboardUpdateWithContext(ctx, *dashboard, common.EntityGUID(d.Id()))
if err != nil {
return diag.FromErr(err)
}
Expand All @@ -463,7 +463,7 @@ func resourceNewRelicOneDashboardDelete(ctx context.Context, d *schema.ResourceD

log.Printf("[INFO] Deleting New Relic One dashboard %v", d.Id())

if _, err := client.Dashboards.DashboardDeleteWithContext(ctx, entities.EntityGUID(d.Id())); err != nil {
if _, err := client.Dashboards.DashboardDeleteWithContext(ctx, common.EntityGUID(d.Id())); err != nil {
if _, ok := err.(*errors.NotFound); ok {
return nil
}
Expand Down
Loading

0 comments on commit 6ca4df1

Please sign in to comment.