Skip to content

Commit

Permalink
fixin some lintin
Browse files Browse the repository at this point in the history
  • Loading branch information
Skarlso committed Dec 16, 2024
1 parent 7358582 commit a81eb4a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 78 deletions.
63 changes: 2 additions & 61 deletions api/oci/extensions/repositories/ocireg/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ 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"

"ocm.software/ocm/api/credentials"
"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"
Expand Down Expand Up @@ -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)
Expand All @@ -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(),
Expand Down
17 changes: 3 additions & 14 deletions api/tech/oras/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
1 change: 0 additions & 1 deletion api/tech/oras/delayed_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion api/tech/regclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion api/tech/regclient/delayed_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a81eb4a

Please sign in to comment.