Skip to content

Commit

Permalink
Fix missing ptr package import
Browse files Browse the repository at this point in the history
  • Loading branch information
avorima committed Mar 13, 2024
1 parent 42b8df2 commit 34108be
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider"
ionos "k8s.io/autoscaler/cluster-autoscaler/cloudprovider/ionoscloud/ionos-cloud-sdk-go"
"k8s.io/utils/ptr"
)

var (
Expand Down Expand Up @@ -137,16 +136,16 @@ func TestCreateIonosCloudManager(t *testing.T) {

func newKubernetesNodePool(state string, size int32) *ionos.KubernetesNodePool {
return &ionos.KubernetesNodePool{
Id: ptr.To("test"),
Metadata: &ionos.DatacenterElementMetadata{State: ptr.To(state)},
Properties: &ionos.KubernetesNodePoolProperties{NodeCount: ptr.To(size)},
Id: ptrTo("test"),
Metadata: &ionos.DatacenterElementMetadata{State: ptrTo(state)},
Properties: &ionos.KubernetesNodePoolProperties{NodeCount: ptrTo(size)},
}
}

func newKubernetesNode(id, state string) ionos.KubernetesNode {
return ionos.KubernetesNode{
Id: ptr.To(id),
Metadata: &ionos.KubernetesNodeMetadata{State: ptr.To(state)},
Id: ptrTo(id),
Metadata: &ionos.KubernetesNodeMetadata{State: ptrTo(state)},
}
}

Expand Down
39 changes: 21 additions & 18 deletions cluster-autoscaler/cloudprovider/ionoscloud/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,54 +22,57 @@ import (
"github.com/stretchr/testify/require"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider"
ionos "k8s.io/autoscaler/cluster-autoscaler/cloudprovider/ionoscloud/ionos-cloud-sdk-go"
"k8s.io/utils/ptr"
)

func ptrTo[T any](v T) *T {
return &v
}

var (
kubernetesNodes = []ionos.KubernetesNode{
{
Id: ptr.To("1"),
Id: ptrTo("1"),
Metadata: &ionos.KubernetesNodeMetadata{
State: ptr.To(K8sNodeStateProvisioning),
State: ptrTo(K8sNodeStateProvisioning),
},
Properties: &ionos.KubernetesNodeProperties{
Name: ptr.To("node1"),
Name: ptrTo("node1"),
},
},
{
Id: ptr.To("2"),
Id: ptrTo("2"),
Metadata: &ionos.KubernetesNodeMetadata{
State: ptr.To(K8sNodeStateProvisioned),
State: ptrTo(K8sNodeStateProvisioned),
},
Properties: &ionos.KubernetesNodeProperties{
Name: ptr.To("node2"),
Name: ptrTo("node2"),
},
},
{
Id: ptr.To("3"),
Id: ptrTo("3"),
Metadata: &ionos.KubernetesNodeMetadata{
State: ptr.To(K8sNodeStateRebuilding),
State: ptrTo(K8sNodeStateRebuilding),
},
Properties: &ionos.KubernetesNodeProperties{
Name: ptr.To("node3"),
Name: ptrTo("node3"),
},
},
{
Id: ptr.To("4"),
Id: ptrTo("4"),
Metadata: &ionos.KubernetesNodeMetadata{
State: ptr.To(K8sNodeStateTerminating),
State: ptrTo(K8sNodeStateTerminating),
},
Properties: &ionos.KubernetesNodeProperties{
Name: ptr.To("node4"),
Name: ptrTo("node4"),
},
},
{
Id: ptr.To("5"),
Id: ptrTo("5"),
Metadata: &ionos.KubernetesNodeMetadata{
State: ptr.To(K8sNodeStateReady),
State: ptrTo(K8sNodeStateReady),
},
Properties: &ionos.KubernetesNodeProperties{
Name: ptr.To("node5"),
Name: ptrTo("node5"),
},
},
}
Expand Down Expand Up @@ -138,9 +141,9 @@ func TestUtils_ConvertToInstances(t *testing.T) {
func TestUtils_ConvertToInstance(t *testing.T) {
t.Run("Success", func(t *testing.T) {
in := ionos.KubernetesNode{
Id: ptr.To("1"),
Id: ptrTo("1"),
Metadata: &ionos.KubernetesNodeMetadata{
State: ptr.To(K8sNodeStateReady),
State: ptrTo(K8sNodeStateReady),
},
}
want := cloudprovider.Instance{
Expand Down

0 comments on commit 34108be

Please sign in to comment.