Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add mindthegap to useragent #476

Merged
merged 1 commit into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
Loading