change kubeconfig loading order

This commit is contained in:
deads2k
2015-04-10 08:54:22 -04:00
parent b59266ad84
commit de4be5422c
50 changed files with 446 additions and 409 deletions

View File

@@ -32,7 +32,7 @@ const (
)
type setOptions struct {
pathOptions *PathOptions
configAccess ConfigAccess
propertyName string
propertyValue string
}
@@ -41,8 +41,8 @@ const set_long = `Sets an individual value in a kubeconfig file
PROPERTY_NAME is a dot delimited name where each token represents either a attribute name or a map key. Map keys may not contain dots.
PROPERTY_VALUE is the new value you wish to set.`
func NewCmdConfigSet(out io.Writer, pathOptions *PathOptions) *cobra.Command {
options := &setOptions{pathOptions: pathOptions}
func NewCmdConfigSet(out io.Writer, configAccess ConfigAccess) *cobra.Command {
options := &setOptions{configAccess: configAccess}
cmd := &cobra.Command{
Use: "set PROPERTY_NAME PROPERTY_VALUE",
@@ -69,7 +69,7 @@ func (o setOptions) run() error {
return err
}
config, err := o.pathOptions.getStartingConfig()
config, err := o.configAccess.GetStartingConfig()
if err != nil {
return err
}
@@ -82,7 +82,7 @@ func (o setOptions) run() error {
return err
}
if err := o.pathOptions.ModifyConfig(*config); err != nil {
if err := ModifyConfig(o.configAccess, *config); err != nil {
return err
}
@@ -110,7 +110,7 @@ func (o setOptions) validate() error {
return errors.New("You must specify a property")
}
return o.pathOptions.Validate()
return nil
}
func modifyConfig(curr reflect.Value, steps *navigationSteps, propertyValue string, unset bool) error {