github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/provider/common/provider.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package common 5 6 import ( 7 "github.com/juju/errors" 8 9 "github.com/juju/juju/environs" 10 ) 11 12 // DefaultProvider exposes the various common implementations found in 13 // this package as methods of a single type. This facilitates treating 14 // the implementations as a bundle, e.g. satisfying interfaces. 15 type DefaultProvider struct { 16 // Env is the Juju environment that methods target. 17 Env environs.Environ 18 } 19 20 // BootstrapEnv bootstraps the Juju environment. 21 func (dp DefaultProvider) BootstrapEnv(ctx environs.BootstrapContext, args environs.BootstrapParams) (*environs.BootstrapResult, error) { 22 result, err := Bootstrap(ctx, dp.Env, args) 23 if err != nil { 24 return nil, errors.Trace(err) 25 } 26 return result, nil 27 } 28 29 // DestroyEnv destroys the Juju environment. 30 func (dp DefaultProvider) DestroyEnv() error { 31 if err := Destroy(dp.Env); err != nil { 32 return errors.Trace(err) 33 } 34 return nil 35 }