1
// Copyright 2012-2015 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
11
"github.com/juju/juju/cmd/envcmd"
12
"github.com/juju/juju/cmd/juju/block"
15
// UnsetCommand sets configuration values of a service back
17
type UnsetCommand struct {
25
Set one or more configuration options for the specified service to their
26
default. See also the set commmand to set one or more configuration options for
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) Init(args []string) error {
41
return errors.New("no service name specified")
43
c.ServiceName = args[0]
45
if len(c.Options) == 0 {
46
return errors.New("no configuration options specified")
51
// UnsetServiceAPI defines the methods on the client API
52
// that the service unset command calls.
53
type UnsetServiceAPI interface {
55
ServiceUnset(service string, options []string) error
58
func (c *UnsetCommand) getAPI() (UnsetServiceAPI, error) {
62
return c.NewAPIClient()
65
// Run resets the configuration of a service.
66
func (c *UnsetCommand) Run(ctx *cmd.Context) error {
67
apiclient, err := c.getAPI()
71
defer apiclient.Close()
72
return block.ProcessBlockedError(apiclient.ServiceUnset(c.ServiceName, c.Options), block.BlockChange)