Skip to content

Commit d79f4b3

Browse files
author
devtools-ci-cd
committed
feat(container): add support for local_storage_limit
1 parent e5ae8ab commit d79f4b3

File tree

5 files changed

+397
-767
lines changed

5 files changed

+397
-767
lines changed

docs/resources/container.md

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ The following arguments are supported:
9999

100100
- `deploy` - (Optional) Boolean indicating whether the container is in a production environment.
101101

102+
- `local_storage_limit` - Local storage limit of the container (in MB)
103+
102104
Note that if you want to use your own configuration, you must consult our configuration [restrictions](https://www.scaleway.com/en/docs/serverless-containers/reference-content/containers-limitations/#configuration-restrictions) section.
103105

104106
## Attributes Reference

internal/services/container/container.go

+11
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ func ResourceContainer() *schema.Resource {
235235
},
236236
},
237237
},
238+
"local_storage_limit": {
239+
Type: schema.TypeInt,
240+
Description: "Local storage limit of the container (in MB)",
241+
Optional: true,
242+
Computed: true,
243+
},
238244
// computed
239245
"status": {
240246
Type: schema.TypeString,
@@ -351,6 +357,7 @@ func ResourceContainerRead(ctx context.Context, d *schema.ResourceData, m interf
351357
_ = d.Set("health_check", flattenHealthCheck(co.HealthCheck))
352358
_ = d.Set("scaling_option", flattenScalingOption(co.ScalingOption))
353359
_ = d.Set("region", co.Region.String())
360+
_ = d.Set("local_storage_limit", int(co.LocalStorageLimit))
354361

355362
return nil
356363
}
@@ -472,6 +479,10 @@ func ResourceContainerUpdate(ctx context.Context, d *schema.ResourceData, m inte
472479
req.Redeploy = &imageHasChanged
473480
}
474481

482+
if d.HasChanges("local_storage_limit") {
483+
req.LocalStorageLimit = scw.Uint32Ptr(uint32(d.Get("local_storage_limit").(int)))
484+
}
485+
475486
con, err := api.UpdateContainer(req, scw.WithContext(ctx))
476487
if err != nil {
477488
return diag.FromErr(err)

internal/services/container/container_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func TestAccContainer_Basic(t *testing.T) {
4646
resource.TestCheckResourceAttrSet("scaleway_container.main", "max_scale"),
4747
resource.TestCheckResourceAttrSet("scaleway_container.main", "min_scale"),
4848
resource.TestCheckResourceAttrSet("scaleway_container.main", "privacy"),
49+
resource.TestCheckResourceAttrSet("scaleway_container.main", "local_storage_limit"),
4950
),
5051
},
5152
{
@@ -63,6 +64,7 @@ func TestAccContainer_Basic(t *testing.T) {
6364
max_scale = 20
6465
timeout = 300
6566
deploy = false
67+
local_storage_limit = 1000
6668
}
6769
`,
6870
Check: resource.ComposeTestCheckFunc(
@@ -79,6 +81,7 @@ func TestAccContainer_Basic(t *testing.T) {
7981
resource.TestCheckResourceAttr("scaleway_container.main", "deploy", "false"),
8082
resource.TestCheckResourceAttr("scaleway_container.main", "privacy", containerSDK.ContainerPrivacyPublic.String()),
8183
resource.TestCheckResourceAttr("scaleway_container.main", "protocol", containerSDK.ContainerProtocolHTTP1.String()),
84+
resource.TestCheckResourceAttr("scaleway_container.main", "local_storage_limit", "1000"),
8285
),
8386
},
8487
{
@@ -96,6 +99,7 @@ func TestAccContainer_Basic(t *testing.T) {
9699
memory_limit = 1120
97100
cpu_limit = 280
98101
deploy = false
102+
local_storage_limit = 1500
99103
}
100104
`,
101105
Check: resource.ComposeTestCheckFunc(
@@ -111,6 +115,7 @@ func TestAccContainer_Basic(t *testing.T) {
111115
resource.TestCheckResourceAttr("scaleway_container.main", "max_concurrency", "80"),
112116
resource.TestCheckResourceAttr("scaleway_container.main", "deploy", "false"),
113117
resource.TestCheckResourceAttr("scaleway_container.main", "protocol", containerSDK.ContainerProtocolHTTP1.String()),
118+
resource.TestCheckResourceAttr("scaleway_container.main", "local_storage_limit", "1500"),
114119
),
115120
},
116121
},

internal/services/container/helpers_container.go

+4
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ func setCreateContainerRequest(d *schema.ResourceData, region scw.Region) (*cont
135135
req.ScalingOption = scalingOptionReq
136136
}
137137

138+
if localStorageLimit, ok := d.GetOk("local_storage_limit"); ok {
139+
req.LocalStorageLimit = scw.Uint32Ptr(uint32(localStorageLimit.(int)))
140+
}
141+
138142
return req, nil
139143
}
140144

0 commit comments

Comments
 (0)