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

Commit 2d920e9

Browse files
author
Ulysses Souza
committed
Mute warning when pushing to a registry
When accepting config media type application/vnd.cnab.config.v1+json, containerd client lib emits a warning: WARN[0015] reference for unknown type: application/vnd.cnab.config.v1+json on stderr. To avoid this, this PR set a muted logger to the push context Based in: cnabio/cnab-to-oci@f709439 Signed-off-by: Ulysses Souza <[email protected]>
1 parent ea61c10 commit 2d920e9

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
)
2830

@@ -127,14 +129,21 @@ func runPush(dockerCli command.Cli, name string, opts pushOptions) error {
127129
return errors.Wrapf(err, "fixing up %q for push", retag.cnabRef)
128130
}
129131
// push bundle manifest
130-
descriptor, err := remotes.Push(context.Background(), bndl, retag.cnabRef, resolverConfig.Resolver, true, withAppAnnotations)
132+
descriptor, err := remotes.Push(newMuteLogContext(), bndl, retag.cnabRef, resolverConfig.Resolver, true, withAppAnnotations)
131133
if err != nil {
132134
return errors.Wrapf(err, "pushing to %q", retag.cnabRef)
133135
}
134136
fmt.Fprintf(os.Stdout, "Successfully pushed bundle to %s. Digest is %s.\n", retag.cnabRef.String(), descriptor.Digest)
135137
return nil
136138
}
137139

140+
func newMuteLogContext() context.Context {
141+
logger := logrus.New()
142+
logger.SetLevel(logrus.ErrorLevel)
143+
logger.SetOutput(ioutil.Discard)
144+
return log.WithLogger(context.Background(), logrus.NewEntry(logger))
145+
}
146+
138147
func withAppAnnotations(index *ocischemav1.Index) error {
139148
if index.Annotations == nil {
140149
index.Annotations = make(map[string]string)

0 commit comments

Comments
 (0)