diff --git a/cmd/cli.go b/cmd/cli.go index a19bc5d..4114c45 100644 --- a/cmd/cli.go +++ b/cmd/cli.go @@ -178,7 +178,23 @@ func (c *CLI) ensureContext(cmd *cobra.Command, args []string) error { return nil } - +func (c *CLI) SetContext(name, endpoint, user, password string) { + if c.config == nil { + c.config = &Config{ + Contexts: []*Context{}, + Insecure: false, + ActiveContext: "", + } + } + context := &Context{ + Name: name, + Endpoint: endpoint, + User: user, + Password: password, + } + c.config.Contexts = append(c.config.Contexts, context) + c.config.ActiveContext = context.Name +} func (c *CLI) readConfig() { cfgLogJSON := viper.GetBool("log-json") if cfgLogJSON {