Skip to content

Commit 32441ed

Browse files
committed
Fix
1 parent 0abaa5d commit 32441ed

File tree

16 files changed

+836
-2997
lines changed

16 files changed

+836
-2997
lines changed

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ require (
2121
github.com/hashicorp/go-cty v1.5.0
2222
github.com/hashicorp/go-multierror v1.1.1
2323
github.com/hashicorp/go-retryablehttp v0.7.8
24-
github.com/hashicorp/terraform-plugin-framework v1.16.0
24+
github.com/hashicorp/terraform-plugin-framework v1.16.1
2525
github.com/hashicorp/terraform-plugin-go v0.29.0
2626
github.com/hashicorp/terraform-plugin-log v0.9.0
2727
github.com/hashicorp/terraform-plugin-mux v0.21.0
@@ -102,6 +102,9 @@ require (
102102
github.com/hashicorp/terraform-exec v0.23.1 // indirect
103103
github.com/hashicorp/terraform-json v0.27.1 // indirect
104104
github.com/hashicorp/terraform-plugin-docs v0.23.0 // indirect
105+
github.com/hashicorp/terraform-plugin-framework-timeouts v0.6.0 // indirect
106+
github.com/hashicorp/terraform-plugin-framework-timetypes v0.5.0 // indirect
107+
github.com/hashicorp/terraform-plugin-framework-validators v0.18.0 // indirect
105108
github.com/hashicorp/terraform-registry-address v0.4.0 // indirect
106109
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
107110
github.com/hashicorp/yamux v0.1.2 // indirect

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,14 @@ github.com/hashicorp/terraform-plugin-docs v0.23.0 h1:sipnfD4/9EJBg9zekym+s1H6qm
326326
github.com/hashicorp/terraform-plugin-docs v0.23.0/go.mod h1:J4b5AtMRgJlDrwCQz+G4hKABgHY5m56PnsRmdAzBwW8=
327327
github.com/hashicorp/terraform-plugin-framework v1.16.0 h1:tP0f+yJg0Z672e7levixDe5EpWwrTrNryPM9kDMYIpE=
328328
github.com/hashicorp/terraform-plugin-framework v1.16.0/go.mod h1:0xFOxLy5lRzDTayc4dzK/FakIgBhNf/lC4499R9cV4Y=
329+
github.com/hashicorp/terraform-plugin-framework v1.16.1 h1:1+zwFm3MEqd/0K3YBB2v9u9DtyYHyEuhVOfeIXbteWA=
330+
github.com/hashicorp/terraform-plugin-framework v1.16.1/go.mod h1:0xFOxLy5lRzDTayc4dzK/FakIgBhNf/lC4499R9cV4Y=
331+
github.com/hashicorp/terraform-plugin-framework-timeouts v0.6.0 h1:Vv16e7EW4nT9668IV0RhdpEmnLl0im7BZx6J+QMlUkg=
332+
github.com/hashicorp/terraform-plugin-framework-timeouts v0.6.0/go.mod h1:rpHo9hZLn4vEkvNL5xsSdLRdaDZKSinuc0xL+BdOpVA=
333+
github.com/hashicorp/terraform-plugin-framework-timetypes v0.5.0 h1:v3DapR8gsp3EM8fKMh6up9cJUFQ2iRaFsYLP8UJnCco=
334+
github.com/hashicorp/terraform-plugin-framework-timetypes v0.5.0/go.mod h1:c3PnGE9pHBDfdEVG9t1S1C9ia5LW+gkFR0CygXlM8ak=
335+
github.com/hashicorp/terraform-plugin-framework-validators v0.18.0 h1:OQnlOt98ua//rCw+QhBbSqfW3QbwtVrcdWeQN5gI3Hw=
336+
github.com/hashicorp/terraform-plugin-framework-validators v0.18.0/go.mod h1:lZvZvagw5hsJwuY7mAY6KUz45/U6fiDR0CzQAwWD0CA=
329337
github.com/hashicorp/terraform-plugin-go v0.29.0 h1:1nXKl/nSpaYIUBU1IG/EsDOX0vv+9JxAltQyDMpq5mU=
330338
github.com/hashicorp/terraform-plugin-go v0.29.0/go.mod h1:vYZbIyvxyy0FWSmDHChCqKvI40cFTDGSb3D8D70i9GM=
331339
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=

internal/locality/regional/schemas.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package regional
22

33
import (
4+
resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema"
45
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
56
"github.com/scaleway/scaleway-sdk-go/scw"
67
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality"
@@ -36,3 +37,10 @@ func Schema() *schema.Schema {
3637
DiffSuppressFunc: locality.SuppressSDKNullAssignment,
3738
}
3839
}
40+
41+
func ResourceSchema(description string) resourceSchema.Attribute {
42+
return resourceSchema.StringAttribute{
43+
Description: description,
44+
Optional: true,
45+
}
46+
}

internal/planModifiers/duration.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package planModifiers
2+
3+
import (
4+
"context"
5+
6+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
7+
)
8+
9+
type Duration struct{}
10+
11+
func (d Duration) Description(ctx context.Context) string {
12+
return "Verify that two duration are equals"
13+
}
14+
15+
func (d Duration) MarkdownDescription(ctx context.Context) string {
16+
return d.Description(ctx)
17+
}
18+
19+
func (d Duration) PlanModifyString(ctx context.Context, request planmodifier.StringRequest, response *planmodifier.StringResponse) {
20+
if request.StateValue == request.PlanValue {
21+
response.PlanValue = request.PlanValue
22+
}
23+
}

internal/provider/provider_framework.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/hashicorp/terraform-plugin-framework/provider"
1111
"github.com/hashicorp/terraform-plugin-framework/provider/schema"
1212
"github.com/hashicorp/terraform-plugin-framework/resource"
13+
"github.com/scaleway/terraform-provider-scaleway/v2/internal/services/secret"
1314
)
1415

1516
var _ provider.Provider = &ScalewayProvider{}
@@ -69,15 +70,19 @@ func (p *ScalewayProvider) Configure(ctx context.Context, req provider.Configure
6970
}
7071

7172
func (p *ScalewayProvider) Resources(ctx context.Context) []func() resource.Resource {
72-
return []func() resource.Resource{}
73+
return []func() resource.Resource{
74+
secret.NewResourceSecret,
75+
}
7376
}
7477

7578
func (p *ScalewayProvider) EphemeralResources(_ context.Context) []func() ephemeral.EphemeralResource {
7679
return []func() ephemeral.EphemeralResource{}
7780
}
7881

7982
func (p *ScalewayProvider) DataSources(_ context.Context) []func() datasource.DataSource {
80-
return []func() datasource.DataSource{}
83+
return []func() datasource.DataSource{
84+
secret.NewDataSourceSecret,
85+
}
8186
}
8287

8388
func (p *ScalewayProvider) Actions(_ context.Context) []func() action.Action {

internal/provider/provider_sdkv2.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ func SDKProvider(config *Config) plugin.ProviderFunc {
233233
"scaleway_redis_cluster": redis.ResourceCluster(),
234234
"scaleway_registry_namespace": registry.ResourceNamespace(),
235235
"scaleway_sdb_sql_database": sdb.ResourceDatabase(),
236-
"scaleway_secret": secret.ResourceSecret(),
237236
"scaleway_secret_version": secret.ResourceVersion(),
238237
"scaleway_tem_domain": tem.ResourceDomain(),
239238
"scaleway_tem_domain_validation": tem.ResourceDomainValidation(),
@@ -329,7 +328,6 @@ func SDKProvider(config *Config) plugin.ProviderFunc {
329328
"scaleway_registry_image": registry.DataSourceImage(),
330329
"scaleway_registry_namespace": registry.DataSourceNamespace(),
331330
"scaleway_registry_image_tag": registry.DataSourceImageTag(),
332-
"scaleway_secret": secret.DataSourceSecret(),
333331
"scaleway_secret_version": secret.DataSourceVersion(),
334332
"scaleway_tem_domain": tem.DataSourceDomain(),
335333
"scaleway_tem_offer_subscription": tem.DataSourceOfferSubscription(),

internal/services/account/schemas.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package account
22

33
import (
4+
dataSourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema"
5+
resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema"
6+
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
47
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
58
"github.com/scaleway/terraform-provider-scaleway/v2/internal/verify"
69
)
@@ -34,3 +37,23 @@ func ProjectIDSchema() *schema.Schema {
3437
ValidateDiagFunc: verify.IsUUID(),
3538
}
3639
}
40+
41+
func ResourceProjectIDSchema(description string) resourceSchema.StringAttribute {
42+
return resourceSchema.StringAttribute{
43+
Description: description,
44+
Optional: true,
45+
Validators: []validator.String{
46+
verify.UUIDValidator{},
47+
},
48+
}
49+
}
50+
51+
func DatasourceOrganizationIDSchema(description string) dataSourceSchema.StringAttribute {
52+
return dataSourceSchema.StringAttribute{
53+
Description: description,
54+
Optional: true,
55+
Validators: []validator.String{
56+
verify.UUIDValidator{},
57+
},
58+
}
59+
}

0 commit comments

Comments
 (0)