Example #1
0
// Print out the addresses of the API server endpoints.
func (c *EndpointCommand) Run(ctx *cmd.Context) error {
	apiendpoint, err := juju.APIEndpointForEnv(c.EnvName, c.refresh)
	if err != nil {
		return err
	}
	return c.out.Write(ctx, apiendpoint.Addresses)
}
Example #2
0
// Print out the addresses of the API server endpoints.
func (c *EndpointCommand) Run(ctx *cmd.Context) error {
	apiendpoint, err := juju.APIEndpointForEnv(c.EnvName, c.refresh)
	if err != nil {
		return err
	}
	// We rely on the fact that the returned API endoint always
	// has the last address we connected to as the first address.
	address := apiendpoint.Addresses[0]
	return c.out.Write(ctx, address)
}
Example #3
0
func (s *APIEndpointForEnvSuite) TestAPIEndpointForEnvSuchName(c *gc.C) {
	coretesting.WriteEnvironments(c, coretesting.MultipleEnvConfig)
	_, err := juju.APIEndpointForEnv("no-such-env", false)
	c.Check(err, jc.Satisfies, errors.IsNotFound)
	c.Check(err, gc.ErrorMatches, `environment "no-such-env" not found`)
}