Skip to content

Commit b6c2b16

Browse files
authored
Merge branch 'master' into compress_cassettes_ci
2 parents 7991ef4 + 600a290 commit b6c2b16

File tree

11 files changed

+118
-37
lines changed

11 files changed

+118
-37
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ require (
2929
github.com/nats-io/jwt/v2 v2.8.0
3030
github.com/nats-io/nats.go v1.46.1
3131
github.com/robfig/cron/v3 v3.0.1
32-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34.0.20250721082157-a9b7a7bd9686
32+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35
3333
github.com/stretchr/testify v1.11.1
3434
golang.org/x/crypto v0.42.0
3535
golang.org/x/sync v0.17.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
456456
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
457457
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
458458
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
459-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34.0.20250721082157-a9b7a7bd9686 h1:rSbtkU5fMMXbv0qwIH5dBq+TvAYnbClahwPP1KtN9bs=
460-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34.0.20250721082157-a9b7a7bd9686/go.mod h1:fw6BmcfYRs2BEHYW0c3/rR0JgZHvdx6uMYqpeUJx3Bc=
459+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35 h1:8xfn1RzeI9yoCUuEwDy08F+No6PcKZGEDOQ6hrRyLts=
460+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35/go.mod h1:47B1d/YXmSAxlJxUJxClzHR6b3T4M1WyCvwENPQNBWc=
461461
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
462462
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
463463
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=

internal/dsf/ip.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package dsf
2+
3+
import (
4+
"net"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
7+
)
8+
9+
func DiffSuppressFuncStandaloneIPandCIDR(_, oldValue, newValue string, _ *schema.ResourceData) bool {
10+
parseIPOrCIDR := func(s string) net.IP {
11+
if ip, _, err := net.ParseCIDR(s); err == nil {
12+
return ip
13+
}
14+
15+
return net.ParseIP(s)
16+
}
17+
18+
oldIP := parseIPOrCIDR(oldValue)
19+
newIP := parseIPOrCIDR(newValue)
20+
21+
return oldIP != nil && newIP != nil && oldIP.Equal(newIP)
22+
}

internal/dsf/ip_test.go

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package dsf_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/scaleway/terraform-provider-scaleway/v2/internal/dsf"
7+
)
8+
9+
func TestDiffSuppress_IPAMIP(t *testing.T) {
10+
tests := []struct {
11+
name string
12+
oldValue string
13+
newValue string
14+
want bool
15+
}{
16+
{
17+
name: "IP == IP",
18+
oldValue: "172.16.32.7",
19+
newValue: "172.16.32.7",
20+
want: true,
21+
},
22+
{
23+
name: "IP == IP/CIDR same host",
24+
oldValue: "172.16.32.7/22",
25+
newValue: "172.16.32.7",
26+
want: true,
27+
},
28+
{
29+
name: "IP/CIDR == IP same host (reversed)",
30+
oldValue: "172.16.32.7",
31+
newValue: "172.16.32.7/22",
32+
want: true,
33+
},
34+
{
35+
name: "Different host within same CIDR is NOT suppressed",
36+
oldValue: "172.16.32.7/22",
37+
newValue: "172.16.32.8",
38+
want: false,
39+
},
40+
{
41+
name: "Different host (plain IPs) is NOT suppressed",
42+
oldValue: "172.16.32.7",
43+
newValue: "172.16.32.8",
44+
want: false,
45+
},
46+
{
47+
name: "Equal but with /32 single-host CIDR",
48+
oldValue: "10.0.0.1/32",
49+
newValue: "10.0.0.1",
50+
want: true,
51+
},
52+
{
53+
name: "Broader CIDR vs network address should NOT suppress",
54+
oldValue: "10.0.0.1/24",
55+
newValue: "10.0.0.0",
56+
want: false,
57+
},
58+
{
59+
name: "Invalid old value -> not suppressed",
60+
oldValue: "not-an-ip",
61+
newValue: "10.0.0.1",
62+
want: false,
63+
},
64+
{
65+
name: "Invalid new value -> not suppressed",
66+
oldValue: "10.0.0.1",
67+
newValue: "bad/32",
68+
want: false,
69+
},
70+
{
71+
name: "Both invalid -> not suppressed",
72+
oldValue: "nope",
73+
newValue: "nope2",
74+
want: false,
75+
},
76+
}
77+
78+
for _, tt := range tests {
79+
t.Run(tt.name, func(t *testing.T) {
80+
got := dsf.DiffSuppressFuncStandaloneIPandCIDR("", tt.oldValue, tt.newValue, nil)
81+
if got != tt.want {
82+
t.Fatalf("diffSuppress(%q, %q) = %v, want %v", tt.oldValue, tt.newValue, got, tt.want)
83+
}
84+
})
85+
}
86+
}

