forked from toolshed/abra
feat: WIP server rm command
This commit is contained in:
@ -57,6 +57,25 @@ func createContext(name string, host string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeleteContext(name string) error {
|
||||
if name == "default" {
|
||||
return errors.New("context 'default' cannot be removed")
|
||||
}
|
||||
if _, err := GetContext(name); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove any context that might be loaded
|
||||
// TODO: Check if the context we are removing is the active one rather than doing it all the time
|
||||
cfg := dConfig.LoadDefaultConfigFile(nil)
|
||||
cfg.CurrentContext = ""
|
||||
if err := cfg.Save(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return NewDefaultDockerContextStore().Remove(name)
|
||||
}
|
||||
|
||||
func GetContext(contextName string) (contextStore.Metadata, error) {
|
||||
ctx, err := NewDefaultDockerContextStore().GetMetadata(contextName)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user