1
// Copyright 2012, 2013 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
9
"launchpad.net/gnuflag"
11
"launchpad.net/juju-core/charm"
12
"launchpad.net/juju-core/cmd"
13
"launchpad.net/juju-core/juju"
16
// UnsetCommand sets configuration values of a service back
18
type UnsetCommand struct {
25
Set one or more configuration options for the specified service
26
to their default. See also the set commmand to set one or more
27
configuration options for a specified service.
30
func (c *UnsetCommand) Info() *cmd.Info {
33
Args: "<service> name ...",
34
Purpose: "set service config options back to their default",
39
func (c *UnsetCommand) SetFlags(f *gnuflag.FlagSet) {
40
c.EnvCommandBase.SetFlags(f)
43
func (c *UnsetCommand) Init(args []string) error {
45
return errors.New("no service name specified")
47
c.ServiceName = args[0]
52
// Run resets the configuration of a service.
53
func (c *UnsetCommand) Run(ctx *cmd.Context) error {
54
conn, err := juju.NewConnFromName(c.EnvName)
59
service, err := conn.State.Service(c.ServiceName)
63
if len(c.Options) > 0 {
64
settings := make(charm.Settings)
65
for _, option := range c.Options {
66
settings[option] = nil
68
return service.UpdateConfigSettings(settings)