internal/services/container/namespace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func ResourceContainerNamespaceCreate(ctx context.Context, d *schema.ResourceDat
122122
Name: types.ExpandOrGenerateString(d.Get("name").(string), "ns"),
123123
ProjectID: d.Get("project_id").(string),
124124
Region: region,
125-
ActivateVpcIntegration: true,
125+
ActivateVpcIntegration: scw.BoolPtr(true),
126126
}
127127

128128
rawTag, tagExist := d.GetOk("tags")

internal/services/function/namespace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func ResourceFunctionNamespaceCreate(ctx context.Context, d *schema.ResourceData
113113
Name: types.ExpandOrGenerateString(d.Get("name").(string), "func"),
114114
ProjectID: d.Get("project_id").(string),
115115
Region: region,
116-
ActivateVpcIntegration: true,
116+
ActivateVpcIntegration: scw.BoolPtr(true),
117117
}
118118

119119
rawTag, tagExist := d.GetOk("tags")

internal/services/iam/user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func resourceIamUserRead(ctx context.Context, d *schema.ResourceData, m any) dia
188188
_ = d.Set("deletable", user.Deletable)
189189
_ = d.Set("last_login_at", types.FlattenTime(user.LastLoginAt))
190190
_ = d.Set("type", user.Type)
191-
_ = d.Set("status", user.Status)
191+
_ = d.Set("status", user.Status.String()) //nolint:staticcheck // convert enum to string for schema compatibility
192192
_ = d.Set("mfa", user.Mfa)
193193
_ = d.Set("account_root_user_id", user.AccountRootUserID)
194194
_ = d.Set("locked", user.Locked)

internal/services/ipam/helpers.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package ipam
33
import (
44
"context"
55
"fmt"
6-
"net"
76
"time"
87

98
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -43,32 +42,6 @@ func NewAPIWithRegionAndID(m any, id string) (*ipam.API, scw.Region, string, err
4342
return ipamAPI, region, ID, err
4443
}
4544

46-
func diffSuppressFuncStandaloneIPandCIDR(_, oldValue, newValue string, _ *schema.ResourceData) bool {
47-
oldIP, oldNet, errOld := net.ParseCIDR(oldValue)
48-
if errOld != nil {
49-
oldIP = net.ParseIP(oldValue)
50-
}
51-
52-
newIP, newNet, errNew := net.ParseCIDR(newValue)
53-
if errNew != nil {
54-
newIP = net.ParseIP(newValue)
55-
}
56-
57-
if oldIP != nil && newIP != nil && oldIP.Equal(newIP) {
58-
return true
59-
}
60-
61-
if oldNet != nil && newIP != nil && oldNet.Contains(newIP) {
62-
return true
63-
}
64-
65-
if newNet != nil && oldIP != nil && newNet.Contains(oldIP) {
66-
return true
67-
}
68-
69-
return false
70-
}
71-
7245
type GetResourcePrivateIPsOptions struct {
7346
ResourceType *ipam.ResourceType
7447
ResourceID *string

internal/services/ipam/ip.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func ResourceIP() *schema.Resource {
3838
ForceNew: true,
3939
Description: "Request a specific IP in the requested source pool",
4040
ValidateFunc: validation.IsIPAddress,
41-
DiffSuppressFunc: diffSuppressFuncStandaloneIPandCIDR,
41+
DiffSuppressFunc: dsf.DiffSuppressFuncStandaloneIPandCIDR,
4242
},
4343
"source": {
4444
Type: schema.TypeList,

internal/services/webhosting/webhosting.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func resourceWebhostingRead(ctx context.Context, d *schema.ResourceData, m any)
303303
}
304304

305305
dnsRecordsResponse, err := dnsAPI.GetDomainDNSRecords(&webhosting.DNSAPIGetDomainDNSRecordsRequest{
306-
Domain: webhostingResponse.Domain,
306+
Domain: *webhostingResponse.Domain, //nolint:staticcheck // deprecated in SDK, kept until domain_info fully propagated
307307
}, scw.WithContext(ctx))
308308
if err != nil {
309309
return diag.FromErr(err)
@@ -314,7 +314,7 @@ func resourceWebhostingRead(ctx context.Context, d *schema.ResourceData, m any)
314314

315315
_ = d.Set("tags", webhostingResponse.Tags)
316316
_ = d.Set("offer_id", regional.NewIDString(region, webhostingResponse.Offer.ID))
317-
_ = d.Set("domain", webhostingResponse.Domain)
317+
_ = d.Set("domain", webhostingResponse.Domain) //nolint:staticcheck // deprecated in SDK, exported for backward compatibility
318318
_ = d.Set("created_at", types.FlattenTime(webhostingResponse.CreatedAt))
319319
_ = d.Set("updated_at", types.FlattenTime(webhostingResponse.UpdatedAt))
320320
_ = d.Set("status", webhostingResponse.Status.String())

0 commit comments

Comments
 (0)