diff --git a/pkg/config/config.go b/pkg/config/config.go index 4b27798b..0b408ad2 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -108,8 +108,15 @@ func GetContexts() error { } func UseContext(context string) error { - viper.Set(CURRENT_CONTEXT, context) - return Write() + contexts := map[string]interface{}{} + viper.UnmarshalKey("contexts", &contexts) + for k := range contexts { + if k == context { + viper.Set(CURRENT_CONTEXT, context) + return Write() + } + } + return fmt.Errorf("Context %s not found", context) } func CurrentContext() (*Context, error) {