@ -6,8 +6,6 @@ package scaleway
import (
"errors"
"fmt"
"log"
"os"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/common/uuid"
@ -116,51 +114,39 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
c . UserAgent = useragent . String ( )
// Deprecated variables
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" )
}
}
if c . Organization != "" {
warnings = append ( warnings , "organization_id is deprecated in favor of project_id" )
c . ProjectID = c . Organization
}
if c . Token == "" {
c . Token = os . Getenv ( "SCALEWAY_API_TOKEN" )
configFile , err := scw . LoadConfig ( )
// If the config file do not exist, don't return an error as we may find config in ENV or flags.
if _ , isNotFoundError := err . ( * scw . ConfigFileNotFoundError ) ; isNotFoundError {
configFile = & scw . Config { }
} else if err != nil {
return nil , err
}
if c . Token != "" {
warnings = append ( warnings , "token is deprecated in favor of secret_key" )
c . SecretKey = c . Token
activeProfile , err := configFile . GetActiveProfile ( )
if err != nil {
return nil , err
}
if c . Region != "" {
warnings = append ( warnings , "region is deprecated in favor of zone" )
c . Zone = c . Region
}
envProfile := scw . LoadEnvProfile ( )
profile := scw . MergeProfiles ( activeProfile , envProfile )
if c . AccessKey == "" {
c . AccessKey = os . Getenv ( scw . ScwAccessKeyEnv )
c . AccessKey = * profile . AccessKey
}
if c . SecretKey == "" {
c . SecretKey = os . Getenv ( scw . ScwSecretKeyEnv )
c . SecretKey = * profile . SecretKey
}
if c . ProjectID == "" {
c . ProjectID = os . Getenv ( scw . ScwDefaultProjectIDEnv )
c . ProjectID = * profile . DefaultProjectID
}
if c . Zone == "" {
c . Zone = os . Getenv ( scw . ScwDefaultZoneEnv )
c . Zone = * profile . DefaultZone
}
if c . APIURL == "" {
c . APIURL = os . Getenv ( scw . ScwAPIURLEnv )
c . APIURL = * profile . APIURL
}
if c . SnapshotName == "" {