Skip to content

Commit

Permalink
feat(changetracking): add deployment custom attributes (#1047)
Browse files Browse the repository at this point in the history
Co-authored-by: Sander Blue <[email protected]>
  • Loading branch information
noahmmcgivern and sanderblue committed Aug 1, 2023
1 parent 9af8c87 commit 4a75305
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 34 deletions.
26 changes: 16 additions & 10 deletions pkg/changetracking/changetracking_api_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
37 changes: 37 additions & 0 deletions pkg/changetracking/changetracking_types.go
Original file line number Diff line number Diff line change
@@ -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"`
}
24 changes: 0 additions & 24 deletions pkg/changetracking/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

0 comments on commit 4a75305

Please sign in to comment.