Skip to content

Commit

Permalink
Add a user agent to GCB calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlorenc committed May 23, 2018
1 parent b86a12b commit 996dd87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/skaffold/build/container_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"io"
"time"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/version"

cstorage "cloud.google.com/go/storage"
"golang.org/x/oauth2/google"
cloudbuild "google.golang.org/api/cloudbuild/v1"
Expand Down Expand Up @@ -84,6 +86,7 @@ func (cb *GoogleCloudBuilder) Build(ctx context.Context, out io.Writer, tagger t
if err != nil {
return nil, errors.Wrap(err, "getting builder")
}
cbclient.UserAgent = version.UserAgent()
c, err := cstorage.NewClient(ctx)
if err != nil {
return nil, errors.Wrap(err, "getting cloud storage client")
Expand Down
7 changes: 6 additions & 1 deletion pkg/skaffold/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
)

var version, gitCommit, gitTreeState, buildDate string
var platform = fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)

type Info struct {
Version string
Expand All @@ -44,6 +45,10 @@ func Get() *Info {
BuildDate: buildDate,
GoVersion: runtime.Version(),
Compiler: runtime.Compiler,
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
Platform: platform,
}
}

func UserAgent() string {
return fmt.Sprintf("skaffold/%s/%s", platform, version)
}

0 comments on commit 996dd87

Please sign in to comment.