@@ -77,6 +77,10 @@ type Env interface {
7777type env struct {
7878 prefix string
7979 cloud * Cloud
80+
81+ // Unstable make env ignore lazy cloud loading and
82+ // refresh it every time it's requested
83+ Unstable bool
8084}
8185
8286// NewEnv create new <prefixed> env loader
@@ -433,21 +437,21 @@ func mergeWithVendors(cloudConfig *Config, vendorPath string) *Config {
433437
434438// Cloud get cloud merged from configuration and env variables
435439func (e * env ) Cloud () (* Cloud , error ) {
436- if e .cloud != nil {
437- return e . cloud , nil
438- }
439- config , err := e . loadOpenstackConfig ( )
440- if err != nil {
441- return nil , fmt . Errorf ( "failed to authenticate client" )
442- }
443- cloud , err := mergeClouds (
444- config . Clouds [ config . DefaultCloud ],
445- e . cloudFromEnv (),
446- )
447- if err != nil {
448- return nil , fmt . Errorf ( "failed to merge cloud %s with env vars: %s" , config . DefaultCloud , err )
440+ if e .cloud == nil || e . Unstable {
441+ config , err := e . loadOpenstackConfig ()
442+ if err != nil {
443+ return nil , fmt . Errorf ( "failed to authenticate client: %s" , err )
444+ }
445+ cloud , err := mergeClouds (
446+ config . Clouds [ config . DefaultCloud ],
447+ e . cloudFromEnv (),
448+ )
449+ if err != nil {
450+ return nil , fmt . Errorf ( "failed to merge cloud %s with env vars: %s" , config . DefaultCloud , err )
451+ }
452+ e . cloud = cloud
449453 }
450- return cloud , err
454+ return e . cloud , nil
451455}
452456
453457// LoadCloudConfig utilize all existing cloud configurations to create cloud configuration:
0 commit comments