kubectl: run - remove unneeded vars

No need extra vars just for a single validation.

Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>

Kubernetes-commit: ea017e53af84b05154f275fabcfc95a61b091493
This commit is contained in:
Douglas Schilling Landgraf 2021-01-15 21:03:27 -05:00 committed by Kubernetes Publisher
parent 0b9eb81108
commit b839958e59
1 changed files with 4 additions and 5 deletions

View File

@ -273,13 +273,12 @@ func (o *RunOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
} }
// validate image name // validate image name
imageName := o.Image if o.Image == "" {
if imageName == "" {
return fmt.Errorf("--image is required") return fmt.Errorf("--image is required")
} }
validImageRef := reference.ReferenceRegexp.MatchString(imageName)
if !validImageRef { if !reference.ReferenceRegexp.MatchString(o.Image) {
return fmt.Errorf("Invalid image name %q: %v", imageName, reference.ErrReferenceInvalidFormat) return fmt.Errorf("Invalid image name %q: %v", o.Image, reference.ErrReferenceInvalidFormat)
} }
if o.TTY && !o.Interactive { if o.TTY && !o.Interactive {