From e1aeaa3b97610316cb936f7feb4291ec7447cc68 Mon Sep 17 00:00:00 2001 From: Noah <47485486+noahmmcgivern@users.noreply.github.com> Date: Tue, 1 Aug 2023 15:58:09 -0400 Subject: [PATCH] chore: changetracking deployment customattributes (#1047) Co-authored-by: Sander Blue --- .../changetracking_api_integration_test.go | 26 ++++++++----- pkg/changetracking/changetracking_types.go | 37 +++++++++++++++++++ pkg/changetracking/types.go | 24 ------------ 3 files changed, 53 insertions(+), 34 deletions(-) create mode 100644 pkg/changetracking/changetracking_types.go diff --git a/pkg/changetracking/changetracking_api_integration_test.go b/pkg/changetracking/changetracking_api_integration_test.go index 26b22f6c4..f32f9458f 100644 --- a/pkg/changetracking/changetracking_api_integration_test.go +++ b/pkg/changetracking/changetracking_api_integration_test.go @@ -19,17 +19,23 @@ func TestChangeTrackingCreateDeployment_Basic(t *testing.T) { a := newIntegrationTestClient(t) + var customAttributes = map[string]string{ + "test": "123", + "test2": "456", + } + input := ChangeTrackingDeploymentInput{ - Changelog: "test", - Commit: "12345a", - DeepLink: "newrelic-client-go", - DeploymentType: ChangeTrackingDeploymentTypeTypes.BASIC, - Description: "This is a test description", - EntityGUID: common.EntityGUID(testhelpers.IntegrationTestApplicationEntityGUID), - GroupId: "deployment", - Timestamp: nrtime.EpochMilliseconds(time.Now()), - User: "newrelic-go-client", - Version: "0.0.1", + Changelog: "test", + Commit: "12345a", + CustomAttributes: &customAttributes, + DeepLink: "newrelic-client-go", + DeploymentType: ChangeTrackingDeploymentTypeTypes.BASIC, + Description: "This is a test description", + EntityGUID: common.EntityGUID(testhelpers.IntegrationTestApplicationEntityGUID), + GroupId: "deployment", + Timestamp: nrtime.EpochMilliseconds(time.Now()), + User: "newrelic-go-client", + Version: "0.0.1", } res, err := a.ChangeTrackingCreateDeployment(input) diff --git a/pkg/changetracking/changetracking_types.go b/pkg/changetracking/changetracking_types.go new file mode 100644 index 000000000..64877a81c --- /dev/null +++ b/pkg/changetracking/changetracking_types.go @@ -0,0 +1,37 @@ +package changetracking + +import ( + "github.com/newrelic/newrelic-client-go/v2/pkg/common" + "github.com/newrelic/newrelic-client-go/v2/pkg/nrtime" +) + +/* +Since we can't yet generate the CustomAttributes type with Tutone, +defer ChangeTrackingDeploymentInput placement into types.go until CustomAttributes GA. +*/ + +// ChangeTrackingDeploymentInput - A deployment. +type ChangeTrackingDeploymentInput struct { + // A URL for the changelog or list of changes if not linkable. + Changelog string `json:"changelog,omitempty"` + // The commit identifier, for example, a Git commit SHA. + Commit string `json:"commit,omitempty"` + // A list of key:value attribute pairs + CustomAttributes *map[string]string `json:"customAttributes,omitempty"` + // A link back to the system generating the deployment. + DeepLink string `json:"deepLink,omitempty"` + // The type of deployment, for example, ‘Blue green’ or ‘Rolling’. + DeploymentType ChangeTrackingDeploymentType `json:"deploymentType,omitempty"` + // A description of the deployment. + Description string `json:"description,omitempty"` + // The NR1 entity that was deployed. + EntityGUID common.EntityGUID `json:"entityGuid"` + // String that can be used to correlate two or more events. + GroupId string `json:"groupId,omitempty"` + // The start time of the deployment, the number of milliseconds since the Unix epoch. Defaults to now + Timestamp nrtime.EpochMilliseconds `json:"timestamp,omitempty"` + // Username of the deployer or bot. + User string `json:"user,omitempty"` + // The version of the deployed software, for example, something like v1.1 + Version string `json:"version"` +} diff --git a/pkg/changetracking/types.go b/pkg/changetracking/types.go index 666f39f85..4b23ca6d2 100644 --- a/pkg/changetracking/types.go +++ b/pkg/changetracking/types.go @@ -62,27 +62,3 @@ type ChangeTrackingDeployment struct { // The version of the deployed software, for example, something like v1.1 Version string `json:"version"` } - -// ChangeTrackingDeploymentInput - A deployment. -type ChangeTrackingDeploymentInput struct { - // A URL for the changelog or list of changes if not linkable. - Changelog string `json:"changelog,omitempty"` - // The commit identifier, for example, a Git commit SHA. - Commit string `json:"commit,omitempty"` - // A link back to the system generating the deployment. - DeepLink string `json:"deepLink,omitempty"` - // The type of deployment, for example, ‘Blue green’ or ‘Rolling’. - DeploymentType ChangeTrackingDeploymentType `json:"deploymentType,omitempty"` - // A description of the deployment. - Description string `json:"description,omitempty"` - // The NR1 entity that was deployed. - EntityGUID common.EntityGUID `json:"entityGuid"` - // String that can be used to correlate two or more events. - GroupId string `json:"groupId,omitempty"` - // The start time of the deployment, the number of milliseconds since the Unix epoch. Defaults to now - Timestamp nrtime.EpochMilliseconds `json:"timestamp,omitempty"` - // Username of the deployer or bot. - User string `json:"user,omitempty"` - // The version of the deployed software, for example, something like v1.1 - Version string `json:"version"` -}