Skip to content

Commit 92dfd6f

Browse files
Merge branch 'main' into mp/cdn/feat/implement-redirects
2 parents 45905c6 + 10c344f commit 92dfd6f

39 files changed

Lines changed: 755 additions & 670 deletions

docs/data-sources/loadbalancer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ data "stackit_loadbalancer" "example" {
4949

5050
Optional:
5151

52-
- `server_name_indicators` (Attributes List) A list of domain names to match in order to pass TLS traffic to the target pool in the current listener (see [below for nested schema](#nestedatt--listeners--server_name_indicators))
52+
- `server_name_indicators` (Attributes List, Deprecated) A list of domain names to match in order to pass TLS traffic to the target pool in the current listener (see [below for nested schema](#nestedatt--listeners--server_name_indicators))
5353

5454
Read-Only:
5555

docs/data-sources/opensearch_instance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ Read-Only:
5959
- `sgw_acl` (String) Comma separated list of IP networks in CIDR notation which are allowed to access this instance.
6060
- `syslog` (List of String) List of syslog servers to send logs to.
6161
- `tls_ciphers` (List of String) List of TLS ciphers to use.
62-
- `tls_protocols` (String) The TLS protocol to use.
62+
- `tls_protocols` (List of String) List of TLS protocols to use.

docs/resources/loadbalancer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ Required:
260260
Optional:
261261

262262
- `display_name` (String)
263-
- `server_name_indicators` (Attributes List) A list of domain names to match in order to pass TLS traffic to the target pool in the current listener (see [below for nested schema](#nestedatt--listeners--server_name_indicators))
263+
- `server_name_indicators` (Attributes List, Deprecated) A list of domain names to match in order to pass TLS traffic to the target pool in the current listener (see [below for nested schema](#nestedatt--listeners--server_name_indicators))
264264
- `tcp` (Attributes) Options that are specific to the TCP protocol. (see [below for nested schema](#nestedatt--listeners--tcp))
265265
- `udp` (Attributes) Options that are specific to the UDP protocol. (see [below for nested schema](#nestedatt--listeners--udp))
266266

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/stackitcloud/stackit-sdk-go/services/git v0.11.0
2121
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.5
2222
github.com/stackitcloud/stackit-sdk-go/services/kms v1.6.0
23-
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.8.0
23+
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.11.1
2424
github.com/stackitcloud/stackit-sdk-go/services/logme v0.27.1
2525
github.com/stackitcloud/stackit-sdk-go/services/logs v0.7.1
2626
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.27.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN
153153
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
154154
github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8=
155155
github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY=
156-
github.com/stackitcloud/stackit-sdk-go/core v0.23.0 h1:zPrOhf3Xe47rKRs1fg/AqKYUiJJRYjdcv+3qsS50mEs=
157-
github.com/stackitcloud/stackit-sdk-go/core v0.23.0/go.mod h1:osMglDby4csGZ5sIfhNyYq1bS1TxIdPY88+skE/kkmI=
158156
github.com/stackitcloud/stackit-sdk-go/core v0.24.0 h1:kHCcezCJ5OGSP7RRuGOxD5rF2wejpkEiRr/OdvNcuPQ=
159157
github.com/stackitcloud/stackit-sdk-go/core v0.24.0/go.mod h1:osMglDby4csGZ5sIfhNyYq1bS1TxIdPY88+skE/kkmI=
160158
github.com/stackitcloud/stackit-sdk-go/services/alb v0.12.1 h1:RKaxAymxlyxxE0Gta3yRuQWf07LnlcX+mfGnVB96NHA=
@@ -175,6 +173,8 @@ github.com/stackitcloud/stackit-sdk-go/services/kms v1.6.0 h1:WWU2LpqmazsPDgoRAV
175173
github.com/stackitcloud/stackit-sdk-go/services/kms v1.6.0/go.mod h1:FuyCm3s/Ihw+tkpVLGMXwgTtlhrijd31cUCUBWpn1p8=
176174
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.8.0 h1:DxrN85V738CRLynu6MULQHO+OXyYnkhVPgoZKULfFIs=
177175
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.8.0/go.mod h1:ClPE4TOM1FeaJiwTXvApq4gWaSgTLq6nU3PPHAIQDN4=
176+
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.11.1 h1:8hLLCP4n9w3K3dqJaKF1PnMpX4qjR8UQL3gDr80hgDI=
177+
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.11.1/go.mod h1:vqTjmecQ4+oVWzeo9tCOUZ3TrpIIzM+C0apC7cdAD0Y=
178178
github.com/stackitcloud/stackit-sdk-go/services/logme v0.27.1 h1:6AaWxQNtOEvIvbtyySi5KIrNzxGbKgOayUnA3fpuqns=
179179
github.com/stackitcloud/stackit-sdk-go/services/logme v0.27.1/go.mod h1:qwpGNPgF7LmfodGPXcgv9uldeSSuFMNJkyD6QPqfiCI=
180180
github.com/stackitcloud/stackit-sdk-go/services/logs v0.7.1 h1:cuQA5dO8WSM0LBHR2FBpf+RgKH7/DE7+5NUPLxDpgPg=

golang-ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ linters:
4040
- typeDefFirst
4141
- ifElseChain
4242
- dupImport # https://github.com/go-critic/go-critic/issues/845
43+
- rangeValCopy
4344
enabled-tags:
4445
- performance
4546
- style

stackit/internal/conversion/conversion.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ func Int64ValueToPointer(s basetypes.Int64Value) *int64 {
108108
return &value
109109
}
110110

111+
// Float32ValueToPointer converts basetypes.Float32Value to a pointer to float32.
112+
// It returns nil if the value is null or unknown.
113+
func Float32ValueToPointer(s basetypes.Float32Value) *float32 {
114+
if s.IsNull() || s.IsUnknown() {
115+
return nil
116+
}
117+
value := s.ValueFloat32()
118+
return &value
119+
}
120+
111121
// Float64ValueToPointer converts basetypes.Float64Value to a pointer to float64.
112122
// It returns nil if the value is null or unknown.
113123
func Float64ValueToPointer(s basetypes.Float64Value) *float64 {
@@ -131,11 +141,21 @@ func BoolValueToPointer(s basetypes.BoolValue) *bool {
131141
// StringListToPointer converts basetypes.ListValue to a pointer to a list of strings.
132142
// It returns nil if the value is null or unknown.
133143
func StringListToPointer(list basetypes.ListValue) (*[]string, error) {
144+
result, err := StringListToSlice(list)
145+
if result == nil {
146+
return nil, err
147+
}
148+
return &result, err
149+
}
150+
151+
// StringListToSlice converts basetypes.ListValue to a list of strings.
152+
// It returns nil if the value is null or unknown.
153+
func StringListToSlice(list basetypes.ListValue) ([]string, error) {
134154
if list.IsNull() || list.IsUnknown() {
135155
return nil, nil
136156
}
137157

138-
listStr := []string{}
158+
var listStr []string
139159
for i, el := range list.Elements() {
140160
elStr, ok := el.(types.String)
141161
if !ok {
@@ -144,7 +164,7 @@ func StringListToPointer(list basetypes.ListValue) (*[]string, error) {
144164
listStr = append(listStr, elStr.ValueString())
145165
}
146166

147-
return &listStr, nil
167+
return listStr, nil
148168
}
149169

150170
// StringSetToPointer converts basetypes.SetValue to a pointer to a list of strings.

stackit/internal/conversion/conversion_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,59 @@ func TestStringSetToSlice(t *testing.T) {
449449
})
450450
}
451451
}
452+
453+
func TestStringListToSlice(t *testing.T) {
454+
t.Parallel()
455+
tests := []struct {
456+
name string
457+
in basetypes.ListValue
458+
want []string
459+
wantErr bool
460+
}{
461+
{
462+
name: "unknown",
463+
in: basetypes.NewListUnknown(types.StringType),
464+
want: nil,
465+
},
466+
{
467+
name: "null",
468+
in: basetypes.NewListNull(types.StringType),
469+
want: nil,
470+
},
471+
{
472+
name: "invalid type",
473+
in: basetypes.NewListValueMust(types.Int64Type, []attr.Value{types.Int64Value(123)}),
474+
wantErr: true,
475+
},
476+
{
477+
name: "some values",
478+
in: basetypes.NewListValueMust(
479+
types.StringType,
480+
[]attr.Value{
481+
types.StringValue("abc"),
482+
types.StringValue("xyz"),
483+
},
484+
),
485+
want: []string{
486+
"abc",
487+
"xyz",
488+
},
489+
},
490+
}
491+
492+
for _, tt := range tests {
493+
t.Run(tt.name, func(t *testing.T) {
494+
t.Parallel()
495+
got, err := StringListToSlice(tt.in)
496+
if tt.wantErr && err == nil {
497+
t.Fatal("expected error")
498+
}
499+
if !tt.wantErr && err != nil {
500+
t.Fatalf("expected no error, got: %v", err)
501+
}
502+
if d := cmp.Diff(got, tt.want); d != "" {
503+
t.Fatalf("no match, diff: %s", d)
504+
}
505+
})
506+
}
507+
}

stackit/internal/core/core.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import (
77
"strings"
88
"time"
99

10-
"github.com/hashicorp/terraform-plugin-framework/types"
11-
"github.com/stackitcloud/stackit-sdk-go/core/runtime"
12-
1310
"github.com/hashicorp/terraform-plugin-framework/diag"
11+
"github.com/hashicorp/terraform-plugin-framework/types"
1412
"github.com/hashicorp/terraform-plugin-log/tflog"
13+
"github.com/stackitcloud/stackit-sdk-go/core/runtime"
1514
)
1615

1716
type ResourceType string

stackit/internal/services/iaas/server/resource.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010
"time"
1111

12+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
1213
iaasUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/iaas/utils"
1314

1415
"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
@@ -314,6 +315,9 @@ func (r *serverResource) Schema(_ context.Context, _ resource.SchemaRequest, res
314315
PlanModifiers: []planmodifier.String{
315316
stringplanmodifier.RequiresReplace(),
316317
},
318+
Validators: []validator.String{
319+
stringvalidator.OneOf(supportedSourceTypes...),
320+
},
317321
},
318322
"source_id": schema.StringAttribute{
319323
Description: "The ID of the source, either image ID or volume ID",
@@ -326,6 +330,7 @@ func (r *serverResource) Schema(_ context.Context, _ resource.SchemaRequest, res
326330
Description: "Delete the volume during the termination of the server. Only allowed when `source_type` is `image`.",
327331
Optional: true,
328332
Computed: true,
333+
Default: booldefault.StaticBool(false),
329334
PlanModifiers: []planmodifier.Bool{
330335
boolplanmodifier.RequiresReplace(),
331336
},

0 commit comments

Comments
 (0)