Merge pull request #5124 from rickard-von-essen/cloudstack-env

cloudstack: Allow reading api_url, api_key, and secret_key from env vars
This commit is contained in:
Rickard von Essen 2017-07-14 10:10:27 +02:00 committed by GitHub
commit 12525507a7
2 changed files with 22 additions and 1 deletions

View File

@ -79,6 +79,21 @@ func NewConfig(raws ...interface{}) (*Config, error) {
var errs *packer.MultiError
// Set some defaults.
if c.APIURL == "" {
// Default to environment variable for api_url, if it exists
c.APIURL = os.Getenv("CLOUDSTACK_API_URL")
}
if c.APIKey == "" {
// Default to environment variable for api_key, if it exists
c.APIKey = os.Getenv("CLOUDSTACK_API_KEY")
}
if c.SecretKey == "" {
// Default to environment variable for secret_key, if it exists
c.SecretKey = os.Getenv("CLOUDSTACK_SECRET_KEY")
}
if c.AsyncTimeout == 0 {
c.AsyncTimeout = 30 * time.Minute
}

View File

@ -34,8 +34,12 @@ builder.
### Required:
- `api_url` (string) - The CloudStack API endpoint we will connect to.
It can also be specified via environment variable `CLOUDSTACK_API_URL`,
if set.
- `api_key` (string) - The API key used to sign all API requests.
- `api_key` (string) - The API key used to sign all API requests. It
can also be specified via environment variable `CLOUDSTACK_API_KEY`,
if set.
- `cidr_list` (array) - List of CIDR's that will have access to the new
instance. This is needed in order for any provisioners to be able to
@ -49,6 +53,8 @@ builder.
to.
- `secret_key` (string) - The secret key used to sign all API requests.
It can also be specified via environment variable `CLOUDSTACK_SECRET_KEY`,
if set.
- `service_offering` (string) - The name or ID of the service offering used
for the instance.