mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
change kubeconfig loading order
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user