From b839958e5999ee349d9abe89b78c62af90244866 Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Fri, 15 Jan 2021 21:03:27 -0500 Subject: [PATCH] kubectl: run - remove unneeded vars No need extra vars just for a single validation. Signed-off-by: Douglas Schilling Landgraf Kubernetes-commit: ea017e53af84b05154f275fabcfc95a61b091493 --- pkg/cmd/run/run.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/run/run.go b/pkg/cmd/run/run.go index b8ef46b6..90d67ef7 100644 --- a/pkg/cmd/run/run.go +++ b/pkg/cmd/run/run.go @@ -273,13 +273,12 @@ func (o *RunOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e } // validate image name - imageName := o.Image - if imageName == "" { + if o.Image == "" { return fmt.Errorf("--image is required") } - validImageRef := reference.ReferenceRegexp.MatchString(imageName) - if !validImageRef { - return fmt.Errorf("Invalid image name %q: %v", imageName, reference.ErrReferenceInvalidFormat) + + if !reference.ReferenceRegexp.MatchString(o.Image) { + return fmt.Errorf("Invalid image name %q: %v", o.Image, reference.ErrReferenceInvalidFormat) } if o.TTY && !o.Interactive {