Skip to content

Commit 15f7270

Browse files
authored
Merge branch 'master' into instance_doc_root_volume_type_compatibility
2 parents ee39890 + 13e1fd9 commit 15f7270

34 files changed

+8892
-103693
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v4
1515
- name: golangci-lint
16-
uses: golangci/golangci-lint-action@v7.0.0
16+
uses: golangci/golangci-lint-action@v8.0.0
1717
with:
1818
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
1919
version: latest

TESTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,16 @@ Running a single test:
6262
```sh
6363
TF_UPDATE_CASSETTES=true TF_LOG=DEBUG SCW_DEBUG=1 TF_ACC=1 go test ./scaleway -v -run=TestAccScalewayDataSourceRDBInstance_Basic -timeout=120m -parallel=10
6464
```
65+
66+
## Compressing the cassettes
67+
68+
We record interactions with the Scaleway API in cassettes, which are stored in the `testdata` directory of each service.
69+
Each wait function used in the resources will perform several requests to the API for pulling a resource state, which can lead to large cassettes.
70+
We use a compressor to reduce the size of these cassettes once they are recorded.
71+
By doing so, tests can run faster and the cassettes are easier to read.
72+
73+
To use the compressor on a given cassette, run the following command:
74+
75+
```sh
76+
go run -v ./cmd/vcr-compressor internal/services/rdb/testdata/acl-basic.cassette
77+
```

cmd/vcr-compressor/main.go

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"log"
6+
"os"
7+
8+
"github.com/scaleway/scaleway-sdk-go/api/k8s/v1"
9+
"gopkg.in/dnaeon/go-vcr.v3/cassette"
10+
)
11+
12+
var transientStates = map[string]bool{
13+
k8s.ClusterStatusCreating.String(): true,
14+
k8s.ClusterStatusDeleting.String(): true,
15+
k8s.ClusterStatusUpdating.String(): true,
16+
k8s.PoolStatusDeleting.String(): true,
17+
k8s.PoolStatusScaling.String(): true,
18+
k8s.PoolStatusUpgrading.String(): true,
19+
}
20+
21+
func main() {
22+
if len(os.Args) < 2 {
23+
log.Fatalf("Usage: %s <cassette_file_name_without_yaml>\n", os.Args[0])
24+
}
25+
26+
path := os.Args[1]
27+
28+
inputCassette, err := cassette.Load(path)
29+
if err != nil {
30+
log.Fatalf("Error while reading file : %v\n", err)
31+
}
32+
33+
outputCassette := cassette.New(path)
34+
transitioning := false
35+
36+
for i := range len(inputCassette.Interactions) {
37+
interaction := inputCassette.Interactions[i]
38+
responseBody := interaction.Response.Body
39+
requestMethod := interaction.Request.Method
40+
41+
if requestMethod != "GET" {
42+
transitioning = false
43+
44+
log.Printf("Interaction %d is not a GET request. Recording it\n", i)
45+
outputCassette.AddInteraction(interaction)
46+
47+
continue
48+
}
49+
50+
if responseBody == "" {
51+
log.Printf("Interaction %d got an empty response body. Recording it\n", i)
52+
outputCassette.AddInteraction(interaction)
53+
54+
continue
55+
}
56+
57+
var m map[string]interface{}
58+
59+
err := json.Unmarshal([]byte(responseBody), &m)
60+
if err != nil {
61+
log.Printf("Interaction %d have an error with unmarshalling response body: %v. Recording it\n", i, err)
62+
outputCassette.AddInteraction(interaction)
63+
64+
continue
65+
}
66+
67+
if m["status"] == nil {
68+
log.Printf("Interaction %d does not contain a status field. Recording it\n", i)
69+
outputCassette.AddInteraction(interaction)
70+
71+
continue
72+
}
73+
74+
status := m["status"].(string)
75+
// We test if the state is transient
76+
if _, ok := transientStates[status]; ok {
77+
if transitioning {
78+
log.Printf("Interaction %d is in a transient state while we are already in transitient state. No need to record it: %s\n", i, status)
79+
} else {
80+
log.Printf("Interaction %d is in a transient state: %s, Recording it\n", i, status)
81+
82+
transitioning = true
83+
84+
outputCassette.AddInteraction(interaction)
85+
}
86+
} else {
87+
if transitioning {
88+
log.Printf("Interaction %d is not in a transient state anymore: %s, Recording it\n", i, status)
89+
90+
outputCassette.AddInteraction(interaction)
91+
92+
transitioning = false
93+
} else {
94+
log.Printf("Interaction %d is not in a transient state: %s, Recording it\n", i, status)
95+
outputCassette.AddInteraction(interaction)
96+
}
97+
}
98+
}
99+
100+
err = outputCassette.Save()
101+
if err != nil {
102+
log.Fatalf("error while saving file: %v", err)
103+
}
104+
}

