Allow token and organization id to be passed via env vars

This commit is contained in:
Edouard BONLIEU 2017-04-06 16:37:06 +02:00 committed by Matthew Hooker
parent e46108298c
commit 9b611af7e6
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
2 changed files with 13 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package scaleway
import (
"errors"
"fmt"
"os"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/common/uuid"
@ -51,6 +52,14 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
c.UserAgent = "Packer - Scaleway builder"
if c.Organization == "" {
c.Organization = os.Getenv("SCALEWAY_API_ORGANIZATION")
}
if c.Token == "" {
c.Token = os.Getenv("SCALEWAY_API_TOKEN")
}
if c.SnapshotName == "" {
def, err := interpolate.Render("packer-{{timestamp}}", nil)
if err != nil {

View File

@ -37,8 +37,12 @@ builder.
### Required:
- `api_organization` (string) - The organization ID to use to access your account.
It can also be specified via
environment variable `SCALEWAY_API_ORGANIZATION`.
- `api_token` (string) - The organization TOKEN to use to access your account.
It can also be specified via
environment variable `SCALEWAY_API_TOKEN`.
- `image` (string) - The UUID of the base image to use. This is the
image that will be used to launch a new server and provision it. See