Skip to content

Commit 8733df5

Browse files
authored
Merge branch 'master' into feat/add-lb-pn-resource
2 parents 5ec856f + ff08324 commit 8733df5

File tree

10 files changed

+509
-779
lines changed

10 files changed

+509
-779
lines changed

docs/resources/edge_services_dns_stage.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ In addition to all arguments above, the following attributes are exported:
3333

3434
- `id` - The ID of the DNS stage (UUID format).
3535
- `type` - The type of the stage.
36+
- `default_fqdn` - The Default Fully Qualified Domain Name attached to the stage.
3637
- `created_at` - The date and time of the creation of the DNS stage.
3738
- `updated_at` - The date and time of the last update of the DNS stage.
3839

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ require (
3030
github.com/nats-io/jwt/v2 v2.8.0
3131
github.com/nats-io/nats.go v1.46.1
3232
github.com/robfig/cron/v3 v3.0.1
33-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251015050748-12aafea99911
33+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251017125838-3eb0f2adaa94
3434
github.com/stretchr/testify v1.11.1
3535
golang.org/x/crypto v0.43.0
3636
golang.org/x/sync v0.17.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
457457
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
458458
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
459459
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
460-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251015050748-12aafea99911 h1:puwRtGGoGw9Rw3qlB7ltimV2+uugkalN08DyVEL1VoE=
461-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251015050748-12aafea99911/go.mod h1:SVm1Zk6UpZtqZN6KtEQpjC+v+Lir4tyVfhQTU19q3PA=
460+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251017125838-3eb0f2adaa94 h1:39j+3zweuYVml1Ozahl7RVb0AtpaiQtRztjq4W3GvNM=
461+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251017125838-3eb0f2adaa94/go.mod h1:SVm1Zk6UpZtqZN6KtEQpjC+v+Lir4tyVfhQTU19q3PA=
462462
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
463463
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
464464
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=

internal/services/edgeservices/dns_stage.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ func ResourceDNSStage() *schema.Resource {
6363
Computed: true,
6464
Description: "The type of the stage",
6565
},
66+
"default_fqdn": {
67+
Type: schema.TypeString,
68+
Computed: true,
69+
Description: "Default Fully Qualified Domain Name attached to the stage",
70+
},
6671
"created_at": {
6772
Type: schema.TypeString,
6873
Computed: true,
@@ -120,6 +125,7 @@ func ResourceDNSStageRead(ctx context.Context, d *schema.ResourceData, m any) di
120125
_ = d.Set("created_at", types.FlattenTime(dnsStage.CreatedAt))
121126
_ = d.Set("updated_at", types.FlattenTime(dnsStage.UpdatedAt))
122127
_ = d.Set("type", dnsStage.Type.String())
128+
_ = d.Set("default_fqdn", dnsStage.DefaultFqdn)
123129

124130
oldFQDNs := d.Get("fqdns").([]any)
125131
oldFQDNsSet := make(map[string]bool)

internal/services/webhosting/helpers.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package webhosting
22

33
import (
44
"context"
5+
"strings"
56
"time"
67

78
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -79,9 +80,15 @@ func waitForHosting(ctx context.Context, api *webhosting.HostingAPI, region scw.
7980

8081
func flattenDNSRecords(records []*webhosting.DNSRecord) []map[string]any {
8182
result := []map[string]any{}
83+
8284
for _, r := range records {
85+
name := r.Name
86+
if name == "" {
87+
name = extractDNSRecordName(r.RawData)
88+
}
89+
8390
result = append(result, map[string]any{
84-
"name": r.Name,
91+
"name": name,
8592
"type": r.Type.String(),
8693
"ttl": r.TTL,
8794
"value": r.Value,
@@ -93,6 +100,15 @@ func flattenDNSRecords(records []*webhosting.DNSRecord) []map[string]any {
93100
return result
94101
}
95102

103+
func extractDNSRecordName(raw string) string {
104+
fields := strings.Fields(raw)
105+
if len(fields) == 0 {
106+
return ""
107+
}
108+
109+
return strings.TrimSuffix(fields[0], ".")
110+
}
111+
96112
func flattenNameServers(servers []*webhosting.Nameserver) []map[string]any {
97113
result := []map[string]any{}
98114
for _, s := range servers {

internal/services/webhosting/testdata/data-source-offer-basic.cassette.yaml

Lines changed: 48 additions & 244 deletions
Large diffs are not rendered by default.

internal/services/webhosting/testdata/data-source-webhosting-basic.cassette.yaml

Lines changed: 283 additions & 283 deletions
Large diffs are not rendered by default.

internal/services/webhosting/testdata/webhosting-basic.cassette.yaml

Lines changed: 148 additions & 246 deletions
Large diffs are not rendered by default.

internal/services/webhosting/webhosting_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ func TestAccWebhosting_Basic(t *testing.T) {
3535
resource "scaleway_webhosting" "main" {
3636
offer_id = data.scaleway_webhosting_offer.by_name.offer_id
3737
38-
domain = "scaleway.com"
38+
domain = "devtools-tf-tests.scaleway.com"
3939
tags = ["devtools", "provider", "terraform"]
4040
}
4141
`,
4242
Check: resource.ComposeTestCheckFunc(
4343
testAccCheckWebhostingExists(tt, "scaleway_webhosting.main"),
4444
resource.TestCheckResourceAttrPair("scaleway_webhosting.main", "offer_id", "data.scaleway_webhosting_offer.by_name", "offer_id"),
4545
resource.TestCheckResourceAttr("scaleway_webhosting.main", "email", "[email protected]"),
46-
resource.TestCheckResourceAttr("scaleway_webhosting.main", "domain", "scaleway.com"),
46+
resource.TestCheckResourceAttr("scaleway_webhosting.main", "domain", "devtools-tf-tests.scaleway.com"),
4747
resource.TestCheckResourceAttr("scaleway_webhosting.main", "status", webhostingSDK.HostingStatusReady.String()),
4848
resource.TestCheckResourceAttr("scaleway_webhosting.main", "tags.0", "devtools"),
4949
resource.TestCheckResourceAttr("scaleway_webhosting.main", "tags.1", "provider"),

templates/resources/edge_services_dns_stage.md.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ In addition to all arguments above, the following attributes are exported:
3434

3535
- `id` - The ID of the DNS stage (UUID format).
3636
- `type` - The type of the stage.
37+
- `default_fqdn` - The Default Fully Qualified Domain Name attached to the stage.
3738
- `created_at` - The date and time of the creation of the DNS stage.
3839
- `updated_at` - The date and time of the last update of the DNS stage.
3940

0 commit comments

Comments
 (0)