Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 4de4c3f

Browse files
Merge pull request #569 from ulyssessouza/mute-push-unsupported-warning
Mute warning when pushing to a registry
2 parents 20ccb74 + 2d920e9 commit 4de4c3f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

internal/commands/push.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"os"
1010
"strings"
1111

12+
"github.com/containerd/containerd/log"
1213
"github.com/containerd/containerd/platforms"
1314
"github.com/deislabs/cnab-go/bundle"
1415
"github.com/docker/app/types/metadata"
@@ -23,6 +24,7 @@ import (
2324
"github.com/morikuni/aec"
2425
ocischemav1 "github.com/opencontainers/image-spec/specs-go/v1"
2526
"github.com/pkg/errors"
27+
"github.com/sirupsen/logrus"
2628
"github.com/spf13/cobra"
2729
"github.com/spf13/pflag"
2830
)
@@ -133,14 +135,21 @@ func runPush(dockerCli command.Cli, name string, opts pushOptions) error {
133135
return errors.Wrapf(err, "fixing up %q for push", retag.cnabRef)
134136
}
135137
// push bundle manifest
136-
descriptor, err := remotes.Push(context.Background(), bndl, retag.cnabRef, resolverConfig.Resolver, true, withAppAnnotations)
138+
descriptor, err := remotes.Push(newMuteLogContext(), bndl, retag.cnabRef, resolverConfig.Resolver, true, withAppAnnotations)
137139
if err != nil {
138140
return errors.Wrapf(err, "pushing to %q", retag.cnabRef)
139141
}
140142
fmt.Fprintf(os.Stdout, "Successfully pushed bundle to %s. Digest is %s.\n", retag.cnabRef.String(), descriptor.Digest)
141143
return nil
142144
}
143145

146+
func newMuteLogContext() context.Context {
147+
logger := logrus.New()
148+
logger.SetLevel(logrus.ErrorLevel)
149+
logger.SetOutput(ioutil.Discard)
150+
return log.WithLogger(context.Background(), logrus.NewEntry(logger))
151+
}
152+
144153
func withAppAnnotations(index *ocischemav1.Index) error {
145154
if index.Annotations == nil {
146155
index.Annotations = make(map[string]string)

0 commit comments

Comments
 (0)