use version.GetUserAgent

Signed-off-by: Josh Dolitsky <josh@dolit.ski>
pull/9782/head
Josh Dolitsky 4 years ago
parent 31588e7908
commit faf7fc5efd
No known key found for this signature in database
GPG Key ID: B2B93673243A65FB

@ -17,7 +17,6 @@ limitations under the License.
package registry // import "helm.sh/helm/v3/internal/experimental/registry" package registry // import "helm.sh/helm/v3/internal/experimental/registry"
import ( import (
"fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -30,8 +29,6 @@ import (
"helm.sh/helm/v3/pkg/helmpath" "helm.sh/helm/v3/pkg/helmpath"
) )
var userAgent = fmt.Sprintf("helm/%s", version.GetVersion())
type ( type (
// Client works with OCI-compliant registries // Client works with OCI-compliant registries
Client struct { Client struct {
@ -64,7 +61,7 @@ func NewClient(options ...ClientOption) (*Client, error) {
} }
if client.resolver == nil { if client.resolver == nil {
headers := http.Header{} headers := http.Header{}
headers.Set("User-Agent", userAgent) headers.Set("User-Agent", version.GetUserAgent())
opts := []auth.ResolverOption{auth.WithResolverHeaders(headers)} opts := []auth.ResolverOption{auth.WithResolverHeaders(headers)}
resolver, err := client.authorizer.ResolverWithOpts(opts...) resolver, err := client.authorizer.ResolverWithOpts(opts...)
if err != nil { if err != nil {

@ -20,6 +20,8 @@ import (
"fmt" "fmt"
"oras.land/oras-go/pkg/auth" "oras.land/oras-go/pkg/auth"
"helm.sh/helm/v3/internal/version"
) )
// Login logs into a registry // Login logs into a registry
@ -33,7 +35,7 @@ func (c *Client) Login(host string, options ...LoginOption) (*LoginResult, error
auth.WithLoginHostname(host), auth.WithLoginHostname(host),
auth.WithLoginUsername(operation.username), auth.WithLoginUsername(operation.username),
auth.WithLoginSecret(operation.password), auth.WithLoginSecret(operation.password),
auth.WithLoginUserAgent(userAgent), auth.WithLoginUserAgent(version.GetUserAgent()),
} }
if operation.insecure { if operation.insecure {
authorizerLoginOpts = append(authorizerLoginOpts, auth.WithLoginInsecure()) authorizerLoginOpts = append(authorizerLoginOpts, auth.WithLoginInsecure())

Loading…
Cancel
Save