From 9b611af7e6dd6e32b823751b47bbc8ea5593e769 Mon Sep 17 00:00:00 2001 From: Edouard BONLIEU Date: Thu, 6 Apr 2017 16:37:06 +0200 Subject: [PATCH] Allow token and organization id to be passed via env vars --- builder/scaleway/config.go | 9 +++++++++ website/source/docs/builders/scaleway.html.md | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/builder/scaleway/config.go b/builder/scaleway/config.go index eb9575140..040b39891 100644 --- a/builder/scaleway/config.go +++ b/builder/scaleway/config.go @@ -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 { diff --git a/website/source/docs/builders/scaleway.html.md b/website/source/docs/builders/scaleway.html.md index 01852c70c..1df9dd6ec 100644 --- a/website/source/docs/builders/scaleway.html.md +++ b/website/source/docs/builders/scaleway.html.md @@ -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