|
|
|
|
@ -11,6 +11,7 @@ import (
|
|
|
|
|
type AccessConfig struct {
|
|
|
|
|
Username string `mapstructure:"username"`
|
|
|
|
|
Password string `mapstructure:"password"`
|
|
|
|
|
Project string `mapstructure:"project"`
|
|
|
|
|
Provider string `mapstructure:"provider"`
|
|
|
|
|
RawRegion string `mapstructure:"region"`
|
|
|
|
|
}
|
|
|
|
|
@ -20,6 +21,7 @@ type AccessConfig struct {
|
|
|
|
|
func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) {
|
|
|
|
|
username := c.Username
|
|
|
|
|
password := c.Password
|
|
|
|
|
project := c.Project
|
|
|
|
|
provider := c.Provider
|
|
|
|
|
|
|
|
|
|
if username == "" {
|
|
|
|
|
@ -28,6 +30,9 @@ func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) {
|
|
|
|
|
if password == "" {
|
|
|
|
|
password = os.Getenv("SDK_PASSWORD")
|
|
|
|
|
}
|
|
|
|
|
if project == "" {
|
|
|
|
|
project = os.Getenv("SDK_PROJECT")
|
|
|
|
|
}
|
|
|
|
|
if provider == "" {
|
|
|
|
|
provider = os.Getenv("SDK_PROVIDER")
|
|
|
|
|
}
|
|
|
|
|
@ -35,6 +40,7 @@ func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) {
|
|
|
|
|
authoptions := gophercloud.AuthOptions{
|
|
|
|
|
Username: username,
|
|
|
|
|
Password: password,
|
|
|
|
|
TenantName: project,
|
|
|
|
|
AllowReauth: true,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|