fix: silencing usage on failures

This commit is contained in:
Jennifer Power
2021-06-02 11:49:08 -04:00
parent 455373fe9f
commit cd0c5a174f
3 changed files with 8 additions and 7 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ func NewCopyCommand() *cobra.Command {
f := cmd.Flags()
f.StringVarP(&opts.dir, "dir", "d", ".", "Target directory for file copy")
f.StringVarP(&opts.src, "registry", "r", "myregistry:5000", "Registry URL to copy file from")
f.StringVarP(&opts.src, "registry", "r", "localhost:5000/file:test", "URI for object in the registry")
return cmd
}
+6 -5
View File
@@ -30,7 +30,7 @@ var (
haulerctl bundle artifacts <artfiacts>
haulerctl relocate artifacts <aritfacts>
haulerctl relocate images <images>
haulerctl copy <registry>
haulerctl copy
haulerctl create
haulerctl bootstrap`
)
@@ -38,10 +38,11 @@ var (
// NewRootCommand defines the root haulerctl command
func NewRootCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "haulerctl",
Short: "haulerctl provides CLI-based air-gap migration assistance",
Long: getLong,
Example: getExample,
Use: "haulerctl",
Short: "haulerctl provides CLI-based air-gap migration assistance",
Long: getLong,
Example: getExample,
SilenceUsage: true,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if err := setupLogger(os.Stdout, loglevel); err != nil {
return err
+1 -1
View File
@@ -57,7 +57,7 @@ func (c Copier) Get(ctx context.Context, src string) error {
resolver := docker.NewResolver(docker.ResolverOptions{})
// Pull file(s) from registry and save to disk
fmt.Printf("Pulling from %s and saving to %s...\n", src, c.Dir)
fmt.Printf("Pulling from %s and saving to %s\n", src, c.Dir)
allowedMediaTypes := []string{(c.mediaType)}
desc, _, err := oras.Pull(ctx, resolver, src, c.fileStore, oras.WithAllowedMediaTypes(allowedMediaTypes))