From 38675ae604506373a1834f0a14fcbeaf6bd1b737 Mon Sep 17 00:00:00 2001 From: Max Jonas Werner Date: Tue, 12 Jul 2022 21:39:29 +0200 Subject: [PATCH] Add support for plain HTTP transport to OCI registry client Signed-off-by: Max Jonas Werner --- pkg/registry/client.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/registry/client.go b/pkg/registry/client.go index c1004f956..cdc17a6e8 100644 --- a/pkg/registry/client.go +++ b/pkg/registry/client.go @@ -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)