mirror of
https://github.com/rancher/os.git
synced 2025-09-18 08:06:48 +00:00
add ability to delete dynamically added services
This commit is contained in:
@@ -26,6 +26,11 @@ func serviceSubCommands() []cli.Command {
|
||||
Usage: "list services and state",
|
||||
Action: list,
|
||||
},
|
||||
{
|
||||
Name: "delete",
|
||||
Usage: "delete a service",
|
||||
Action: del,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +57,28 @@ func disable(c *cli.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func del(c *cli.Context) {
|
||||
changed := false
|
||||
cfg, err := config.LoadConfig()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
for _, service := range c.Args() {
|
||||
if _, ok := cfg.ServicesInclude[service]; !ok {
|
||||
continue
|
||||
}
|
||||
delete(cfg.ServicesInclude, service)
|
||||
changed = true
|
||||
}
|
||||
|
||||
if changed {
|
||||
if err = cfg.Set("services_include", cfg.ServicesInclude); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func enable(c *cli.Context) {
|
||||
changed := false
|
||||
cfg, err := config.LoadConfig()
|
||||
|
Reference in New Issue
Block a user