Skip to content

Commit

Permalink
feat(instance_volume): add scratch type (#2122)
Browse files Browse the repository at this point in the history
* feat(instance_volume): add scratch type

* update doc
  • Loading branch information
Codelax authored Sep 6, 2023
1 parent 6fefc99 commit c5ca20a
Show file tree
Hide file tree
Showing 4 changed files with 256 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/resources/instance_volume.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ resource "scaleway_instance_volume" "server_volume" {

The following arguments are supported:

- `type` - (Required) The type of the volume. The possible values are: `b_ssd` (Block SSD), `l_ssd` (Local SSD).
- `type` - (Required) The type of the volume. The possible values are: `b_ssd` (Block SSD), `l_ssd` (Local SSD), `scratch` (Local Scratch SSD).
- `size_in_gb` - (Optional) The size of the volume. Only one of `size_in_gb`, `from_volume_id` and `from_snapshot_id` should be specified.
- `from_volume_id` - (Optional) If set, the new volume will be copied from this volume. Only one of `size_in_gb`, `from_volume_id` and `from_snapshot_id` should be specified.
- ``from_snapshot_id`` - (Optional) If set, the new volume will be created from this snapshot. Only one of `size_in_gb`, `from_volume_id` and `from_snapshot_id` should be specified.
- `from_snapshot_id` - (Optional) If set, the new volume will be created from this snapshot. Only one of `size_in_gb`, `from_volume_id` and `from_snapshot_id` should be specified.
- `name` - (Optional) The name of the volume. If not provided it will be randomly generated.
- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the volume should be created.
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the volume is associated with.
Expand Down
1 change: 1 addition & 0 deletions scaleway/resource_instance_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func resourceScalewayInstanceVolume() *schema.Resource {
ValidateFunc: validation.StringInSlice([]string{
instance.VolumeVolumeTypeBSSD.String(),
instance.VolumeVolumeTypeLSSD.String(),
instance.VolumeVolumeTypeScratch.String(),
}, false),
},
"size_in_gb": {
Expand Down
19 changes: 19 additions & 0 deletions scaleway/resource_instance_volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,25 @@ func TestAccScalewayInstanceVolume_CannotResizeBlockDown(t *testing.T) {
})
}

func TestAccScalewayInstanceVolume_Scratch(t *testing.T) {
tt := NewTestTools(t)
defer tt.Cleanup()
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: tt.ProviderFactories,
CheckDestroy: testAccCheckScalewayInstanceVolumeDestroy(tt),
Steps: []resource.TestStep{
{
Config: `
resource "scaleway_instance_volume" "main" {
type = "scratch"
size_in_gb = 20
}`,
},
},
})
}

