Example #1
0
func (c *GetConstraintsCommand) Run(ctx *cmd.Context) error {
	conn, err := juju.NewConnFromName(c.EnvName)
	if err != nil {
		return err
	}
	defer conn.Close()

	var cons constraints.Value
	if c.ServiceName != "" {
		args := params.GetServiceConstraints{
			ServiceName: c.ServiceName,
		}
		var results params.GetServiceConstraintsResults
		results, err = statecmd.GetServiceConstraints(conn.State, args)
		cons = results.Constraints
	} else {
		cons, err = conn.State.EnvironConstraints()
	}
	if err != nil {
		return err
	}
	return c.out.Write(ctx, cons)
}
Example #2
0
// GetServiceConstraints returns the constraints for a given service.
func (c *Client) GetServiceConstraints(args params.GetServiceConstraints) (params.GetServiceConstraintsResults, error) {
	return statecmd.GetServiceConstraints(c.api.state, args)
}