cmd/vcr-viewer/main.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"log"
6+
"os"
7+
8+
"gopkg.in/dnaeon/go-vcr.v3/cassette"
9+
)
10+
11+
func main() {
12+
if len(os.Args) < 2 {
13+
log.Fatalf("Usage: %s <cassette_file_name_without_yaml>\n", os.Args[0])
14+
}
15+
16+
path := os.Args[1]
17+
18+
data, err := cassette.Load(path)
19+
if err != nil {
20+
log.Fatalf("Error while reading file: %v\n", err)
21+
}
22+
23+
for i := range len(data.Interactions) {
24+
interaction := data.Interactions[i]
25+
26+
log.Println("--------------")
27+
log.Printf("Interaction %d:\n", i+1)
28+
log.Printf(" Request:\n")
29+
log.Printf(" Method: %s\n", interaction.Request.Method)
30+
log.Printf(" URL: %s\n", interaction.Request.URL)
31+
32+
if interaction.Request.Body != "" {
33+
log.Printf(" Body: %s\n", interaction.Request.Body)
34+
}
35+
36+
log.Printf(" Response:\n")
37+
log.Printf(" Status: %s\n", interaction.Response.Status)
38+
log.Printf(" Body: %s\n", interaction.Response.Body)
39+
40+
var m map[string]interface{}
41+
42+
err := json.Unmarshal([]byte(interaction.Response.Body), &m)
43+
if err != nil {
44+
continue
45+
}
46+
47+
if m["status"] != nil {
48+
log.Println("++++++++++++++++")
49+
log.Printf("status: %s\n", m["status"])
50+
log.Println("++++++++++++++++")
51+
}
52+
53+
log.Println("--------------")
54+
}
55+
}

docs/data-sources/flexible_ip.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,26 @@ Gets information about a Flexible IP.
1111

1212
```hcl
1313
# Get info by IP address
14-
data "scaleway_flexible_ip" "my_ip" {
14+
data "scaleway_flexible_ip" "with_ip" {
1515
ip_address = "1.2.3.4"
1616
}
1717
1818
# Get info by IP ID
19-
data "scaleway_flexible_ip" "my_ip" {
20-
ip_id = "11111111-1111-1111-1111-111111111111"
19+
data "scaleway_flexible_ip" "with_id" {
20+
flexible_ip_id = "11111111-1111-1111-1111-111111111111"
2121
}
2222
```
2323

2424
## Argument Reference
2525

2626
- `ip_address` - (Optional) The IP address.
27-
Only one of `ip_address` and `ip_id` should be specified.
27+
Only one of `ip_address` and `flexible_ip_id` should be specified.
2828

2929
- `flexible_ip_id` - (Optional) The IP ID.
3030
Only one of `ip_address` and `flexible_ip_id` should be specified.
3131

