// EnsureNotBootstrapped returns nil if the environment is not // bootstrapped, and an error if it is or if the function was not able // to tell. func EnsureNotBootstrapped(env environs.Environ) error { _, err := env.ControllerInstances() // If there is no error determining controller instaces, // then we are bootstrapped. switch errors.Cause(err) { case nil: return environs.ErrAlreadyBootstrapped case environs.ErrNoInstances: // TODO(axw) 2015-02-03 #1417526 // We should not be relying on this result, // as it is possible for there to be no // controllers despite the environment // being bootstrapped. fallthrough case environs.ErrNotBootstrapped: return nil } return err }