Add support for plain HTTP transport to OCI registry client

Signed-off-by: Max Jonas Werner <max@e13.dev>
pull/11139/head
Max Jonas Werner 3 years ago
parent c52cd40ace
commit 38675ae604
No known key found for this signature in database
GPG Key ID: EB525E0F02B52140

@ -57,6 +57,7 @@ type (
enableCache bool
// path to repository config file e.g. ~/.docker/config.json
credentialsFile string
plainHTTP bool
out io.Writer
authorizer auth.Client
registryAuthorizer *registryauth.Client
@ -90,6 +91,9 @@ func NewClient(options ...ClientOption) (*Client, error) {
headers := http.Header{}
headers.Set("User-Agent", version.GetUserAgent())
opts := []auth.ResolverOption{auth.WithResolverHeaders(headers)}
if client.plainHTTP {
opts = append(opts, auth.WithResolverPlainHTTP())
}
resolver, err := client.authorizer.ResolverWithOpts(opts...)
if err != nil {
return nil, err
@ -166,6 +170,12 @@ func ClientOptCredentialsFile(credentialsFile string) ClientOption {
}
}
func ClientOptPlainHTTP() ClientOption {
return func(client *Client) {
client.plainHTTP = true
}
}
type (
// LoginOption allows specifying various settings on login
LoginOption func(*loginOperation)

Loading…
Cancel
Save