Suggested Changes

This commit is contained in:
Phani Teja Marupaka
2020-05-06 12:38:12 -07:00
parent e771902a07
commit 7309a5cb06
2 changed files with 8 additions and 8 deletions

View File

@@ -4,8 +4,6 @@
package commands
import (
"fmt"
"github.com/go-openapi/spec"
"github.com/spf13/cobra"
"sigs.k8s.io/kustomize/cmd/config/ext"
@@ -106,10 +104,11 @@ func (r *CreateSetterRunner) preRunE(c *cobra.Command, args []string) error {
return err
}
_, err = openapi.Resolve(&ref)
if err == nil {
return errors.Errorf(fmt.Sprintf("substitution with name %s already exists, "+
"substitution and setter can't have same name", r.CreateSetter.Name))
subst, _ := openapi.Resolve(&ref)
// if substitution already exists with the input setter name, throw error
if subst != nil {
return errors.Errorf("substitution with name %s already exists, "+
"substitution and setter can't have same name", r.CreateSetter.Name)
}
r.CreateSetter.Description = r.Set.SetPartialField.Description

View File

@@ -76,8 +76,9 @@ func (r *CreateSubstitutionRunner) preRunE(c *cobra.Command, args []string) erro
return err
}
_, err = openapi.Resolve(&ref) // resolve the setter to its openAPI def
if err == nil {
setter, _ := openapi.Resolve(&ref)
// if setter already exists with input substitution name, throw error
if setter != nil {
return errors.Errorf(fmt.Sprintf("setter with name %s already exists, "+
"substitution and setter can't have same name", r.CreateSubstitution.Name))
}