Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore case on instance types #312

Merged
merged 3 commits into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions scaleway/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,3 +558,17 @@ func validateDuration() schema.SchemaValidateFunc {
return nil, nil
}
}

func diffSuppressFuncIgnoreCase(k, old, new string, d *schema.ResourceData) bool {
if strings.ToLower(old) == strings.ToLower(new) {
return true
}
return false
}

func diffSuppressFuncIgnoreCaseAndHyphen(k, old, new string, d *schema.ResourceData) bool {
if strings.Replace(strings.ToLower(old), "-", "_", -1) == strings.Replace(strings.ToLower(new), "-", "_", -1) {
return true
}
return false
}
9 changes: 5 additions & 4 deletions scaleway/resource_instance_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ func resourceScalewayInstanceServer() *schema.Resource {
Description: "The UUID or the label of the base image used by the server",
},
"type": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The instance type of the server", // TODO: link to scaleway pricing in the doc
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The instance type of the server", // TODO: link to scaleway pricing in the doc
DiffSuppressFunc: diffSuppressFuncIgnoreCase,
},
"tags": {
Type: schema.TypeList,
Expand Down
9 changes: 5 additions & 4 deletions scaleway/resource_k8s_cluster_beta.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ func resourceScalewayK8SClusterBeta() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"node_type": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "Server type of the default pool servers",
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "Server type of the default pool servers",
DiffSuppressFunc: diffSuppressFuncIgnoreCaseAndHyphen,
},
"autoscaling": {
Type: schema.TypeBool,
Expand Down
9 changes: 5 additions & 4 deletions scaleway/resource_k8s_pool_beta.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ func resourceScalewayK8SPoolBeta() *schema.Resource {
Description: "The name of the cluster",
},
"node_type": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "Server type of the pool servers",
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "Server type of the pool servers",
DiffSuppressFunc: diffSuppressFuncIgnoreCaseAndHyphen,
},
"autoscaling": {
Type: schema.TypeBool,
Expand Down