~hduran-8/juju-core/add_create_stream_script

« back to all changes in this revision

Viewing changes to cmd/juju/constraints.go

  • Committer: Tarmac
  • Author(s): mattyw, Matthew Williams
  • Date: 2014-04-01 14:55:36 UTC
  • mfrom: (2303.4.44 user-add-remove-cli)
  • Revision ID: tarmac-20140401145536-0l5f7pln1d1pm24d
[r=mattyw],[bug=1285256] https://codereview.appspot.com/75600044/

Preliminary support for basic juju id commands:

juju add-user <username> <password>

if password is not supplied a strong one is generated.
The resulting jenv file is output (or saved to a file if -o option is provided)

juju remove-user <username>

doesn't actually remove the user. But mark them as inactive

add-user and remove-user aren't registered yet as they are useless without
login. But the details of this are still being worked out.

This branch also contains fixes for lp:1285256.
The EnvCommandBase struct includes a function for ensuring the envname is not ""

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
        "launchpad.net/gnuflag"
10
10
 
11
11
        "launchpad.net/juju-core/cmd"
 
12
        "launchpad.net/juju-core/cmd/envcmd"
12
13
        "launchpad.net/juju-core/constraints"
13
14
        "launchpad.net/juju-core/juju"
14
15
        "launchpad.net/juju-core/names"
51
52
 
52
53
// GetConstraintsCommand shows the constraints for a service or environment.
53
54
type GetConstraintsCommand struct {
54
 
        cmd.EnvCommandBase
 
55
        envcmd.EnvCommandBase
55
56
        ServiceName string
56
57
        out         cmd.Output
57
58
}
79
80
}
80
81
 
81
82
func (c *GetConstraintsCommand) Init(args []string) error {
 
83
        err := c.EnvCommandBase.Init()
 
84
        if err != nil {
 
85
                return err
 
86
        }
82
87
        if len(args) > 0 {
83
88
                if !names.IsService(args[0]) {
84
89
                        return fmt.Errorf("invalid service name %q", args[0])
129
134
 
130
135
// SetConstraintsCommand shows the constraints for a service or environment.
131
136
type SetConstraintsCommand struct {
132
 
        cmd.EnvCommandBase
 
137
        envcmd.EnvCommandBase
133
138
        ServiceName string
134
139
        Constraints constraints.Value
135
140
}
150
155
}
151
156
 
152
157
func (c *SetConstraintsCommand) Init(args []string) (err error) {
 
158
        err = c.EnvCommandBase.Init()
 
159
        if err != nil {
 
160
                return
 
161
        }
153
162
        if c.ServiceName != "" && !names.IsService(c.ServiceName) {
154
163
                return fmt.Errorf("invalid service name %q", c.ServiceName)
155
164
        }