File tree Expand file tree Collapse file tree 5 files changed +21
-12
lines changed Expand file tree Collapse file tree 5 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package regional
33import (
44 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
55 "github.com/scaleway/scaleway-sdk-go/scw"
6- "github.com/scaleway/terraform-provider-scaleway/v2/internal/locality "
6+ "github.com/scaleway/terraform-provider-scaleway/v2/internal/verify "
77)
88
99// ComputedSchema returns a standard schema for a region
@@ -32,6 +32,6 @@ func Schema() *schema.Schema {
3232 Optional : true ,
3333 ForceNew : true ,
3434 Computed : true ,
35- ValidateDiagFunc : locality .ValidateStringInSliceWithWarning (allRegions (), "region" ),
35+ ValidateDiagFunc : verify .ValidateStringInSliceWithWarning (allRegions (), "region" ),
3636 }
3737}
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package zonal
33import (
44 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
55 "github.com/scaleway/scaleway-sdk-go/scw"
6- "github.com/scaleway/terraform-provider-scaleway/v2/internal/locality "
6+ "github.com/scaleway/terraform-provider-scaleway/v2/internal/verify "
77)
88
99// ComputedSchema returns a standard schema for a zone
@@ -32,6 +32,6 @@ func Schema() *schema.Schema {
3232 Optional : true ,
3333 ForceNew : true ,
3434 Computed : true ,
35- ValidateDiagFunc : locality .ValidateStringInSliceWithWarning (AllZones (), "zone" ),
35+ ValidateDiagFunc : verify .ValidateStringInSliceWithWarning (AllZones (), "zone" ),
3636 }
3737}
Original file line number Diff line number Diff line change @@ -64,11 +64,20 @@ func ResourceCluster() *schema.Resource {
6464 Description : "The version of the cluster" ,
6565 },
6666 "cni" : {
67- Type : schema .TypeString ,
68- Required : true ,
69- ForceNew : true ,
70- Description : "The CNI plugin of the cluster" ,
71- ValidateDiagFunc : verify .ValidateEnum [k8s.CNI ](),
67+ Type : schema .TypeString ,
68+ Required : true ,
69+ ForceNew : true ,
70+ Description : "The CNI plugin of the cluster" ,
71+ ValidateDiagFunc : func (i any , p cty.Path ) diag.Diagnostics {
72+ var cniValues []k8s.CNI
73+
74+ cniStringValues := []string (nil )
75+ for _ , cniValue := range cniValues {
76+ cniStringValues = append (cniStringValues , cniValue .String ())
77+ }
78+
79+ return verify .ValidateStringInSliceWithWarning (cniStringValues , "cni" )(i , p )
80+ },
7281 },
7382 "tags" : {
7483 Type : schema .TypeList ,
Original file line number Diff line number Diff line change @@ -10,12 +10,12 @@ import (
1010 "github.com/scaleway/scaleway-sdk-go/api/vpc/v2"
1111 "github.com/scaleway/scaleway-sdk-go/scw"
1212 "github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors"
13- "github.com/scaleway/terraform-provider-scaleway/v2/internal/locality"
1413 "github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/regional"
1514 "github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/zonal"
1615 "github.com/scaleway/terraform-provider-scaleway/v2/internal/meta"
1716 "github.com/scaleway/terraform-provider-scaleway/v2/internal/services/account"
1817 "github.com/scaleway/terraform-provider-scaleway/v2/internal/types"
18+ "github.com/scaleway/terraform-provider-scaleway/v2/internal/verify"
1919)
2020
2121func ResourcePrivateNetwork () * schema.Resource {
@@ -172,7 +172,7 @@ func ResourcePrivateNetwork() *schema.Resource {
172172 Optional : true ,
173173 Computed : true ,
174174 Deprecated : "This field is deprecated and will be removed in the next major version, please use `region` instead" ,
175- ValidateDiagFunc : locality .ValidateStringInSliceWithWarning (zonal .AllZones (), "zone" ),
175+ ValidateDiagFunc : verify .ValidateStringInSliceWithWarning (zonal .AllZones (), "zone" ),
176176 },
177177 "region" : regional .Schema (),
178178 // Computed elements
Original file line number Diff line number Diff line change 1- package locality
1+ package verify
22
33import (
44 "github.com/hashicorp/go-cty/cty"
You can’t perform that action at this time.
0 commit comments