unexport fields
Signed-off-by: Meredith Lancaster <malancas@github.com>
This commit is contained in:
parent
8e3c197755
commit
3c2ded10a0
2 changed files with 14 additions and 14 deletions
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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}}}
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue