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

feat(container): add support for local_storage_limit #2969

Merged
merged 1 commit into from
Mar 10, 2025
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
2 changes: 2 additions & 0 deletions docs/resources/container.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ The following arguments are supported:

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

- `local_storage_limit` - Local storage limit of the container (in MB)

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.

## Attributes Reference
Expand Down
11 changes: 11 additions & 0 deletions internal/services/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ func ResourceContainer() *schema.Resource {
},
},
},
"local_storage_limit": {
Type: schema.TypeInt,
Description: "Local storage limit of the container (in MB)",
Optional: true,
Computed: true,
},
// computed
"status": {
Type: schema.TypeString,
Expand Down Expand Up @@ -351,6 +357,7 @@ func ResourceContainerRead(ctx context.Context, d *schema.ResourceData, m interf
_ = d.Set("health_check", flattenHealthCheck(co.HealthCheck))
_ = d.Set("scaling_option", flattenScalingOption(co.ScalingOption))
_ = d.Set("region", co.Region.String())
_ = d.Set("local_storage_limit", int(co.LocalStorageLimit))

return nil
}
Expand Down Expand Up @@ -472,6 +479,10 @@ func ResourceContainerUpdate(ctx context.Context, d *schema.ResourceData, m inte
req.Redeploy = &imageHasChanged
}

if d.HasChanges("local_storage_limit") {
req.LocalStorageLimit = scw.Uint32Ptr(uint32(d.Get("local_storage_limit").(int)))
}

con, err := api.UpdateContainer(req, scw.WithContext(ctx))
if err != nil {
return diag.FromErr(err)
Expand Down
5 changes: 5 additions & 0 deletions internal/services/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func TestAccContainer_Basic(t *testing.T) {
resource.TestCheckResourceAttrSet("scaleway_container.main", "max_scale"),
resource.TestCheckResourceAttrSet("scaleway_container.main", "min_scale"),
resource.TestCheckResourceAttrSet("scaleway_container.main", "privacy"),
resource.TestCheckResourceAttrSet("scaleway_container.main", "local_storage_limit"),
),
},
{
Expand All @@ -63,6 +64,7 @@ func TestAccContainer_Basic(t *testing.T) {
max_scale = 20
timeout = 300
deploy = false
local_storage_limit = 1000
}
`,
Check: resource.ComposeTestCheckFunc(
Expand All @@ -79,6 +81,7 @@ func TestAccContainer_Basic(t *testing.T) {
resource.TestCheckResourceAttr("scaleway_container.main", "deploy", "false"),
resource.TestCheckResourceAttr("scaleway_container.main", "privacy", containerSDK.ContainerPrivacyPublic.String()),
resource.TestCheckResourceAttr("scaleway_container.main", "protocol", containerSDK.ContainerProtocolHTTP1.String()),
resource.TestCheckResourceAttr("scaleway_container.main", "local_storage_limit", "1000"),
),
},
{
Expand All @@ -96,6 +99,7 @@ func TestAccContainer_Basic(t *testing.T) {
memory_limit = 1120
cpu_limit = 280
deploy = false
local_storage_limit = 1500
}
`,
Check: resource.ComposeTestCheckFunc(
Expand All @@ -111,6 +115,7 @@ func TestAccContainer_Basic(t *testing.T) {
resource.TestCheckResourceAttr("scaleway_container.main", "max_concurrency", "80"),
resource.TestCheckResourceAttr("scaleway_container.main", "deploy", "false"),
resource.TestCheckResourceAttr("scaleway_container.main", "protocol", containerSDK.ContainerProtocolHTTP1.String()),
resource.TestCheckResourceAttr("scaleway_container.main", "local_storage_limit", "1500"),
),
},
},
Expand Down
4 changes: 4 additions & 0 deletions internal/services/container/helpers_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ func setCreateContainerRequest(d *schema.ResourceData, region scw.Region) (*cont
req.ScalingOption = scalingOptionReq
}

if localStorageLimit, ok := d.GetOk("local_storage_limit"); ok {
req.LocalStorageLimit = scw.Uint32Ptr(uint32(localStorageLimit.(int)))
}

return req, nil
}

Expand Down
Loading
Loading