diff --git a/api/oci/extensions/repositories/ocireg/repository.go b/api/oci/extensions/repositories/ocireg/repository.go index 9b9faf680d..62eab2280d 100644 --- a/api/oci/extensions/repositories/ocireg/repository.go +++ b/api/oci/extensions/repositories/ocireg/repository.go @@ -8,7 +8,6 @@ import ( "github.com/containerd/errdefs" "github.com/mandelsoft/goutils/errors" "github.com/mandelsoft/logging" - "ocm.software/ocm/api/tech/oras" "oras.land/oras-go/v2/registry/remote/auth" "oras.land/oras-go/v2/registry/remote/retry" @@ -16,6 +15,7 @@ import ( "ocm.software/ocm/api/oci/artdesc" "ocm.software/ocm/api/oci/cpi" "ocm.software/ocm/api/tech/oci/identity" + "ocm.software/ocm/api/tech/oras" "ocm.software/ocm/api/tech/regclient" "ocm.software/ocm/api/utils" ocmlog "ocm.software/ocm/api/utils/logging" @@ -122,7 +122,7 @@ func (r *RepositoryImpl) getResolver(comp string) (regclient.Resolver, error) { if creds == nil { logger.Trace("no credentials") } - + authCreds := auth.Credential{} if creds != nil { pass := creds.GetProperty(credentials.ATTR_IDENTITY_TOKEN) @@ -133,65 +133,6 @@ func (r *RepositoryImpl) getResolver(comp string) (regclient.Resolver, error) { authCreds.Password = pass } - //opts := regclient.ClientOptions{ - // Host: []regconfig.Host{ - // { - // Name: "ghcr.io", //TODO: Need to figure out how to set the host. - // User: username, - // Pass: password, - // }, - // }, - // Version: comp, - //} - //opts := docker.ResolverOptions{ - // Hosts: docker.ConvertHosts(config.ConfigureHosts(context.Background(), config.HostOptions{ - // UpdateClient: func(client *http.Client) error { - // // copy from http.DefaultTransport with a roundtripper injection - // client.Transport = ocmlog.NewRoundTripper(client.Transport, logger) - // return nil - // }, - // Credentials: func(host string) (string, string, error) { - // if creds != nil { - // p := creds.GetProperty(credentials.ATTR_IDENTITY_TOKEN) - // if p == "" { - // p = creds.GetProperty(credentials.ATTR_PASSWORD) - // } - // pw := "" - // if p != "" { - // pw = "***" - // } - // logger.Trace("query credentials", ocmlog.ATTR_USER, creds.GetProperty(credentials.ATTR_USERNAME), "pass", pw) - // return creds.GetProperty(credentials.ATTR_USERNAME), p, nil - // } - // logger.Trace("no credentials") - // return "", "", nil - // }, - // DefaultScheme: r.info.Scheme, - // //nolint:gosec // used like the default, there are OCI servers (quay.io) not working with min version. - // DefaultTLS: func() *tls.Config { - // if r.info.Scheme == "http" { - // return nil - // } - // return &tls.Config{ - // // MinVersion: tls.VersionTLS13, - // RootCAs: func() *x509.CertPool { - // var rootCAs *x509.CertPool - // if creds != nil { - // c := creds.GetProperty(credentials.ATTR_CERTIFICATE_AUTHORITY) - // if c != "" { - // rootCAs = x509.NewCertPool() - // rootCAs.AppendCertsFromPEM([]byte(c)) - // } - // } - // if rootCAs == nil { - // rootCAs = rootcertsattr.Get(r.GetContext()).GetRootCertPool(true) - // } - // return rootCAs - // }(), - // } - // }(), - // })), - //} client := &auth.Client{ Client: retry.DefaultClient, Cache: auth.NewCache(), diff --git a/api/tech/oras/client.go b/api/tech/oras/client.go index 0d1d4ce681..755bfee6ee 100644 --- a/api/tech/oras/client.go +++ b/api/tech/oras/client.go @@ -11,6 +11,7 @@ import ( "github.com/opencontainers/go-digest" ociv1 "github.com/opencontainers/image-spec/specs-go/v1" regref "github.com/regclient/regclient/types/ref" + "ocm.software/ocm/api/tech/regclient" "oras.land/oras-go/v2/registry/remote" "oras.land/oras-go/v2/registry/remote/auth" @@ -22,15 +23,12 @@ type ClientOptions struct { } type Client struct { - Client *auth.Client - //Repository *remote.Repository + Client *auth.Client PlainHTTP bool Ref string } -type pushRequest struct { - ref regref.Ref -} +type pushRequest struct{} func (p *pushRequest) Commit(ctx context.Context, size int64, expected digest.Digest, opts ...content.Opt) error { return nil @@ -130,15 +128,6 @@ func (c *Client) Push(ctx context.Context, d ociv1.Descriptor, src regclient.Sou return nil, fmt.Errorf("failed to push: %w, %s", err, c.Ref) } - //ref, err := registry.ParseReference(c.Ref) - //if err != nil { - // return nil, err - //} - //if ref. - //if err := repository.Tag(ctx, d, c.Ref); err != nil { - // return nil, fmt.Errorf("failed to push tag: %w", err) - //} - return &pushRequest{}, nil } diff --git a/api/tech/oras/delayed_reader.go b/api/tech/oras/delayed_reader.go index b73055cc02..9918b78c5d 100644 --- a/api/tech/oras/delayed_reader.go +++ b/api/tech/oras/delayed_reader.go @@ -25,7 +25,6 @@ func (d *delayedReader) Read(p []byte) (n int, err error) { reader, err := d.reader() if err != nil { return 0, err - } return reader.Read(p) diff --git a/api/tech/regclient/client.go b/api/tech/regclient/client.go index c6fc2d8bea..cd51397b6d 100644 --- a/api/tech/regclient/client.go +++ b/api/tech/regclient/client.go @@ -148,7 +148,7 @@ func (c *Client) Resolve(ctx context.Context, ref string) (string, ociv1.Descrip blob, err := c.rc.BlobHead(ctx, r, descriptor.Descriptor{ Digest: digest.Digest(r.Digest), }) - defer blob.Close() // we can safely close it as this is not when we read it. + defer blob.Close() //nolint:staticcheck // we can safely close it as this is not when we read it. if err != nil { if c.isNotFoundError(err) { diff --git a/api/tech/regclient/delayed_reader.go b/api/tech/regclient/delayed_reader.go index 19fb9f2205..ac7f3d5faf 100644 --- a/api/tech/regclient/delayed_reader.go +++ b/api/tech/regclient/delayed_reader.go @@ -25,7 +25,6 @@ func (d *delayedReader) Read(p []byte) (n int, err error) { reader, err := d.reader() if err != nil { return 0, err - } return reader.Read(p)