Skip to content

Commit 60d010c

Browse files
authored
Merge branch 'master' into fix-nightly-object
2 parents 6c9361a + 6f6860e commit 60d010c

36 files changed

+26719
-12945
lines changed

docs/resources/instance_server.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ To retrieve more information by label please use: ```scw marketplace image get l
201201

202202
- `security_group_id` - (Optional) The [security group](https://www.scaleway.com/en/developers/api/instance/#path-security-groups-update-a-security-group9) the server is attached to.
203203

204+
~> **Important:** If you don't specify a security group, a default one will be created, which won't be tracked by Terraform unless you import it.
205+
204206
- `placement_group_id` - (Optional) The [placement group](https://www.scaleway.com/en/developers/api/instance/#path-security-groups-update-a-security-group the server is attached to.
205207

206208

docs/resources/lb.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ The following arguments are supported:
161161

162162
- `ip_ids` - (Optional) The List of IP IDs to attach to the Load Balancer.
163163

164+
~> **Important:** Make sure to use a [`scaleway_lb_ip`](./lb_ip.md) resource to create the IPs.
165+
164166
- `ip_id` - (Deprecated) The ID of the associated Load Balancer IP. See below.
165167

166168
~> **Important:** Updates to `ip_id` will recreate the Load Balancer.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/nats-io/jwt/v2 v2.7.2
2929
github.com/nats-io/nats.go v1.37.0
3030
github.com/robfig/cron/v3 v3.0.1
31-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241021115642-2d127a2d76c7
31+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241028153617-2a48843b5fcb
3232
github.com/stretchr/testify v1.9.0
3333
golang.org/x/crypto v0.28.0
3434
gopkg.in/dnaeon/go-vcr.v3 v3.2.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXq
295295
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
296296
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
297297
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
298-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241021115642-2d127a2d76c7 h1:mWi3yS37Lhf73OP2Z4CboKtXJM4mWDAUWFHKSx2WK7k=
299-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241021115642-2d127a2d76c7/go.mod h1:3jrRJM7638J+P33hKy9MBvfOBxNo8pEGNQQoIv65Ihg=
298+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241028153617-2a48843b5fcb h1:OsRpbw60numCy/+3FS7UhZzkdiTu6OZwq29bb4b3gNo=
299+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241028153617-2a48843b5fcb/go.mod h1:3jrRJM7638J+P33hKy9MBvfOBxNo8pEGNQQoIv65Ihg=
300300
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
301301
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
302302
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=

internal/services/container/namespace.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ func ResourceNamespace() *schema.Resource {
4646
Optional: true,
4747
Description: "The description of the container namespace",
4848
},
49+
"tags": {
50+
Type: schema.TypeList,
51+
Elem: &schema.Schema{
52+
Type: schema.TypeString,
53+
},
54+
Optional: true,
55+
Description: "List of tags [\"tag1\", \"tag2\", ...] attached to the container namespace",
56+
},
4957
"environment_variables": {
5058
Type: schema.TypeMap,
5159
Optional: true,
@@ -97,14 +105,21 @@ func ResourceContainerNamespaceCreate(ctx context.Context, d *schema.ResourceDat
97105
return diag.FromErr(err)
98106
}
99107

100-
ns, err := api.CreateNamespace(&container.CreateNamespaceRequest{
108+
createReq := &container.CreateNamespaceRequest{
101109
Description: types.ExpandStringPtr(d.Get("description").(string)),
102110
EnvironmentVariables: types.ExpandMapPtrStringString(d.Get("environment_variables")),
103111
SecretEnvironmentVariables: expandContainerSecrets(d.Get("secret_environment_variables")),
104112
Name: types.ExpandOrGenerateString(d.Get("name").(string), "ns"),
105113
ProjectID: d.Get("project_id").(string),
106114
Region: region,
107-
}, scw.WithContext(ctx))
115+
}
116+
117+
rawTag, tagExist := d.GetOk("tags")
118+
if tagExist {
119+
createReq.Tags = types.ExpandStrings(rawTag)
120+
}
121+
122+
ns, err := api.CreateNamespace(createReq, scw.WithContext(ctx))
108123
if err != nil {
109124
return diag.FromErr(err)
110125
}
@@ -135,6 +150,7 @@ func ResourceContainerNamespaceRead(ctx context.Context, d *schema.ResourceData,
135150
}
136151

137152
_ = d.Set("description", types.FlattenStringPtr(ns.Description))
153+
_ = d.Set("tags", types.FlattenSliceString(ns.Tags))
138154
_ = d.Set("environment_variables", ns.EnvironmentVariables)
139155
_ = d.Set("name", ns.Name)
140156
_ = d.Set("organization_id", ns.OrganizationID)
@@ -166,6 +182,10 @@ func ResourceContainerNamespaceUpdate(ctx context.Context, d *schema.ResourceDat
166182
req.Description = types.ExpandUpdatedStringPtr(d.Get("description"))
167183
}
168184

185+
if d.HasChange("tags") {
186+
req.Tags = types.ExpandUpdatedStringsPtr(d.Get("tags"))
187+
}
188+
169189
if d.HasChanges("environment_variables") {
170190
req.EnvironmentVariables = types.ExpandMapPtrStringString(d.Get("environment_variables"))
171191
}

internal/services/container/namespace_test.go

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,32 @@ func TestAccNamespace_Basic(t *testing.T) {
7070
acctest.CheckResourceAttrUUID("scaleway_container_namespace.main", "id"),
7171
),
7272
},
73+
{
74+
Config: `
75+
resource scaleway_container_namespace main {
76+
name = "test-cr-ns-01"
77+
environment_variables = {
78+
"test" = "test"
79+
}
80+
secret_environment_variables = {
81+
"test_secret" = "test_secret"
82+
}
83+
tags = ["tag1", "tag2"]
84+
}
85+
`,
86+
Check: resource.ComposeTestCheckFunc(
87+
isNamespacePresent(tt, "scaleway_container_namespace.main"),
88+
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "description", ""),
89+
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "name", "test-cr-ns-01"),
90+
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "environment_variables.test", "test"),
91+
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "secret_environment_variables.test_secret", "test_secret"),
92+
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "tags.#", "2"),
93+
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "tags.0", "tag1"),
94+
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "tags.1", "tag2"),
95+
96+
acctest.CheckResourceAttrUUID("scaleway_container_namespace.main", "id"),
97+
),
98+
},
7399
{
74100
Config: `
75101
resource scaleway_container_namespace main {
@@ -80,6 +106,7 @@ func TestAccNamespace_Basic(t *testing.T) {
80106
resource.TestCheckResourceAttrSet("scaleway_container_namespace.main", "name"),
81107
resource.TestCheckResourceAttrSet("scaleway_container_namespace.main", "registry_endpoint"),
82108
resource.TestCheckResourceAttrSet("scaleway_container_namespace.main", "registry_namespace_id"),
109+
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "tags.#", "0"),
83110
),
84111
},
85112
{
@@ -99,7 +126,7 @@ func TestAccNamespace_Basic(t *testing.T) {
99126
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "name", "tf-env-test"),
100127
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "environment_variables.test", "test"),
101128
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "secret_environment_variables.test_secret", "test_secret"),
102-
129+
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "tags.#", "0"),
103130
acctest.CheckResourceAttrUUID("scaleway_container_namespace.main", "id"),
104131
),
105132
},
@@ -120,6 +147,23 @@ func TestAccNamespace_Basic(t *testing.T) {
120147
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "name", "tf-env-test"),
121148
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "environment_variables.foo", "bar"),
122149
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "secret_environment_variables.foo_secret", "bar_secret"),
150+
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "tags.#", "0"),
151+
acctest.CheckResourceAttrUUID("scaleway_container_namespace.main", "id"),
152+
),
153+
},
154+
{
155+
Config: `
156+
resource scaleway_container_namespace main {
157+
name = "tf-tags-test"
158+
tags = ["tag1", "tag2"]
159+
}
160+
`,
161+
Check: resource.ComposeTestCheckFunc(
162+
isNamespacePresent(tt, "scaleway_container_namespace.main"),
163+
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "name", "tf-tags-test"),
164+
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "tags.#", "2"),
165+
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "tags.0", "tag1"),
166+
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "tags.1", "tag2"),
123167

124168
acctest.CheckResourceAttrUUID("scaleway_container_namespace.main", "id"),
125169
),

0 commit comments

Comments
 (0)