github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/state/utils/environ.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package utils 5 6 import ( 7 "github.com/juju/errors" 8 9 "github.com/juju/juju/environs" 10 "github.com/juju/juju/state" 11 ) 12 13 // GetEnviron returns the environs.Environ ("provider") associated 14 // with the model. 15 func GetEnviron(st *state.State) (environs.Environ, error) { 16 envcfg, err := st.ModelConfig() 17 if err != nil { 18 return nil, errors.Trace(err) 19 } 20 env, err := environs.New(envcfg) 21 return env, errors.Trace(err) 22 }