Done. Refactored to get user and stateServers from one read of jenv.


On 05/06/14 13:15, Tim Penhey wrote:
>
> In cmd/juju/switch.go:
>
> > -		fmt.Fprintf(ctx.Stdout, "%s\n", currentEnv)
> > -	default:
> > -		// Switch the environment.
> > -		if !validEnvironmentName(c.EnvName, names) {
> > -			return fmt.Errorf("%q is not a name of an existing defined environment", c.EnvName)
> > +	return nil
> > +}
> > +
> > +// envInfo builds and returns an EnvInfo
> > +func (c *SwitchCommand) envInfo(ctx *cmd.Context, envName string, oldEnvName string) (info EnvInfo, err error) {
> > +	info.EnvironName = envName
> > +	info.PreviousEnvironName = oldEnvName
> > +	if info.Username, err = user(envName); err != nil {
> > +		return EnvInfo{}, err
> > +	}
> > +	if info.StateServers, err = stateServers(envName); err != nil {
>
> Both user and stateServers for the environment need to read the jenv 
> file. Perhaps consider doing that before?
>
> —
> Reply to this email directly or view it on GitHub 
> <https://github.com/juju/juju/pull/20/files#r13420130>.
>