Skip to content

Commit

Permalink
fix: removed defaultfunc from 'organization' to supress useless warni…
Browse files Browse the repository at this point in the history
…ngs (scaleway#157)
  • Loading branch information
DenBeke authored and jerome-quere committed Jun 11, 2019
1 parent 77de883 commit 7fe2396
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions scaleway/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,22 @@ func Provider() terraform.ResourceProvider {
if projectID, exist := scwConfig.GetDefaultProjectID(); exist {
return projectID, nil
}
// No error is returned here to allow user to use deprecated `organization`.

// Keep the deprecated behavior of 'organization'.
if organization := os.Getenv("SCALEWAY_ORGANIZATION"); organization != "" {
l.Warningf("SCALEWAY_ORGANIZATION is deprecated, please use SCW_DEFAULT_PROJECT_ID instead")
return organization, nil
}
if path, err := homedir.Expand("~/.scwrc"); err == nil {
_, scwOrganization, err := readDeprecatedScalewayConfig(path)
if err != nil {
// No error is returned here to allow user to use `project_id`.
l.Errorf("cannot parse deprecated config file: %s", err)
return nil, nil
}
return scwOrganization, nil
}
// No error is returned here to allow user to use `project_id`.
return nil, nil
}),
},
Expand Down Expand Up @@ -130,24 +145,6 @@ func Provider() terraform.ResourceProvider {
Type: schema.TypeString,
Optional: true, // To allow user to use `project_id`.
Deprecated: "Use `project_id` instead.",
DefaultFunc: schema.SchemaDefaultFunc(func() (interface{}, error) {
// Keep the deprecated behavior
if organization := os.Getenv("SCALEWAY_ORGANIZATION"); organization != "" {
l.Warningf("SCALEWAY_ORGANIZATION is deprecated, please use SCW_DEFAULT_PROJECT_ID instead")
return organization, nil
}
if path, err := homedir.Expand("~/.scwrc"); err == nil {
_, scwOrganization, err := readDeprecatedScalewayConfig(path)
if err != nil {
// No error is returned here to allow user to use `project_id`.
l.Errorf("cannot parse deprecated config file: %s", err)
return nil, nil
}
return scwOrganization, nil
}
// No error is returned here to allow user to use `project_id`.
return nil, nil
}),
},
},

Expand Down

0 comments on commit 7fe2396

Please sign in to comment.