diff --git a/cmd/oras/push.go b/cmd/oras/push.go index 406948191..df239b8d3 100644 --- a/cmd/oras/push.go +++ b/cmd/oras/push.go @@ -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 } diff --git a/internal/resolver/dummy.go b/internal/resolver/dummy.go index 5e37a27da..39eac5c97 100644 --- a/internal/resolver/dummy.go +++ b/internal/resolver/dummy.go @@ -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") }