diff --git a/builder/scaleway/builder_test.go b/builder/scaleway/builder_test.go index a1a0fccc3..1d42ed7e9 100644 --- a/builder/scaleway/builder_test.go +++ b/builder/scaleway/builder_test.go @@ -9,7 +9,7 @@ import ( func testConfig() map[string]interface{} { return map[string]interface{}{ - "organization_id": "foo", + "api_access_key": "foo", "api_token": "bar", "region": "ams1", "commercial_type": "START1-S", diff --git a/builder/scaleway/config.go b/builder/scaleway/config.go index 45a8217e8..f7a90c55a 100644 --- a/builder/scaleway/config.go +++ b/builder/scaleway/config.go @@ -3,7 +3,6 @@ package scaleway import ( "errors" "fmt" - "log" "os" "github.com/hashicorp/packer/common" @@ -21,7 +20,7 @@ type Config struct { Comm communicator.Config `mapstructure:",squash"` Token string `mapstructure:"api_token"` - Organization string `mapstructure:"organization_id"` + Organization string `mapstructure:"api_access_key"` Region string `mapstructure:"region"` Image string `mapstructure:"image"` @@ -58,12 +57,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) { c.UserAgent = useragent.String() if c.Organization == "" { - if os.Getenv("SCALEWAY_ORGANIZATION") != "" { - c.Organization = os.Getenv("SCALEWAY_ORGANIZATION") - } else { - log.Printf("Deprecation warning: Use SCALEWAY_ORGANIZATION environment variable and organization_id argument instead of api_access_key argument and SCALEWAY_API_ACCESS_KEY environment variable.") - c.Organization = os.Getenv("SCALEWAY_API_ACCESS_KEY") - } + c.Organization = os.Getenv("SCALEWAY_API_ACCESS_KEY") } if c.Token == "" { diff --git a/fix/fixer.go b/fix/fixer.go index 41dd8e9fd..03c9f9948 100644 --- a/fix/fixer.go +++ b/fix/fixer.go @@ -30,7 +30,6 @@ func init() { "parallels-deprecations": new(FixerParallelsDeprecations), "sshkeypath": new(FixerSSHKeyPath), "sshdisableagent": new(FixerSSHDisableAgent), - "scaleway-access-key": new(FixerScalewayAccessKey), "manifest-filename": new(FixerManifestFilename), "amazon-shutdown_behavior": new(FixerAmazonShutdownBehavior), "amazon-enhanced-networking": new(FixerAmazonEnhancedNetworking), @@ -53,7 +52,6 @@ func init() { "parallels-deprecations", "sshkeypath", "sshdisableagent", - "scaleway-access-key", "manifest-filename", "amazon-shutdown_behavior", "amazon-enhanced-networking", diff --git a/fix/fixer_scaleway_access_key.go b/fix/fixer_scaleway_access_key.go deleted file mode 100644 index d134ac32d..000000000 --- a/fix/fixer_scaleway_access_key.go +++ /dev/null @@ -1,54 +0,0 @@ -package fix - -import ( - "github.com/mitchellh/mapstructure" -) - -// FixerScalewayAccessKey changes the "access_key" of a template -// to "organization_id". -type FixerScalewayAccessKey struct{} - -func (FixerScalewayAccessKey) Fix(input map[string]interface{}) (map[string]interface{}, error) { - // The type we'll decode into; we only care about builders - type template struct { - Builders []map[string]interface{} - } - - // Decode the input into our structure, if we can - var tpl template - if err := mapstructure.Decode(input, &tpl); err != nil { - return nil, err - } - - for _, builder := range tpl.Builders { - if builder["type"] != "scaleway" { - continue - } - - keyRaw, ok := builder["access_key"] - if !ok { - continue - } - - accessKey, ok := keyRaw.(string) - if !ok { - continue - } - - // only assign to organization_id if it doesn't - // already exist; otherwise we'll just ignore access_key - _, organizationIdIncluded := builder["organization_id"] - if !organizationIdIncluded { - builder["organization_id"] = accessKey - } - - delete(builder, "access_key") - } - - input["builders"] = tpl.Builders - return input, nil -} - -func (FixerScalewayAccessKey) Synopsis() string { - return `Updates builders using "access_key" to use "organization_id"` -} diff --git a/fix/fixer_scaleway_access_key_test.go b/fix/fixer_scaleway_access_key_test.go deleted file mode 100644 index 61ff7eed8..000000000 --- a/fix/fixer_scaleway_access_key_test.go +++ /dev/null @@ -1,89 +0,0 @@ -package fix - -import ( - "reflect" - "testing" -) - -func TestFixerScalewayAccessKey_Fix_Impl(t *testing.T) { - var _ Fixer = new(FixerScalewayAccessKey) -} - -func TestFixerScalewayAccessKey_Fix(t *testing.T) { - cases := []struct { - Input map[string]interface{} - Expected map[string]interface{} - }{ - // No key_path field - { - Input: map[string]interface{}{ - "type": "scaleway", - }, - - Expected: map[string]interface{}{ - "type": "scaleway", - }, - }, - - // organization_id without access_key - { - Input: map[string]interface{}{ - "type": "scaleway", - "organization_id": "0000", - }, - - Expected: map[string]interface{}{ - "type": "scaleway", - "organization_id": "0000", - }, - }, - - // access_key without organization_id - { - Input: map[string]interface{}{ - "type": "scaleway", - "access_key": "1111", - }, - - Expected: map[string]interface{}{ - "type": "scaleway", - "organization_id": "1111", - }, - }, - - // access_key and organization_id - { - Input: map[string]interface{}{ - "type": "scaleway", - "access_key": "2222", - "organization_id": "3333", - }, - - Expected: map[string]interface{}{ - "type": "scaleway", - "organization_id": "3333", - }, - }, - } - - for _, tc := range cases { - var f FixerScalewayAccessKey - - input := map[string]interface{}{ - "builders": []map[string]interface{}{tc.Input}, - } - - expected := map[string]interface{}{ - "builders": []map[string]interface{}{tc.Expected}, - } - - output, err := f.Fix(input) - if err != nil { - t.Fatalf("err: %s", err) - } - - if !reflect.DeepEqual(output, expected) { - t.Fatalf("unexpected: %#v\nexpected: %#v\n", output, expected) - } - } -} diff --git a/website/source/docs/builders/scaleway.html.md b/website/source/docs/builders/scaleway.html.md index fcf1c9008..e2ce32676 100644 --- a/website/source/docs/builders/scaleway.html.md +++ b/website/source/docs/builders/scaleway.html.md @@ -35,12 +35,11 @@ builder. ### Required: -- `organization_id` (string) - The organization id to use to identify your - organization. It can also be specified via environment variable - `SCALEWAY_ORGANIZATION`. Your organization id is available in the - ["Account" section](https://cloud.scaleway.com/#/account) of the +- `api_access_key` (string) - The organization access key to use to identify + your organization. It can also be specified via environment variable + `SCALEWAY_API_ACCESS_KEY`. Your access key is available in the + ["Credentials" section](https://cloud.scaleway.com/#/credentials) of the control panel. - Previously named: `api_access_key` with environment variable: `SCALEWAY_API_ACCESS_KEY` - `api_token` (string) - The token to use to authenticate with your account. It can also be specified via environment variable `SCALEWAY_API_TOKEN`. You @@ -87,7 +86,7 @@ access tokens: ``` json { "type": "scaleway", - "organization_id": "YOUR ORGANIZATION ID", + "api_access_key": "YOUR API ACCESS KEY", "api_token": "YOUR TOKEN", "image": "UUID OF THE BASE IMAGE", "region": "par1",