Skip to content

Commit

Permalink
feat: Add mindthegap to useragent (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson authored Jul 31, 2023
1 parent 5e81317 commit 14f7d2c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
8 changes: 7 additions & 1 deletion cmd/mindthegap/create/imagebundle/image_bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/mesosphere/mindthegap/archive"
"github.com/mesosphere/mindthegap/cleanup"
"github.com/mesosphere/mindthegap/cmd/mindthegap/utils"
"github.com/mesosphere/mindthegap/config"
"github.com/mesosphere/mindthegap/docker/registry"
"github.com/mesosphere/mindthegap/images"
Expand Down Expand Up @@ -133,7 +134,11 @@ func NewCommand(out output.Output) *cobra.Command {
tr.CloseIdleConnections()
}
}()
destRemoteOpts := []remote.Option{remote.WithTransport(destTLSRoundTripper), remote.WithContext(egCtx)}
destRemoteOpts := []remote.Option{
remote.WithTransport(destTLSRoundTripper),
remote.WithContext(egCtx),
remote.WithUserAgent(utils.Useragent()),
}

out.StartOperationWithProgress(pullGauge)

Expand Down Expand Up @@ -165,6 +170,7 @@ func NewCommand(out output.Output) *cobra.Command {
remote.WithTransport(sourceTLSRoundTripper),
remote.WithAuthFromKeychain(keychain),
remote.WithContext(egCtx),
remote.WithUserAgent(utils.Useragent()),
}

platformsStrings := make([]string, 0, len(platforms))
Expand Down
10 changes: 8 additions & 2 deletions cmd/mindthegap/push/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ func NewCommand(out output.Output, bundleCmdName string) *cobra.Command {
out.Error(err, "error configuring TLS for source registry")
os.Exit(2)
}
sourceRemoteOpts := []remote.Option{remote.WithTransport(sourceTLSRoundTripper)}
sourceRemoteOpts := []remote.Option{
remote.WithTransport(sourceTLSRoundTripper),
remote.WithUserAgent(utils.Useragent()),
}

destTLSRoundTripper, err := httputils.TLSConfiguredRoundTripper(
remote.DefaultTransport,
Expand All @@ -119,7 +122,10 @@ func NewCommand(out output.Output, bundleCmdName string) *cobra.Command {
out.Error(err, "error configuring TLS for destination registry")
os.Exit(2)
}
destRemoteOpts := []remote.Option{remote.WithTransport(destTLSRoundTripper)}
destRemoteOpts := []remote.Option{
remote.WithTransport(destTLSRoundTripper),
remote.WithUserAgent(utils.Useragent()),
}

var destNameOpts []name.Option
if flags.SkipTLSVerify(destRegistrySkipTLSVerify, &destRegistryURI) {
Expand Down
14 changes: 14 additions & 0 deletions cmd/mindthegap/utils/useragent.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2023 D2iQ, Inc. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package utils

import (
"fmt"

"github.com/mesosphere/dkp-cli-runtime/core/cmd/version"
)

func Useragent() string {
return fmt.Sprintf("mindthegap/%s", version.GetVersion().GitVersion)
}

0 comments on commit 14f7d2c

Please sign in to comment.