func testAccCheckScalewayInstanceVolumeExists(tt *TestTools, n string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down
234 changes: 234 additions & 0 deletions scaleway/testdata/instance-volume-scratch.cassette.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
---
version: 1
interactions:
- request:
body: '{"name":"tf-vol-vigilant-tereshkova","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","volume_type":"scratch","size":20000000000}'
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.0; linux; amd64) terraform-provider/develop
terraform/terraform-tests
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes
method: POST
response:
body: '{"volume":{"creation_date":"2023-09-06T11:38:51.980736+00:00","export_uri":null,"id":"6af48311-3c75-4a87-91e3-a0d7b5eaf4b1","modification_date":"2023-09-06T11:38:51.980736+00:00","name":"tf-vol-vigilant-tereshkova","organization":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","server":null,"size":20000000000,"state":"available","tags":[],"volume_type":"scratch","zone":"fr-par-1"}}'
headers:
Content-Length:
- "450"
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'
Content-Type:
- application/json
Date:
- Wed, 06 Sep 2023 11:38:52 GMT
Location:
- https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6af48311-3c75-4a87-91e3-a0d7b5eaf4b1
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
- max-age=63072000
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
X-Request-Id:
- 92f58692-32f4-4627-96ba-d3118d71f365
status: 201 Created
code: 201
duration: ""
- request:
body: ""
form: {}
headers:
User-Agent:
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.0; linux; amd64) terraform-provider/develop
terraform/terraform-tests
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6af48311-3c75-4a87-91e3-a0d7b5eaf4b1
method: GET
response:
body: '{"volume":{"creation_date":"2023-09-06T11:38:51.980736+00:00","export_uri":null,"id":"6af48311-3c75-4a87-91e3-a0d7b5eaf4b1","modification_date":"2023-09-06T11:38:51.980736+00:00","name":"tf-vol-vigilant-tereshkova","organization":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","server":null,"size":20000000000,"state":"available","tags":[],"volume_type":"scratch","zone":"fr-par-1"}}'
headers:
Content-Length:
- "450"
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'
Content-Type:
- application/json
Date:
- Wed, 06 Sep 2023 11:38:52 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
- max-age=63072000
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
X-Request-Id:
- a4820696-3745-4e8d-95a3-dd245ce02757
status: 200 OK
code: 200
duration: ""
- request:
body: ""
form: {}
headers:
User-Agent:
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.0; linux; amd64) terraform-provider/develop
terraform/terraform-tests
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6af48311-3c75-4a87-91e3-a0d7b5eaf4b1
method: GET
response:
body: '{"volume":{"creation_date":"2023-09-06T11:38:51.980736+00:00","export_uri":null,"id":"6af48311-3c75-4a87-91e3-a0d7b5eaf4b1","modification_date":"2023-09-06T11:38:51.980736+00:00","name":"tf-vol-vigilant-tereshkova","organization":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","server":null,"size":20000000000,"state":"available","tags":[],"volume_type":"scratch","zone":"fr-par-1"}}'
headers:
Content-Length:
- "450"
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'
Content-Type:
- application/json
Date:
- Wed, 06 Sep 2023 11:38:52 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
- max-age=63072000
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
X-Request-Id:
- ca61c348-33ae-443f-8aab-dff22ab1a370
status: 200 OK
code: 200
duration: ""
- request:
body: ""
form: {}
headers:
User-Agent:
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.0; linux; amd64) terraform-provider/develop
terraform/terraform-tests
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6af48311-3c75-4a87-91e3-a0d7b5eaf4b1
method: GET
response:
body: '{"volume":{"creation_date":"2023-09-06T11:38:51.980736+00:00","export_uri":null,"id":"6af48311-3c75-4a87-91e3-a0d7b5eaf4b1","modification_date":"2023-09-06T11:38:51.980736+00:00","name":"tf-vol-vigilant-tereshkova","organization":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","server":null,"size":20000000000,"state":"available","tags":[],"volume_type":"scratch","zone":"fr-par-1"}}'
headers:
Content-Length:
- "450"
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'
Content-Type:
- application/json
Date:
- Wed, 06 Sep 2023 11:38:52 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
- max-age=63072000
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
X-Request-Id:
- 51902651-be18-41fb-92f9-9af8091910b4
status: 200 OK
code: 200
duration: ""
- request:
body: ""
form: {}
headers:
User-Agent:
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.0; linux; amd64) terraform-provider/develop
terraform/terraform-tests
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6af48311-3c75-4a87-91e3-a0d7b5eaf4b1
method: GET
response:
body: '{"volume":{"creation_date":"2023-09-06T11:38:51.980736+00:00","export_uri":null,"id":"6af48311-3c75-4a87-91e3-a0d7b5eaf4b1","modification_date":"2023-09-06T11:38:51.980736+00:00","name":"tf-vol-vigilant-tereshkova","organization":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","server":null,"size":20000000000,"state":"available","tags":[],"volume_type":"scratch","zone":"fr-par-1"}}'
headers:
Content-Length:
- "450"
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'
Content-Type:
- application/json
Date:
- Wed, 06 Sep 2023 11:38:53 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
- max-age=63072000
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
X-Request-Id:
- bb45a795-e74f-4832-b20a-5763cd7c6a0c
status: 200 OK
code: 200
duration: ""
- request:
body: ""
form: {}
headers:
User-Agent:
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.0; linux; amd64) terraform-provider/develop
terraform/terraform-tests
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6af48311-3c75-4a87-91e3-a0d7b5eaf4b1
method: DELETE
response:
body: ""
headers:
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'
Date:
- Wed, 06 Sep 2023 11:38:53 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
- max-age=63072000
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
X-Request-Id:
- e018bf84-60ce-4c9a-a905-0c7ef04bfdb7
status: 204 No Content
code: 204
duration: ""
- request:
body: ""
form: {}
headers:
User-Agent:
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.0; linux; amd64) terraform-provider/develop
terraform/terraform-tests
url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6af48311-3c75-4a87-91e3-a0d7b5eaf4b1
method: GET
response:
body: '{"message":"resource is not found","resource":"instance_volume","resource_id":"6af48311-3c75-4a87-91e3-a0d7b5eaf4b1","type":"not_found"}'
headers:
Content-Length:
- "143"
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'
Content-Type:
- application/json
Date:
- Wed, 06 Sep 2023 11:38:54 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
- max-age=63072000
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
X-Request-Id:
- ab666111-d85d-4cde-842c-e87d455285ca
status: 404 Not Found
code: 404
duration: ""

0 comments on commit c5ca20a

Please sign in to comment.