Merge pull request #382 from justinsb/specify_openstack_project
builder/openstack: allow project to be specified
This commit is contained in:
commit
c4ca558174
|
@ -11,6 +11,7 @@ import (
|
||||||
type AccessConfig struct {
|
type AccessConfig struct {
|
||||||
Username string `mapstructure:"username"`
|
Username string `mapstructure:"username"`
|
||||||
Password string `mapstructure:"password"`
|
Password string `mapstructure:"password"`
|
||||||
|
Project string `mapstructure:"project"`
|
||||||
Provider string `mapstructure:"provider"`
|
Provider string `mapstructure:"provider"`
|
||||||
RawRegion string `mapstructure:"region"`
|
RawRegion string `mapstructure:"region"`
|
||||||
}
|
}
|
||||||
|
@ -20,6 +21,7 @@ type AccessConfig struct {
|
||||||
func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) {
|
func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) {
|
||||||
username := c.Username
|
username := c.Username
|
||||||
password := c.Password
|
password := c.Password
|
||||||
|
project := c.Project
|
||||||
provider := c.Provider
|
provider := c.Provider
|
||||||
|
|
||||||
if username == "" {
|
if username == "" {
|
||||||
|
@ -28,6 +30,9 @@ func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) {
|
||||||
if password == "" {
|
if password == "" {
|
||||||
password = os.Getenv("SDK_PASSWORD")
|
password = os.Getenv("SDK_PASSWORD")
|
||||||
}
|
}
|
||||||
|
if project == "" {
|
||||||
|
project = os.Getenv("SDK_PROJECT")
|
||||||
|
}
|
||||||
if provider == "" {
|
if provider == "" {
|
||||||
provider = os.Getenv("SDK_PROVIDER")
|
provider = os.Getenv("SDK_PROVIDER")
|
||||||
}
|
}
|
||||||
|
@ -38,6 +43,10 @@ func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) {
|
||||||
AllowReauth: true,
|
AllowReauth: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if project != "" {
|
||||||
|
authoptions.TenantName = project
|
||||||
|
}
|
||||||
|
|
||||||
return gophercloud.Authenticate(provider, authoptions)
|
return gophercloud.Authenticate(provider, authoptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue