Skip to content

Commit b367b47

Browse files
authored
feat(serverless): add support for native domain name (#1358)
1 parent efb453b commit b367b47

File tree

7 files changed

+12
-15
lines changed

7 files changed

+12
-15
lines changed

docs/resources/container.md

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ In addition to all above arguments, the following attributes are exported:
9494
- `status` - The container status.
9595
- `cron_status` - The cron status of the container.
9696
- `error_message` - The error message of the container.
97+
- `domain_name` - The native domain name of the container
9798

9899
## Import
99100

docs/resources/function.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ The following arguments are supported:
9191
In addition to all arguments above, the following attributes are exported:
9292

9393
- `id` - The ID of the function
94+
- `domain_name` - The native domain name of the function
9495
- `organization_id` - The organization ID the function is associated with.
9596
- `cpu_limit` - The CPU limit in mCPU for your function. More infos on resources [here](https://developers.scaleway.com/en/products/functions/api/#functions)
9697

97-
9898
## Import
9999

100100
Functions can be imported using the `{region}/{id}`, e.g.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/hashicorp/terraform-plugin-log v0.4.1
1313
github.com/hashicorp/terraform-plugin-sdk/v2 v2.17.0
1414
github.com/robfig/cron/v3 v3.0.1
15-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220628124746-c91952af9ea3
15+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220706124610-072bee915715
1616
github.com/stretchr/testify v1.8.0
1717
)
1818

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
254254
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
255255
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
256256
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
257-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220628124746-c91952af9ea3 h1:bfY4HHzHUS8PNStk8gwVlcMouelOWr1hr91hQjp+Rhw=
258-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220628124746-c91952af9ea3/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
257+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220706124610-072bee915715 h1:e+1PXi8wsIPdl8DUOm+R23C1D91UYph6BJcrJL5NpU0=
258+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220706124610-072bee915715/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
259259
github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4=
260260
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
261261
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=

scaleway/helpers_container.go

-4
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ func setCreateContainerRequest(d *schema.ResourceData, region scw.Region) (*cont
9595
req.MaxConcurrency = scw.Uint32Ptr(uint32(maxConcurrency.(int)))
9696
}
9797

98-
if domainName, ok := d.GetOk("domain_name"); ok {
99-
req.DomainName = expandStringPtr(domainName)
100-
}
101-
10298
return req, nil
10399
}
104100

scaleway/resource_container.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,8 @@ func resourceScalewayContainer() *schema.Resource {
114114
},
115115
"domain_name": {
116116
Type: schema.TypeString,
117-
Optional: true,
118117
Computed: true,
119-
Description: "The container domain name.",
118+
Description: "The native container domain name.",
120119
},
121120
"protocol": {
122121
Type: schema.TypeString,
@@ -315,10 +314,6 @@ func resourceScalewayContainerUpdate(ctx context.Context, d *schema.ResourceData
315314
req.RegistryImage = expandStringPtr(d.Get("registry_image"))
316315
}
317316

318-
if d.HasChanges("domain_name") {
319-
req.DomainName = expandStringPtr(d.Get("domain_name"))
320-
}
321-
322317
if d.HasChanges("max_concurrency") {
323318
req.MaxConcurrency = toUint32(d.Get("max_concurrency"))
324319
}

scaleway/resource_function.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ func resourceScalewayFunction() *schema.Resource {
125125
Computed: true,
126126
Description: "CPU limit in mCPU for your function",
127127
},
128-
128+
"domain_name": {
129+
Type: schema.TypeString,
130+
Computed: true,
131+
Description: "The native function domain name.",
132+
},
129133
"region": regionSchema(),
130134
"organization_id": organizationIDSchema(),
131135
"project_id": projectIDSchema(),
@@ -263,6 +267,7 @@ func resourceScalewayFunctionRead(ctx context.Context, d *schema.ResourceData, m
263267
_ = d.Set("privacy", f.Privacy.String())
264268
_ = d.Set("region", f.Region.String())
265269
_ = d.Set("timeout", flattenDuration(f.Timeout.ToTimeDuration()))
270+
_ = d.Set("domain_name", f.DomainName)
266271

267272
return diags
268273
}

0 commit comments

Comments
 (0)