Commit e7d7f9bb authored by Devin Carlen's avatar Devin Carlen

Add OpenStack API key support

parent 828d7ebd
...@@ -15,6 +15,7 @@ import ( ...@@ -15,6 +15,7 @@ import (
type AccessConfig struct { type AccessConfig struct {
Username string `mapstructure:"username"` Username string `mapstructure:"username"`
Password string `mapstructure:"password"` Password string `mapstructure:"password"`
ApiKey string `mapstructure:"api_key"`
Project string `mapstructure:"project"` Project string `mapstructure:"project"`
Provider string `mapstructure:"provider"` Provider string `mapstructure:"provider"`
RawRegion string `mapstructure:"region"` RawRegion string `mapstructure:"region"`
...@@ -26,6 +27,7 @@ type AccessConfig struct { ...@@ -26,6 +27,7 @@ type AccessConfig struct {
func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) { func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) {
c.Username = common.CoalesceVals(c.Username, os.Getenv("SDK_USERNAME"), os.Getenv("OS_USERNAME")) c.Username = common.CoalesceVals(c.Username, os.Getenv("SDK_USERNAME"), os.Getenv("OS_USERNAME"))
c.Password = common.CoalesceVals(c.Password, os.Getenv("SDK_PASSWORD"), os.Getenv("OS_PASSWORD")) c.Password = common.CoalesceVals(c.Password, os.Getenv("SDK_PASSWORD"), os.Getenv("OS_PASSWORD"))
c.ApiKey = common.CoalesceVals(c.ApiKey, os.Getenv("SDK_API_KEY"))
c.Project = common.CoalesceVals(c.Project, os.Getenv("SDK_PROJECT"), os.Getenv("OS_TENANT_NAME")) c.Project = common.CoalesceVals(c.Project, os.Getenv("SDK_PROJECT"), os.Getenv("OS_TENANT_NAME"))
c.Provider = common.CoalesceVals(c.Provider, os.Getenv("SDK_PROVIDER"), os.Getenv("OS_AUTH_URL")) c.Provider = common.CoalesceVals(c.Provider, os.Getenv("SDK_PROVIDER"), os.Getenv("OS_AUTH_URL"))
c.RawRegion = common.CoalesceVals(c.RawRegion, os.Getenv("SDK_REGION"), os.Getenv("OS_REGION_NAME")) c.RawRegion = common.CoalesceVals(c.RawRegion, os.Getenv("SDK_REGION"), os.Getenv("OS_REGION_NAME"))
...@@ -40,6 +42,7 @@ func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) { ...@@ -40,6 +42,7 @@ func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) {
authoptions := gophercloud.AuthOptions{ authoptions := gophercloud.AuthOptions{
Username: c.Username, Username: c.Username,
Password: c.Password, Password: c.Password,
ApiKey: c.ApiKey,
AllowReauth: true, AllowReauth: true,
} }
...@@ -79,6 +82,7 @@ func (c *AccessConfig) Prepare(t *packer.ConfigTemplate) []error { ...@@ -79,6 +82,7 @@ func (c *AccessConfig) Prepare(t *packer.ConfigTemplate) []error {
templates := map[string]*string{ templates := map[string]*string{
"username": &c.Username, "username": &c.Username,
"password": &c.Password, "password": &c.Password,
"apiKey": &c.ApiKey,
"provider": &c.Provider, "provider": &c.Provider,
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment