Skip to content

Commit

Permalink
Merge pull request #75 from K-Phoen/stackdriver-project-name
Browse files Browse the repository at this point in the history
Allow the GCP project to be set by target
  • Loading branch information
K-Phoen authored Jul 10, 2020
2 parents 6b96860 + 08fcfef commit 0715171
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 20 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.13

require (
github.com/gosimple/slug v1.9.0 // indirect
github.com/grafana-tools/sdk v0.0.0-20200610203821-a982d46f0598
github.com/grafana-tools/sdk v0.0.0-20200707194905-904dd74ea1f1
github.com/stretchr/testify v1.4.0
gopkg.in/yaml.v2 v2.2.2
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/gosimple/slug v1.1.1 h1:fRu/digW+NMwBIP+RmviTK97Ho/bEj/C9swrCspN3D4=
github.com/gosimple/slug v1.1.1/go.mod h1:ER78kgg1Mv0NQGlXiDe57DpCyfbNywXXZ9mIorhxAf0=
github.com/gosimple/slug v1.9.0 h1:r5vDcYrFz9BmfIAMC829un9hq7hKM4cHUrsv36LbEqs=
github.com/gosimple/slug v1.9.0/go.mod h1:AMZ+sOVe65uByN3kgEyf9WEBKBCSS+dJjMX9x4vDJbg=
github.com/grafana-tools/sdk v0.0.0-20200610203821-a982d46f0598 h1:PqTSd+sSXH9WkMMCXW41J061pAwLBgPbvW7/2inMjCc=
github.com/grafana-tools/sdk v0.0.0-20200610203821-a982d46f0598/go.mod h1:aqBqJVTJmj0MTX9cP8wuReJPte6HyttMDzSS2u8nJwo=
github.com/grafana-tools/sdk v0.0.0-20200707194905-904dd74ea1f1 h1:rrFdCywvFjLar44ALynJnQmQdrZEHx+6uN2dWLYZhMM=
github.com/grafana-tools/sdk v0.0.0-20200707194905-904dd74ea1f1/go.mod h1:aqBqJVTJmj0MTX9cP8wuReJPte6HyttMDzSS2u8nJwo=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
7 changes: 7 additions & 0 deletions target/stackdriver/stackdriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ func Legend(legend string) Option {
}
}

// Project defines the GCP project to use for this target.
func Project(project string) Option {
return func(stackdriver *Stackdriver) {
stackdriver.Builder.ProjectName = project
}
}

// Aggregation defines how the time series will be aggregated.
func Aggregation(reducer Reducer) Option {
return func(stackdriver *Stackdriver) {
Expand Down
9 changes: 9 additions & 0 deletions target/stackdriver/stackdriver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ func TestLegendCanBeConfigured(t *testing.T) {
req.Equal(legend, target.Builder.AliasBy)
}

func TestProjectCanBeConfigured(t *testing.T) {
req := require.New(t)
project := "some-gcp-project-id"

target := stackdriver.Delta("", stackdriver.Project(project))

req.Equal(project, target.Builder.ProjectName)
}

func TestRefCanBeConfigured(t *testing.T) {
req := require.New(t)

Expand Down
37 changes: 21 additions & 16 deletions vendor/github.com/grafana-tools/sdk/panel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
github.com/davecgh/go-spew/spew
# github.com/gosimple/slug v1.9.0
github.com/gosimple/slug
# github.com/grafana-tools/sdk v0.0.0-20200610203821-a982d46f0598
# github.com/grafana-tools/sdk v0.0.0-20200707194905-904dd74ea1f1
github.com/grafana-tools/sdk
# github.com/pkg/errors v0.9.1
github.com/pkg/errors
Expand Down

0 comments on commit 0715171

Please sign in to comment.