@@ -171,22 +171,25 @@ type OpenStack struct {
171171// Config is used to read and store information from the cloud configuration file
172172type Config struct {
173173 Global struct {
174- AuthURL string `gcfg:"auth-url"`
175- Username string
176- UserID string `gcfg:"user-id"`
177- Password string
178- TenantID string `gcfg:"tenant-id"`
179- TenantName string `gcfg:"tenant-name"`
180- TrustID string `gcfg:"trust-id"`
181- DomainID string `gcfg:"domain-id"`
182- DomainName string `gcfg:"domain-name"`
183- TenantDomainID string `gcfg:"tenant-domain-id"`
184- TenantDomainName string `gcfg:"tenant-domain-name"`
185- Region string
186- CAFile string `gcfg:"ca-file"`
187- UseClouds bool `gcfg:"use-clouds"`
188- CloudsFile string `gcfg:"clouds-file,omitempty"`
189- Cloud string `gcfg:"cloud,omitempty"`
174+ AuthURL string `gcfg:"auth-url"`
175+ Username string
176+ UserID string `gcfg:"user-id"`
177+ Password string
178+ TenantID string `gcfg:"tenant-id"`
179+ TenantName string `gcfg:"tenant-name"`
180+ TrustID string `gcfg:"trust-id"`
181+ DomainID string `gcfg:"domain-id"`
182+ DomainName string `gcfg:"domain-name"`
183+ TenantDomainID string `gcfg:"tenant-domain-id"`
184+ TenantDomainName string `gcfg:"tenant-domain-name"`
185+ Region string
186+ CAFile string `gcfg:"ca-file"`
187+ UseClouds bool `gcfg:"use-clouds"`
188+ CloudsFile string `gcfg:"clouds-file,omitempty"`
189+ Cloud string `gcfg:"cloud,omitempty"`
190+ ApplicationCredentialID string `gcfg:"application-credential-id"`
191+ ApplicationCredentialName string `gcfg:"application-credential-name"`
192+ ApplicationCredentialSecret string `gcfg:"application-credential-secret"`
190193 }
191194 LoadBalancer LoadBalancerOpts
192195 LoadBalancerClass map [string ]* LBClass
@@ -228,14 +231,17 @@ func init() {
228231
229232func (cfg Config ) toAuthOptions () gophercloud.AuthOptions {
230233 return gophercloud.AuthOptions {
231- IdentityEndpoint : cfg .Global .AuthURL ,
232- Username : cfg .Global .Username ,
233- UserID : cfg .Global .UserID ,
234- Password : cfg .Global .Password ,
235- TenantID : cfg .Global .TenantID ,
236- TenantName : cfg .Global .TenantName ,
237- DomainID : cfg .Global .DomainID ,
238- DomainName : cfg .Global .DomainName ,
234+ IdentityEndpoint : cfg .Global .AuthURL ,
235+ Username : cfg .Global .Username ,
236+ UserID : cfg .Global .UserID ,
237+ Password : cfg .Global .Password ,
238+ TenantID : cfg .Global .TenantID ,
239+ TenantName : cfg .Global .TenantName ,
240+ DomainID : cfg .Global .DomainID ,
241+ DomainName : cfg .Global .DomainName ,
242+ ApplicationCredentialID : cfg .Global .ApplicationCredentialID ,
243+ ApplicationCredentialName : cfg .Global .ApplicationCredentialName ,
244+ ApplicationCredentialSecret : cfg .Global .ApplicationCredentialSecret ,
239245
240246 // Persistent service, so we need to be able to renew tokens.
241247 AllowReauth : true ,
@@ -289,6 +295,9 @@ func configFromEnv() (cfg Config, ok bool) {
289295 cfg .Global .Region = os .Getenv ("OS_REGION_NAME" )
290296 cfg .Global .UserID = os .Getenv ("OS_USER_ID" )
291297 cfg .Global .TrustID = os .Getenv ("OS_TRUST_ID" )
298+ cfg .Global .ApplicationCredentialID = os .Getenv ("OS_APPLICATION_CREDENTIAL_ID" )
299+ cfg .Global .ApplicationCredentialName = os .Getenv ("OS_APPLICATION_CREDENTIAL_NAME" )
300+ cfg .Global .ApplicationCredentialSecret = os .Getenv ("OS_APPLICATION_CREDENTIAL_SECRET" )
292301
293302 cfg .Global .TenantID = os .Getenv ("OS_TENANT_ID" )
294303 if cfg .Global .TenantID == "" {
@@ -312,8 +321,8 @@ func configFromEnv() (cfg Config, ok bool) {
312321 cfg .Global .TenantDomainName = os .Getenv ("OS_PROJECT_DOMAIN_NAME" )
313322
314323 ok = cfg .Global .AuthURL != "" &&
315- cfg .Global .Username != "" &&
316- cfg .Global .Password != "" &&
324+ (( cfg .Global .Username != "" && cfg . Global . Password != "" ) ||
325+ (( cfg .Global .ApplicationCredentialID != "" || cfg . Global . ApplicationCredentialName != "" ) && cfg . Global . ApplicationCredentialSecret != "" )) &&
317326 (cfg .Global .TenantID != "" || cfg .Global .TenantName != "" ||
318327 cfg .Global .DomainID != "" || cfg .Global .DomainName != "" ||
319328 cfg .Global .Region != "" || cfg .Global .UserID != "" ||
0 commit comments