Skip to content

Commit

Permalink
no dummy resolver applied to reference resolver
Browse files Browse the repository at this point in the history
Signed-off-by: Shiwei Zhang <shizh@microsoft.com>
  • Loading branch information
shizhMSFT committed Mar 31, 2021
1 parent 321d79c commit 0e3fc18
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/oras/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ func runPush(opts pushOptions) error {
// bake artifact
var pushOpts []oras.PushOpt
if opts.artifactType != "" {
manifests, err := loadReferences(ctx, resolver, opts.artifactRefs)
refResolver := resolver
if iresolver.IsDummy(resolver) {
refResolver = newResolver(opts.username, opts.password, opts.insecure, opts.plainHTTP, opts.configs...)
}
manifests, err := loadReferences(ctx, refResolver, opts.artifactRefs)
if err != nil {
return err
}
Expand Down
5 changes: 5 additions & 0 deletions internal/resolver/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ func Dummy() remotes.Resolver {
return dummyResolverInstance
}

// IsDummy checks if the resolver is dummy
func IsDummy(resolver remotes.Resolver) bool {
return resolver == dummyResolverInstance
}

func (r *dummyResolver) Resolve(ctx context.Context, ref string) (name string, desc ocispec.Descriptor, err error) {
return "", ocispec.Descriptor{}, errors.Wrap(errdefs.ErrNotFound, "dummy resolver")
}
Expand Down

0 comments on commit 0e3fc18

Please sign in to comment.