Feature: allow system components on nodepools (#591)

* feat: allow system components on nodepools

* docs: generated docs for ske

* lint: sort imports

* revert changes
This commit is contained in:
Mauritz Uphoff 2024-11-13 11:44:55 +01:00 committed by GitHub
parent 2bf6a8dce7
commit 3ac1d50253
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 155 additions and 59 deletions

View file

@ -8,8 +8,10 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/stackitcloud/stackit-sdk-go/core/utils"
"github.com/stackitcloud/stackit-sdk-go/services/ske"
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
)
@ -106,7 +108,8 @@ func TestMapFields(t *testing.T) {
Name: utils.Ptr("name"),
Nodepools: &[]ske.Nodepool{
{
AvailabilityZones: &[]string{"z1", "z2"},
AllowSystemComponents: utils.Ptr(true),
AvailabilityZones: &[]string{"z1", "z2"},
Cri: &ske.CRI{
Name: utils.Ptr("cri"),
},
@ -195,6 +198,7 @@ func TestMapFields(t *testing.T) {
types.StringValue("z2"),
},
),
"allow_system_components": types.BoolValue(true),
},
),
},
@ -481,6 +485,7 @@ func TestMapFields(t *testing.T) {
types.StringValue("z2"),
},
),
"allow_system_components": types.BoolValue(true),
},
),
},
@ -599,6 +604,7 @@ func TestMapFields(t *testing.T) {
types.StringValue("z2"),
},
),
"allow_system_components": types.BoolNull(),
},
),
},
@ -2284,3 +2290,57 @@ func TestToNetworkPayload(t *testing.T) {
})
}
}
func TestVerifySystemComponentNodepools(t *testing.T) {
tests := []struct {
description string
nodePools []ske.Nodepool
isValid bool
}{
{
description: "all pools allow system components",
nodePools: []ske.Nodepool{
{
AllowSystemComponents: conversion.BoolValueToPointer(basetypes.NewBoolValue(true)),
},
{
AllowSystemComponents: conversion.BoolValueToPointer(basetypes.NewBoolValue(true)),
},
},
isValid: true,
},
{
description: "one pool allows system components",
nodePools: []ske.Nodepool{
{
AllowSystemComponents: conversion.BoolValueToPointer(basetypes.NewBoolValue(true)),
},
{
AllowSystemComponents: conversion.BoolValueToPointer(basetypes.NewBoolValue(false)),
},
},
isValid: true,
},
{
description: "no pool allows system components",
nodePools: []ske.Nodepool{
{
AllowSystemComponents: conversion.BoolValueToPointer(basetypes.NewBoolValue(false)),
},
{
AllowSystemComponents: conversion.BoolValueToPointer(basetypes.NewBoolValue(false)),
},
},
isValid: false,
},
}
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
err := verifySystemComponentsInNodePools(tt.nodePools)
if (err == nil) != tt.isValid {
t.Errorf("expected validity to be %v, but got error: %v", tt.isValid, err)
}
})
}
}