From d4fb0709c940e687d3feb99d2fb99d7c6d53d28a Mon Sep 17 00:00:00 2001 From: Phil Estes Date: Fri, 26 Jan 2018 09:14:13 -0500 Subject: [PATCH] Add error return for missing params in ctr images For missing required parameters adds error return before attempting any actions to `ctr images` commands. Signed-off-by: Phil Estes --- cmd/ctr/commands/images/export.go | 3 +++ cmd/ctr/commands/images/pull.go | 4 +++- cmd/ctr/commands/images/push.go | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/ctr/commands/images/export.go b/cmd/ctr/commands/images/export.go index 3a972913b..c2e450fb1 100644 --- a/cmd/ctr/commands/images/export.go +++ b/cmd/ctr/commands/images/export.go @@ -43,6 +43,9 @@ Currently, only OCI format is supported. local = context.Args().Get(1) desc ocispec.Descriptor ) + if out == "" || local == "" { + return errors.New("please provide both an output filename and an image reference to export") + } client, ctx, cancel, err := commands.NewClient(context) if err != nil { return err diff --git a/cmd/ctr/commands/images/pull.go b/cmd/ctr/commands/images/pull.go index c155413b7..0550d4c29 100644 --- a/cmd/ctr/commands/images/pull.go +++ b/cmd/ctr/commands/images/pull.go @@ -27,7 +27,9 @@ command. As part of this process, we do the following: var ( ref = context.Args().First() ) - + if ref == "" { + return fmt.Errorf("please provide an image reference to pull") + } ctx, cancel := commands.AppContext(context) defer cancel() diff --git a/cmd/ctr/commands/images/push.go b/cmd/ctr/commands/images/push.go index b8b2ee878..48cdee654 100644 --- a/cmd/ctr/commands/images/push.go +++ b/cmd/ctr/commands/images/push.go @@ -49,6 +49,9 @@ var pushCommand = cli.Command{ local = context.Args().Get(1) desc ocispec.Descriptor ) + if ref == "" { + return errors.New("please provide a remote image reference to push") + } client, ctx, cancel, err := commands.NewClient(context) if err != nil { return err