Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ require (
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
github.com/stackitcloud/stackit-sdk-go/core v0.22.0
github.com/stackitcloud/stackit-sdk-go/core v0.23.0
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0
github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.6
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.5
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.7.0
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.8.0
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.19.0
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.20.1
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0
go.uber.org/atomic v1.11.0
go.uber.org/mock v0.6.0
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -465,18 +465,18 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stackitcloud/stackit-sdk-go/core v0.22.0 h1:6rViz7GnNwXSh51Lur5xuDzO8EWSZfN9J0HvEkBKq6c=
github.com/stackitcloud/stackit-sdk-go/core v0.22.0/go.mod h1:osMglDby4csGZ5sIfhNyYq1bS1TxIdPY88+skE/kkmI=
github.com/stackitcloud/stackit-sdk-go/core v0.23.0 h1:zPrOhf3Xe47rKRs1fg/AqKYUiJJRYjdcv+3qsS50mEs=
github.com/stackitcloud/stackit-sdk-go/core v0.23.0/go.mod h1:osMglDby4csGZ5sIfhNyYq1bS1TxIdPY88+skE/kkmI=
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0 h1:HxPgBu04j5tj6nfZ2r0l6v4VXC0/tYOGe4sA5Addra8=
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0/go.mod h1:uYI9pHAA2g84jJN25ejFUxa0/JtfpPZqMDkctQ1BzJk=
github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.6 h1:GBRb49x5Nax/oQQaaf2F3kKwv8DQQOL0TQOC0C/v/Ew=
github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.6/go.mod h1:IX9iL3MigDZUmzwswTJMfYvyi118KAHrFMfjJUy5NYk=
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.5 h1:W57+XRa8wTLsi5CV9Tqa7mGgt/PvlRM//RurXSmvII8=
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.5/go.mod h1:lTWjW57eAq1bwfM6nsNinhoBr3MHFW/GaFasdAsYfDM=
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.7.0 h1:WyOC7tEazOPF9PwlExsycYvhm2l9OcjGQfZHDAckVIc=
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.7.0/go.mod h1:78hDXs5sEokK2sAaBSn79kodytszmDYEAuMS56kPHIw=
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.8.0 h1:DxrN85V738CRLynu6MULQHO+OXyYnkhVPgoZKULfFIs=
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.8.0/go.mod h1:ClPE4TOM1FeaJiwTXvApq4gWaSgTLq6nU3PPHAIQDN4=
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.19.0 h1:OcjYHjTsKLlOz8GF2owYdJK0cUqGGzjHRQLYUH0vMnQ=
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.19.0/go.mod h1:jiPIzF8lcm5Dx0TkDK2CBgeRBHSRUqwyX+z/zqo1bes=
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.20.1 h1:IvZqEXjRjXrkjY0aSZFZ5zccOr2ZB+fj+N8AG46ajC4=
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.20.1/go.mod h1:yjrIuyp6+6RCYTiP77NGV1DniULFyhLTz9B5ebwvF40=
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0 h1:l1EDIlXce2C8JcbBDHVa6nZ4SjPTqmnALTgrhms+NKI=
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.12.0/go.mod h1:EXq8/J7t9p8zPmdIq+atuxyAbnQwxrQT18fI+Qpv98k=
github.com/stoewer/go-strcase v1.3.1 h1:iS0MdW+kVTxgMoE1LAZyMiYJFKlOzLooE4MxjirtkAs=
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/bastion/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
extensionsv1alpha1 "github.com/gardener/gardener/pkg/apis/extensions/v1alpha1"
"github.com/gardener/gardener/pkg/controllerutils/reconciler"
"github.com/go-logr/logr"
iaaswait "github.com/stackitcloud/stackit-sdk-go/services/iaas/wait"
iaaswait "github.com/stackitcloud/stackit-sdk-go/services/iaas/v2api/wait"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/bastion/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/go-logr/logr"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
iaas "github.com/stackitcloud/stackit-sdk-go/services/iaas/v2api"

stackitclient "github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/stackit/client"
)
Expand Down
7 changes: 3 additions & 4 deletions pkg/controller/bastion/resources_public_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import (
"fmt"

"github.com/go-logr/logr"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
"k8s.io/utils/ptr"
iaas "github.com/stackitcloud/stackit-sdk-go/services/iaas/v2api"

"github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/stackit"
)
Expand All @@ -15,7 +14,7 @@ func (r *Resources) reconcilePublicIP(ctx context.Context, log logr.Logger) erro
if r.PublicIP == nil {
var err error
r.PublicIP, err = r.IaaS.CreatePublicIp(ctx, iaas.CreatePublicIPPayload{
Labels: new(stackit.ToLabels(r.Labels)),
Labels: stackit.ToLabels(r.Labels),
})
if err != nil {
return fmt.Errorf("error creating public IP: %w", err)
Expand All @@ -24,7 +23,7 @@ func (r *Resources) reconcilePublicIP(ctx context.Context, log logr.Logger) erro
log.Info("Created public IP", "publicIP", r.PublicIP.GetId())
}

if networkInterface := ptr.Deref(r.PublicIP.GetNetworkInterface(), ""); networkInterface != "" {
if networkInterface := r.PublicIP.GetNetworkInterface(); networkInterface != "" {
log.V(1).Info("Public IP is already associated with network interface", "publicIP", r.PublicIP.GetId(), "networkInterface", networkInterface)
return nil
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/controller/bastion/resources_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/netip"

"github.com/go-logr/logr"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
iaas "github.com/stackitcloud/stackit-sdk-go/services/iaas/v2api"

"github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/stackit"
stackitclient "github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/stackit/client"
Expand All @@ -20,8 +20,8 @@ func (r *Resources) reconcileSecurityGroup(ctx context.Context, log logr.Logger)
if r.SecurityGroup == nil {
var err error
r.SecurityGroup, err = r.IaaS.CreateSecurityGroup(ctx, iaas.CreateSecurityGroupPayload{
Name: new(r.ResourceName),
Labels: new(stackit.ToLabels(r.Labels)),
Name: r.ResourceName,
Labels: stackit.ToLabels(r.Labels),

Description: new("Security group for Bastion " + r.Bastion.Name),
})
Expand Down Expand Up @@ -61,7 +61,7 @@ func (o *Options) determineWantedSecurityGroupRules() ([]iaas.SecurityGroupRule,
// DHCP tells us our IP and the route to the metadata server
Description: new("Allow DHCP requests"),

Direction: new(stackit.DirectionEgress),
Direction: stackit.DirectionEgress,
Ethertype: new(stackit.EtherTypeIPv4),
Protocol: new(stackit.ProtocolUDP),
PortRange: iaas.NewPortRange(68, 67),
Expand All @@ -71,7 +71,7 @@ func (o *Options) determineWantedSecurityGroupRules() ([]iaas.SecurityGroupRule,
{
Description: new("Allow egress to metadata server"),

Direction: new(stackit.DirectionEgress),
Direction: stackit.DirectionEgress,
Ethertype: new(stackit.EtherTypeIPv4),
Protocol: new(stackit.ProtocolTCP),
PortRange: iaas.NewPortRange(80, 80),
Expand All @@ -81,7 +81,7 @@ func (o *Options) determineWantedSecurityGroupRules() ([]iaas.SecurityGroupRule,
{
Description: new(fmt.Sprintf("Allow egress from Bastion %s to %s worker nodes", o.Bastion.Name, o.TechnicalID)),

Direction: new(stackit.DirectionEgress),
Direction: stackit.DirectionEgress,
Ethertype: new(stackit.EtherTypeIPv4),
Protocol: new(stackit.ProtocolTCP),
PortRange: portRangeSSH,
Expand All @@ -95,7 +95,7 @@ func (o *Options) determineWantedSecurityGroupRules() ([]iaas.SecurityGroupRule,
rules = append(rules, iaas.SecurityGroupRule{
Description: new(fmt.Sprintf("Allow ingress to Bastion %s from world", o.Bastion.Name)),

Direction: new(stackit.DirectionIngress),
Direction: stackit.DirectionIngress,
Ethertype: new(stackit.EtherTypeIPv4),
Protocol: new(stackit.ProtocolTCP),
PortRange: portRangeSSH,
Expand All @@ -120,7 +120,7 @@ func (o *Options) determineWantedSecurityGroupRules() ([]iaas.SecurityGroupRule,
rules = append(rules, iaas.SecurityGroupRule{
Description: new(fmt.Sprintf("Allow ingress to Bastion %s from %s", o.Bastion.Name, normalizedCIDR)),

Direction: new(stackit.DirectionIngress),
Direction: stackit.DirectionIngress,
Ethertype: new(etherType),
Protocol: new(stackit.ProtocolTCP),
PortRange: portRangeSSH,
Expand All @@ -137,7 +137,7 @@ func (r *Resources) reconcileWorkerSecurityGroupRule(ctx context.Context, log lo
wantedRule := iaas.SecurityGroupRule{
Description: new(fmt.Sprintf("Allow ingress to shoot worker nodes from Bastion %s", r.Bastion.Name)),

Direction: new(stackit.DirectionIngress),
Direction: stackit.DirectionIngress,
Ethertype: new(stackit.EtherTypeIPv4),
Protocol: new(stackit.ProtocolTCP),
PortRange: portRangeSSH,
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/bastion/resources_security_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
extensionsv1alpha1 "github.com/gardener/gardener/pkg/apis/extensions/v1alpha1"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
iaas "github.com/stackitcloud/stackit-sdk-go/services/iaas/v2api"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand Down Expand Up @@ -47,7 +47,7 @@ var _ = Describe("Security Group", func() {
iaas.SecurityGroupRule{
Description: new(fmt.Sprintf("Allow ingress to Bastion %s from %s", o.Bastion.Name, "1.2.3.4/32")),

Direction: new(stackit.DirectionIngress),
Direction: stackit.DirectionIngress,
Ethertype: new(stackit.EtherTypeIPv4),
Protocol: new(stackit.ProtocolTCP),
PortRange: iaas.NewPortRange(22, 22),
Expand All @@ -57,7 +57,7 @@ var _ = Describe("Security Group", func() {
iaas.SecurityGroupRule{
Description: new(fmt.Sprintf("Allow ingress to Bastion %s from %s", o.Bastion.Name, "2001:db8:1::/48")),

Direction: new(stackit.DirectionIngress),
Direction: stackit.DirectionIngress,
Ethertype: new(stackit.EtherTypeIPv6),
Protocol: new(stackit.ProtocolTCP),
PortRange: iaas.NewPortRange(22, 22),
Expand All @@ -74,7 +74,7 @@ var _ = Describe("Security Group", func() {
iaas.SecurityGroupRule{
Description: new(fmt.Sprintf("Allow ingress to Bastion %s from world", o.Bastion.Name)),

Direction: new(stackit.DirectionIngress),
Direction: stackit.DirectionIngress,
Ethertype: new(stackit.EtherTypeIPv4),
Protocol: new(stackit.ProtocolTCP),
PortRange: iaas.NewPortRange(22, 22),
Expand Down
18 changes: 9 additions & 9 deletions pkg/controller/bastion/resources_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/go-logr/logr"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
iaas "github.com/stackitcloud/stackit-sdk-go/services/iaas/v2api"

"github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/stackit"
)
Expand All @@ -18,24 +18,24 @@ func (r *Resources) reconcileServer(ctx context.Context, log logr.Logger) error

var err error
r.Server, err = r.IaaS.CreateServer(ctx, iaas.CreateServerPayload{
Name: new(r.ResourceName),
Labels: new(stackit.ToLabels(r.Labels)),
Name: r.ResourceName,
Labels: stackit.ToLabels(r.Labels),

AvailabilityZone: new(r.AvailabilityZone),
MachineType: new(r.MachineType),
BootVolume: &iaas.ServerBootVolume{
MachineType: r.MachineType,
BootVolume: &iaas.BootVolume{
DeleteOnTermination: new(true),
Source: iaas.NewBootVolumeSource(r.ImageID, "image"),
// TODO: make size and performance class configurable
Size: new(int64(10)),
},

SecurityGroups: new([]string{r.SecurityGroup.GetId()}),
Networking: new(iaas.CreateServerNetworkingAsCreateServerPayloadAllOfNetworking(&iaas.CreateServerNetworking{
SecurityGroups: []string{r.SecurityGroup.GetId()},
Networking: iaas.CreateServerNetworkingAsCreateServerPayloadAllOfNetworking(&iaas.CreateServerNetworking{
NetworkId: new(r.NetworkID),
})),
}),

UserData: new(r.Bastion.Spec.UserData),
UserData: new(string(r.Bastion.Spec.UserData)),
})
if err != nil {
return fmt.Errorf("error creating server: %w", err)
Expand Down
30 changes: 15 additions & 15 deletions pkg/controller/bastion/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/go-logr/logr"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
iaas "github.com/stackitcloud/stackit-sdk-go/services/iaas/v2api"
"go.uber.org/mock/gomock"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand Down Expand Up @@ -47,10 +47,10 @@ var _ = Describe("Bastion Resources", func() {
resources.ResourceName = "test-resource"
resources.Labels = map[string]string{"test-labels-key": "test-labels-value"}

expectedSecurityGroup := []iaas.SecurityGroup{{Name: new("test-security-group")}}
expectedSecurityGroup := []iaas.SecurityGroup{{Name: "test-security-group"}}
mockIaaS.EXPECT().GetSecurityGroupByName(ctx, resources.ResourceName).Return(expectedSecurityGroup, nil)

expectedServer := []iaas.Server{{Name: new("test-server")}}
expectedServer := []iaas.Server{{Name: "test-server"}}
mockIaaS.EXPECT().GetServerByName(ctx, resources.ResourceName).Return(expectedServer, nil)

expectedPublicIP := []iaas.PublicIp{{Id: new("test-ip")}}
Expand Down Expand Up @@ -157,7 +157,7 @@ var _ = Describe("Bastion Resources", func() {
}
resources.PublicIP = &iaas.PublicIp{
Id: new("test-public-ip"),
NetworkInterface: iaas.NewNullableString(new("test-interface")),
NetworkInterface: *iaas.NewNullableString(new("test-interface")),
}

err := resources.reconcilePublicIP(ctx, logger)
Expand Down Expand Up @@ -222,23 +222,23 @@ var _ = Describe("Bastion Resources", func() {
resources.SecurityGroup = &iaas.SecurityGroup{Id: new("test-security-group")}

expectedPayload := iaas.CreateServerPayload{
Name: new("test-resource"),
Labels: new(stackit.ToLabels(map[string]string{
Name: "test-resource",
Labels: stackit.ToLabels(map[string]string{
"test-label-key": "test-label-value",
})),
}),
AvailabilityZone: new("test-az"),
MachineType: new("test-machine"),
BootVolume: &iaas.ServerBootVolume{
MachineType: "test-machine",
BootVolume: &iaas.BootVolume{
DeleteOnTermination: new(true),
Source: iaas.NewBootVolumeSource("test-image", "image"),
Size: new(int64(10)),
},
SecurityGroups: new([]string{"test-security-group"}),
Networking: new(iaas.CreateServerNetworkingAsCreateServerPayloadAllOfNetworking(&iaas.CreateServerNetworking{
SecurityGroups: []string{"test-security-group"},
Networking: iaas.CreateServerNetworkingAsCreateServerPayloadAllOfNetworking(&iaas.CreateServerNetworking{
NetworkId: new("test-network"),
})),
}),

UserData: new([]byte{1, 2, 3, 4}),
UserData: new(string([]byte{1, 2, 3, 4})),
}
expectedServer := &iaas.Server{
Id: new("test-server"),
Expand Down Expand Up @@ -292,8 +292,8 @@ var _ = Describe("Bastion Resources", func() {
}

expectedPayload := iaas.CreateSecurityGroupPayload{
Name: new("test-resource"),
Labels: new(stackit.ToLabels(map[string]string{"test-labels-key": "test-labels-value"})),
Name: "test-resource",
Labels: stackit.ToLabels(map[string]string{"test-labels-key": "test-labels-value"}),
Description: new("Security group for Bastion test-bastion"),
}
expectedSecurityGroup := &iaas.SecurityGroup{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ func (fctx *FlowContext) ensureStackitSSHKeyPair(ctx context.Context) error {
return err
}
if keyPair != nil {
publicKey := ptr.Deref(keyPair.PublicKey, "")
publicKey := keyPair.PublicKey
// if the public keys are matching then return early. In all other cases we should be creating (or replacing) the keypair with a new one.
if publicKey != "" && publicKey == string(fctx.infra.Spec.SSHPublicKey) {
fctx.state.Set(NameKeyPair, *keyPair.Name)
Expand Down
Loading