Skip to content

Commit c5c39b7

Browse files
committed
Merge branch 'feat/add-autoscaling-group' of github.com:yfodil/terraform-provider-scaleway into feat/add-autoscaling-group
2 parents 516c389 + c502b6f commit c5c39b7

File tree

107 files changed

+18224
-123144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+18224
-123144
lines changed

.github/labeler.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,8 @@ webhosting:
117117
- changed-files:
118118
- any-glob-to-any-file:
119119
- internal/services/webhosting/**
120+
file:
121+
- changed-files:
122+
- any-glob-to-any-file:
123+
- internal/services/file/**
124+

.github/workflows/acceptance-tests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
- cockpit
2020
- container
2121
- domain
22+
- file
2223
- flexibleip
2324
- function
2425
- iam

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ 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.
19-
version: latest
19+
version: v2.1.6
2020
args: --timeout 5m

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ linters:
118118
rules:
119119
- name: exported
120120
disabled: true
121+
ireturn:
122+
reject:
123+
- anon
121124

122125
exclusions:
123126
rules:

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

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: 11 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
@@ -35,6 +36,9 @@ resource "scaleway_container" "main" {
3536
protocol = "http1"
3637
deploy = true
3738
39+
command = [ "bash", "-c", "script.sh" ]
40+
args = [ "some", "args" ]
41+
3842
environment_variables = {
3943
"foo" = "var"
4044
}
@@ -56,6 +60,8 @@ The following arguments are supported:
5660

5761
- `description` (Optional) The description of the container.
5862

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

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

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

102-
- `local_storage_limit` - Local storage limit of the container (in MB)
108+
- `local_storage_limit` - (Optional) Local storage limit of the container (in MB)
109+
110+
- `command` - (Optional) Command executed when the container starts. This overrides the default command defined in the container image. This is usually the main executable, or entry point script to run.
111+
112+
- `args` - (Optional) Arguments passed to the command specified in the "command" field. These override the default arguments from the container image, and behave like command-line parameters.
103113

104114
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.
105115

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

0 commit comments

Comments
 (0)