32-
## Attributes Reference
33-
34-
In addition to all above arguments, the following attributes are exported:
32+
- `project_id` - (Optional. Defaults to [provider](../index.md#project_id) `project_id`) The ID of the Project the Flexible IP is associated with.
3533

36-
- `id` - The ID of the flexible IP.
37-
38-
~> **Important:** Flexible IPs' IDs are [zoned](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{zone}/{id}`, e.g. `fr-par-1/11111111-1111-1111-1111-111111111111`
34+
## Attributes Reference
3935

40-
- `reverse` - The reverse domain associated with this IP.
41-
- `server_id` - The associated server ID if any
42-
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the IP is in.
43-
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the IP is in.
36+
Exported attributes are the ones from `flexible_ip` [resource](../resources/flexible_ip.md)

docs/resources/container.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ resource "scaleway_container_namespace" "main" {
2222
resource "scaleway_container" "main" {
2323
name = "my-container-02"
2424
description = "environment variables test"
25+
tags = ["tag1", "tag2"]
2526
namespace_id = scaleway_container_namespace.main.id
2627
registry_image = "${scaleway_container_namespace.main.registry_endpoint}/alpine:test"
2728
port = 9997
@@ -56,6 +57,8 @@ The following arguments are supported:
5657

5758
- `description` (Optional) The description of the container.
5859

60+
- `tags` - (Optional) The list of tags associated with the container.
61+
5962
- `environment_variables` - (Optional) The [environment variables](https://www.scaleway.com/en/docs/serverless-containers/concepts/#environment-variables) of the container.
6063

6164
- `secret_environment_variables` - (Optional) The [secret environment variables](https://www.scaleway.com/en/docs/serverless-containers/concepts/#secrets) of the container.
@@ -99,7 +102,7 @@ The following arguments are supported:
99102

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

102-
- `local_storage_limit` - Local storage limit of the container (in MB)
105+
- `local_storage_limit` - (Optional) Local storage limit of the container (in MB)
103106

104107
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.
105108

docs/resources/container_namespace.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Refer to the Containers namespace [documentation](https://www.scaleway.com/en/do
1616
resource "scaleway_container_namespace" "main" {
1717
name = "main-container-namespace"
1818
description = "Main container namespace"
19+
tags = ["tag1", "tag2"]
1920
}
2021
```
2122

@@ -27,15 +28,17 @@ The following arguments are supported:
2728

2829
~> **Important** Updates to the `name` argument will recreate the namespace.
2930

30-
- `description` (Optional) The description of the namespace.
31+
- `description` - (Optional) The description of the namespace.
32+
33+
- `tags` - (Optional) The list of tags associated with the namespace.
3134

3235
- `region` - (Defaults to [provider](../index.md#region) `region`). The [region](../guides/regions_and_zones.md#regions) in which the namespace is created.
3336

3437
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The unique identifier of the project that contains the namespace.
3538

36-
- `environment_variables` - The environment variables of the namespace.
39+
- `environment_variables` - (Optional) The environment variables of the namespace.
3740

38-
- `secret_environment_variables` - The secret environment variables of the namespace.
41+
- `secret_environment_variables` - (Optional) The secret environment variables of the namespace.
3942

4043
## Attributes Reference
4144

docs/resources/flexible_ip.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ The following arguments are supported:
7878
- `reverse` - (Optional) The reverse domain associated with this flexible IP.
7979
- `is_ipv6` - (Optional) Defines whether the flexible IP has an IPv6 address.
8080
- `zone` -(Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) of the Flexible IP.
81-
81+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the Project the Flexible IP is associated with.
8282

8383
## Attributes Reference
8484

@@ -94,7 +94,6 @@ In addition to all arguments above, the following attributes are exported:
9494
- `created_at` - The date and time of the creation of the Flexible IP (Format ISO 8601).
9595
- `updated_at` - The date and time of the last update of the Flexible IP (Format ISO 8601).
9696
- `organization_id` - The organization of the Flexible IP.
97-
- `project_id` - The project of the Flexible IP.
9897

9998
## Import
10099

docs/resources/function.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ resource "scaleway_function_namespace" "main" {
4141
4242
resource "scaleway_function" "main" {
4343
namespace_id = scaleway_function_namespace.main.id
44+
description = "function with zip file"
45+
tags = ["tag1", "tag2"]
4446
runtime = "go118"
4547
handler = "Handle"
4648
privacy = "private"
@@ -63,29 +65,31 @@ The following arguments are supported:
6365

6466
- `description` (Optional) The description of the function.
6567

68+
- `tags` - (Optional) The list of tags associated with the function.
69+
6670
- `environment_variables` - (Optional) The [environment variables](https://www.scaleway.com/en/docs/compute/functions/concepts/#environment-variables) of the function.
6771

6872
- `secret_environment_variables` - (Optional) The [secret environment variables](https://www.scaleway.com/en/docs/compute/functions/concepts/#secrets) of the function.
6973

7074
- `privacy` - (Optional) The privacy type defines the way to authenticate to your function. Please check our dedicated [section](https://www.scaleway.com/en/developers/api/serverless-functions/#protocol-9dd4c8).
7175

72-
- `runtime` - Runtime of the function. Runtimes can be fetched using [specific route](https://www.scaleway.com/en/developers/api/serverless-functions/#path-functions-get-a-function)
76+
- `runtime` - (Required) Runtime of the function. Runtimes can be fetched using [specific route](https://www.scaleway.com/en/developers/api/serverless-functions/#path-functions-get-a-function)
7377

7478
- `min_scale` - (Optional) The minimum number of function instances running continuously. Defaults to 0. Functions are billed when executed, and using a `min_scale` greater than 0 will cause your function to run constantly.
7579

7680
- `max_scale` - (Optional) The maximum number of instances this function can scale to. Default to 20. Your function will scale automatically based on the incoming workload, but will never exceed the configured `max_scale` value.
7781

7882
- `memory_limit` - (Optional) The memory resources in MB to allocate to each function. Defaults to 256 MB.
7983

80-
- `handler` - Handler of the function, depends on the runtime. Refer to the [dedicated documentation](https://www.scaleway.com/en/developers/api/serverless-functions/#path-functions-create-a-new-function) for the list of supported runtimes.
84+
- `handler` - (Required) Handler of the function, depends on the runtime. Refer to the [dedicated documentation](https://www.scaleway.com/en/developers/api/serverless-functions/#path-functions-create-a-new-function) for the list of supported runtimes.
8185

8286
- `timeout` - (Optional) The maximum amount of time your function can spend processing a request before being stopped. Defaults to 300s.
8387

84-
- `zip_file` - Path to the zip file containing your function sources to upload.
88+
- `zip_file` - (Optional) Path to the zip file containing your function sources to upload.
8589

86-
- `zip_hash` - The hash of your source zip file, changing it will redeploy the function. Can be any string, changing it will simply trigger a state change. You can use any Terraform hash function to trigger a change on your zip change (see examples).
90+
- `zip_hash` - (Optional) The hash of your source zip file, changing it will redeploy the function. Can be any string, changing it will simply trigger a state change. You can use any Terraform hash function to trigger a change on your zip change (see examples).
8791

88-
- `deploy` - Define whether the function should be deployed. Terraform will wait for the function to be deployed. Your function will be redeployed if you update the source zip file.
92+
- `deploy` - (Optional, defaults to `false`) Define whether the function should be deployed. Terraform will wait for the function to be deployed. Your function will be redeployed if you update the source zip file.
8993

9094
- `http_option` - (Optional) Allows both HTTP and HTTPS (`enabled`) or redirect HTTP to HTTPS (`redirected`). Defaults to `enabled`.
9195

docs/resources/function_namespace.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Refer to the Functions namespace [documentation](https://www.scaleway.com/en/doc
1616
resource "scaleway_function_namespace" "main" {
1717
name = "main-function-namespace"
1818
description = "Main function namespace"
19+
tags = ["tag1", "tag2"]
1920
}
2021
```
2122

@@ -29,13 +30,15 @@ The following arguments are supported:
2930

3031
- `description` (Optional) The description of the namespace.
3132

33+
- `tags` - (Optional) The list of tags associated with the namespace.
34+
3235
- `region` - (Defaults to [provider](../index.md#region) `region`). The [region](../guides/regions_and_zones.md#regions) in which the namespace is created.
3336

3437
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The unique identifier of the project that contains the namespace.
3538

36-
- `environment_variables` - The environment variables of the namespace.
39+
- `environment_variables` - (Optional) The environment variables of the namespace.
3740

38-
- `secret_environment_variables` - The secret environment variables of the namespace.
41+
- `secret_environment_variables` - (Optional) The secret environment variables of the namespace.
3942

4043
## Attributes Reference
4144

0 commit comments

Comments
 (0)