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

@@ -25,12 +25,12 @@ import (
)
type useContextOptions struct {
pathOptions *PathOptions
contextName string
configAccess ConfigAccess
contextName string
}
func NewCmdConfigUseContext(out io.Writer, pathOptions *PathOptions) *cobra.Command {
options := &useContextOptions{pathOptions: pathOptions}
func NewCmdConfigUseContext(out io.Writer, configAccess ConfigAccess) *cobra.Command {
options := &useContextOptions{configAccess: configAccess}
cmd := &cobra.Command{
Use: "use-context CONTEXT_NAME",
@@ -57,14 +57,14 @@ func (o useContextOptions) run() error {
return err
}
config, err := o.pathOptions.getStartingConfig()
config, err := o.configAccess.GetStartingConfig()
if err != nil {
return err
}
config.CurrentContext = o.contextName
if err := o.pathOptions.ModifyConfig(*config); err != nil {
if err := ModifyConfig(o.configAccess, *config); err != nil {
return err
}
@@ -87,5 +87,5 @@ func (o useContextOptions) validate() error {
return errors.New("You must specify a current-context")
}
return o.pathOptions.Validate()
return nil
}