From 3c2ded10a09f0404cd100dcd452541068421caab Mon Sep 17 00:00:00 2001 From: Meredith Lancaster Date: Thu, 14 Mar 2024 12:27:16 -0600 Subject: [PATCH] unexport fields Signed-off-by: Meredith Lancaster --- pkg/cmd/attestation/artifact/oci/client.go | 12 ++++++------ pkg/cmd/attestation/artifact/oci/client_test.go | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/cmd/attestation/artifact/oci/client.go b/pkg/cmd/attestation/artifact/oci/client.go index 77e78d485..4b29e9e6d 100644 --- a/pkg/cmd/attestation/artifact/oci/client.go +++ b/pkg/cmd/attestation/artifact/oci/client.go @@ -31,13 +31,13 @@ func checkForUnauthorizedOrDeniedErr(err transport.Error) error { } type LiveClient struct { - ParseReference func(string, ...name.Option) (name.Reference, error) - Get func(name.Reference, ...remote.Option) (*remote.Descriptor, error) + parseReference func(string, ...name.Option) (name.Reference, error) + get func(name.Reference, ...remote.Option) (*remote.Descriptor, error) } // where name is formed like ghcr.io/github/my-image-repo func (c LiveClient) GetImageDigest(imgName string) (*v1.Hash, error) { - name, err := c.ParseReference(imgName) + name, err := c.parseReference(imgName) if err != nil { return nil, fmt.Errorf("failed to create image tag: %w", err) } @@ -45,7 +45,7 @@ func (c LiveClient) GetImageDigest(imgName string) (*v1.Hash, error) { // The user must already be authenticated with the container registry // The authn.DefaultKeychain argument indicates that Get should checks the // user's configuration for the registry credentials - desc, err := c.Get(name, remote.WithAuthFromKeychain(authn.DefaultKeychain)) + desc, err := c.get(name, remote.WithAuthFromKeychain(authn.DefaultKeychain)) if err != nil { var transportErr *transport.Error if errors.As(err, &transportErr) { @@ -61,7 +61,7 @@ func (c LiveClient) GetImageDigest(imgName string) (*v1.Hash, error) { func NewLiveClient() *LiveClient { return &LiveClient{ - ParseReference: name.ParseReference, - Get: remote.Get, + parseReference: name.ParseReference, + get: remote.Get, } } diff --git a/pkg/cmd/attestation/artifact/oci/client_test.go b/pkg/cmd/attestation/artifact/oci/client_test.go index 48643a5b0..9aa415c47 100644 --- a/pkg/cmd/attestation/artifact/oci/client_test.go +++ b/pkg/cmd/attestation/artifact/oci/client_test.go @@ -19,10 +19,10 @@ func TestGetImageDigest_Success(t *testing.T) { } c := LiveClient{ - ParseReference: func(string, ...name.Option) (name.Reference, error) { + parseReference: func(string, ...name.Option) (name.Reference, error) { return name.Tag{}, nil }, - Get: func(name.Reference, ...remote.Option) (*remote.Descriptor, error) { + get: func(name.Reference, ...remote.Option) (*remote.Descriptor, error) { d := remote.Descriptor{} d.Digest = expectedDigest @@ -37,10 +37,10 @@ func TestGetImageDigest_Success(t *testing.T) { func TestGetImageDigest_ReferenceFail(t *testing.T) { c := LiveClient{ - ParseReference: func(string, ...name.Option) (name.Reference, error) { + parseReference: func(string, ...name.Option) (name.Reference, error) { return nil, fmt.Errorf("failed to parse reference") }, - Get: func(name.Reference, ...remote.Option) (*remote.Descriptor, error) { + get: func(name.Reference, ...remote.Option) (*remote.Descriptor, error) { return nil, nil }, } @@ -52,10 +52,10 @@ func TestGetImageDigest_ReferenceFail(t *testing.T) { func TestGetImageDigest_AuthFail(t *testing.T) { c := LiveClient{ - ParseReference: func(string, ...name.Option) (name.Reference, error) { + parseReference: func(string, ...name.Option) (name.Reference, error) { return name.Tag{}, nil }, - Get: func(name.Reference, ...remote.Option) (*remote.Descriptor, error) { + get: func(name.Reference, ...remote.Option) (*remote.Descriptor, error) { return nil, &transport.Error{Errors: []transport.Diagnostic{{Code: transport.UnauthorizedErrorCode}}} }, } @@ -68,10 +68,10 @@ func TestGetImageDigest_AuthFail(t *testing.T) { func TestGetImageDigest_Denied(t *testing.T) { c := LiveClient{ - ParseReference: func(string, ...name.Option) (name.Reference, error) { + parseReference: func(string, ...name.Option) (name.Reference, error) { return name.Tag{}, nil }, - Get: func(name.Reference, ...remote.Option) (*remote.Descriptor, error) { + get: func(name.Reference, ...remote.Option) (*remote.Descriptor, error) { return nil, &transport.Error{Errors: []transport.Diagnostic{{Code: transport.DeniedErrorCode}}} }, }