Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump k8s & cluster api dependency #4569

Closed
wants to merge 3 commits into from
Closed
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
10 changes: 5 additions & 5 deletions api/v1beta2/awsmachine_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

utildefaulting "sigs.k8s.io/cluster-api/util/defaulting"
)
Expand Down Expand Up @@ -284,14 +284,14 @@ func TestAWSMachineUpdate(t *testing.T) {
},
newMachine: &AWSMachine{
Spec: AWSMachineSpec{
ProviderID: pointer.String("ID"),
ProviderID: ptr.To[string]("ID"),
InstanceType: "test",
AdditionalTags: Tags{
"key-1": "value-1",
},
AdditionalSecurityGroups: []AWSResourceReference{
{
ID: pointer.String("ID"),
ID: ptr.To[string]("ID"),
},
},
CloudInit: CloudInit{
Expand All @@ -316,13 +316,13 @@ func TestAWSMachineUpdate(t *testing.T) {
Spec: AWSMachineSpec{
ImageLookupOrg: "test",
InstanceType: "test",
ProviderID: pointer.String("ID"),
ProviderID: ptr.To[string]("ID"),
AdditionalTags: Tags{
"key-1": "value-1",
},
AdditionalSecurityGroups: []AWSResourceReference{
{
ID: pointer.String("ID"),
ID: ptr.To[string]("ID"),
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta2/awsmachinetemplate_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/aws/aws-sdk-go/aws"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

func TestAWSMachineTemplateValidateCreate(t *testing.T) {
Expand All @@ -38,7 +38,7 @@ func TestAWSMachineTemplateValidateCreate(t *testing.T) {
Spec: AWSMachineTemplateSpec{
Template: AWSMachineTemplateResource{
Spec: AWSMachineSpec{
ProviderID: pointer.String("something"),
ProviderID: ptr.To[string]("something"),
},
},
},
Expand Down
12 changes: 6 additions & 6 deletions bootstrap/eks/controllers/eksconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
Expand Down Expand Up @@ -261,14 +261,14 @@ func (r *EKSConfigReconciler) joinWorker(ctx context.Context, cluster *clusterv1
// If not, we also check if the cluster is ipv6 based.
if config.Spec.ServiceIPV6Cidr != nil && *config.Spec.ServiceIPV6Cidr != "" {
nodeInput.ServiceIPV6Cidr = config.Spec.ServiceIPV6Cidr
nodeInput.IPFamily = pointer.String("ipv6")
nodeInput.IPFamily = ptr.To[string]("ipv6")
}

// we don't want to override any manually set configuration options.
if config.Spec.ServiceIPV6Cidr == nil && controlPlane.Spec.NetworkSpec.VPC.IsIPv6Enabled() {
log.Info("Adding ipv6 data to userdata....")
nodeInput.ServiceIPV6Cidr = pointer.String(controlPlane.Spec.NetworkSpec.VPC.IPv6.CidrBlock)
nodeInput.IPFamily = pointer.String("ipv6")
nodeInput.ServiceIPV6Cidr = ptr.To[string](controlPlane.Spec.NetworkSpec.VPC.IPv6.CidrBlock)
nodeInput.IPFamily = ptr.To[string]("ipv6")
}

// generate userdata
Expand Down Expand Up @@ -355,7 +355,7 @@ func (r *EKSConfigReconciler) storeBootstrapData(ctx context.Context, cluster *c
}
}

config.Status.DataSecretName = pointer.String(secret.Name)
config.Status.DataSecretName = ptr.To[string](secret.Name)
config.Status.Ready = true
conditions.MarkTrue(config, eksbootstrapv1.DataSecretAvailableCondition)
return nil
Expand Down Expand Up @@ -443,7 +443,7 @@ func (r *EKSConfigReconciler) createBootstrapSecret(ctx context.Context, cluster
Kind: "EKSConfig",
Name: config.Name,
UID: config.UID,
Controller: pointer.Bool(true),
Controller: ptr.To[bool](true),
},
},
},
Expand Down
24 changes: 12 additions & 12 deletions bootstrap/eks/internal/userdata/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/format"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

eksbootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/v2/bootstrap/eks/api/v1beta2"
)
Expand Down Expand Up @@ -77,7 +77,7 @@ runcmd:
args: args{
input: &NodeInput{
ClusterName: "test-cluster",
ContainerRuntime: pointer.String("containerd"),
ContainerRuntime: ptr.To[string]("containerd"),
},
},
expectedBytes: []byte(`#cloud-config
Expand All @@ -95,7 +95,7 @@ runcmd:
"node-labels": "node-role.undistro.io/infra=true",
"register-with-taints": "dedicated=infra:NoSchedule",
},
ContainerRuntime: pointer.String("containerd"),
ContainerRuntime: ptr.To[string]("containerd"),
},
},
expectedBytes: []byte(`#cloud-config
Expand All @@ -109,8 +109,8 @@ runcmd:
args: args{
input: &NodeInput{
ClusterName: "test-cluster",
ServiceIPV6Cidr: pointer.String("fe80:0000:0000:0000:0204:61ff:fe9d:f156/24"),
IPFamily: pointer.String("ipv6"),
ServiceIPV6Cidr: ptr.To[string]("fe80:0000:0000:0000:0204:61ff:fe9d:f156/24"),
IPFamily: ptr.To[string]("ipv6"),
},
},
expectedBytes: []byte(`#cloud-config
Expand All @@ -124,7 +124,7 @@ runcmd:
args: args{
input: &NodeInput{
ClusterName: "test-cluster",
UseMaxPods: pointer.Bool(false),
UseMaxPods: ptr.To[bool](false),
},
},
expectedBytes: []byte(`#cloud-config
Expand All @@ -138,7 +138,7 @@ runcmd:
args: args{
input: &NodeInput{
ClusterName: "test-cluster",
APIRetryAttempts: pointer.Int(5),
APIRetryAttempts: ptr.To[int](5),
},
},
expectedBytes: []byte(`#cloud-config
Expand All @@ -152,8 +152,8 @@ runcmd:
args: args{
input: &NodeInput{
ClusterName: "test-cluster",
PauseContainerAccount: pointer.String("12345678"),
PauseContainerVersion: pointer.String("v1"),
PauseContainerAccount: ptr.To[string]("12345678"),
PauseContainerVersion: ptr.To[string]("v1"),
},
},
expectedBytes: []byte(`#cloud-config
Expand All @@ -167,7 +167,7 @@ runcmd:
args: args{
input: &NodeInput{
ClusterName: "test-cluster",
DNSClusterIP: pointer.String("192.168.0.1"),
DNSClusterIP: ptr.To[string]("192.168.0.1"),
},
},
expectedBytes: []byte(`#cloud-config
Expand All @@ -181,7 +181,7 @@ runcmd:
args: args{
input: &NodeInput{
ClusterName: "test-cluster",
DockerConfigJSON: pointer.String("{\"debug\":true}"),
DockerConfigJSON: ptr.To[string]("{\"debug\":true}"),
},
},
expectedBytes: []byte(`#cloud-config
Expand Down Expand Up @@ -244,7 +244,7 @@ runcmd:
args: args{
input: &NodeInput{
ClusterName: "test-cluster",
BootstrapCommandOverride: pointer.String("/custom/mybootstrap.sh"),
BootstrapCommandOverride: ptr.To[string]("/custom/mybootstrap.sh"),
},
},
expectedBytes: []byte(`#cloud-config
Expand Down
6 changes: 3 additions & 3 deletions cmd/clusterawsadm/api/bootstrap/v1alpha1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package v1alpha1

import (
runtime "k8s.io/apimachinery/pkg/runtime"
utilpointer "k8s.io/utils/pointer"
"k8s.io/utils/ptr"

infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
iamv1 "sigs.k8s.io/cluster-api-provider-aws/v2/iam/api/v1beta1"
Expand Down Expand Up @@ -49,7 +49,7 @@ func SetDefaults_BootstrapUser(obj *BootstrapUser) { //nolint:golint,stylecheck
// SetDefaults_AWSIAMConfigurationSpec is used by defaulter-gen.
func SetDefaults_AWSIAMConfigurationSpec(obj *AWSIAMConfigurationSpec) { //nolint:golint,stylecheck
if obj.NameSuffix == nil {
obj.NameSuffix = utilpointer.String(iamv1.DefaultNameSuffix)
obj.NameSuffix = ptr.To[string](iamv1.DefaultNameSuffix)
}
if obj.Partition == "" {
obj.Partition = DefaultPartitionName
Expand Down Expand Up @@ -98,7 +98,7 @@ func SetDefaults_AWSIAMConfiguration(obj *AWSIAMConfiguration) { //nolint:golint
obj.APIVersion = SchemeGroupVersion.String()
obj.Kind = "AWSIAMConfiguration"
if obj.Spec.NameSuffix == nil {
obj.Spec.NameSuffix = utilpointer.String(iamv1.DefaultNameSuffix)
obj.Spec.NameSuffix = ptr.To[string](iamv1.DefaultNameSuffix)
}
if obj.Spec.StackName == "" {
obj.Spec.StackName = DefaultStackName
Expand Down
6 changes: 3 additions & 3 deletions cmd/clusterawsadm/api/bootstrap/v1beta1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package v1beta1

import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
iamv1 "sigs.k8s.io/cluster-api-provider-aws/v2/iam/api/v1beta1"
Expand Down Expand Up @@ -60,7 +60,7 @@ func SetDefaults_BootstrapUser(obj *BootstrapUser) { //nolint:golint,stylecheck
// SetDefaults_AWSIAMConfigurationSpec is used by defaulter-gen.
func SetDefaults_AWSIAMConfigurationSpec(obj *AWSIAMConfigurationSpec) { //nolint:golint,stylecheck
if obj.NameSuffix == nil {
obj.NameSuffix = pointer.String(iamv1.DefaultNameSuffix)
obj.NameSuffix = ptr.To[string](iamv1.DefaultNameSuffix)
}
if obj.Partition == "" {
obj.Partition = DefaultPartitionName
Expand Down Expand Up @@ -113,7 +113,7 @@ func SetDefaults_AWSIAMConfiguration(obj *AWSIAMConfiguration) { //nolint:golint
obj.APIVersion = SchemeGroupVersion.String()
obj.Kind = "AWSIAMConfiguration"
if obj.Spec.NameSuffix == nil {
obj.Spec.NameSuffix = pointer.String(iamv1.DefaultNameSuffix)
obj.Spec.NameSuffix = ptr.To[string](iamv1.DefaultNameSuffix)
}
if obj.Spec.StackName == "" {
obj.Spec.StackName = DefaultStackName
Expand Down
4 changes: 2 additions & 2 deletions cmd/clusterawsadm/cloudformation/bootstrap/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/awslabs/goformation/v4/cloudformation"
"github.com/sergi/go-diff/diffmatchpatch"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/yaml"

infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
Expand Down Expand Up @@ -73,7 +73,7 @@ func TestRenderCloudformation(t *testing.T) {
fixture: "customsuffix",
template: func() Template {
t := NewTemplate()
t.Spec.NameSuffix = pointer.String(".custom-suffix.com")
t.Spec.NameSuffix = ptr.To[string](".custom-suffix.com")
return t
},
},
Expand Down
6 changes: 3 additions & 3 deletions cmd/clusterawsadm/cloudformation/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
go_cfn "github.com/awslabs/goformation/v4/cloudformation"
"github.com/pkg/errors"
"k8s.io/klog/v2"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/awserrors"
)
Expand Down Expand Up @@ -59,8 +59,8 @@ func (s *Service) ReconcileBootstrapStack(stackName string, t go_cfn.Template, t
stackTags := []*cfn.Tag{}
for k, v := range tags {
stackTags = append(stackTags, &cfn.Tag{
Key: pointer.String(k),
Value: pointer.String(v),
Key: ptr.To[string](k),
Value: ptr.To[string](v),
})
}
//nolint:nestif
Expand Down
14 changes: 6 additions & 8 deletions controllers/awsmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/tools/record"
"k8s.io/klog/v2"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
Expand All @@ -59,7 +59,6 @@ import (
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/userdata"
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/controllers/noderefutil"
capierrors "sigs.k8s.io/cluster-api/errors"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/annotations"
Expand Down Expand Up @@ -418,30 +417,29 @@ func (r *AWSMachineReconciler) reconcileDelete(machineScope *scope.MachineScope,
// findInstance queries the EC2 apis and retrieves the instance if it exists.
// If providerID is empty, finds instance by tags and if it cannot be found, returns empty instance with nil error.
// If providerID is set, either finds the instance by ID or returns error.
func (r *AWSMachineReconciler) findInstance(scope *scope.MachineScope, ec2svc services.EC2Interface) (*infrav1.Instance, error) {
func (r *AWSMachineReconciler) findInstance(machineScope *scope.MachineScope, ec2svc services.EC2Interface) (*infrav1.Instance, error) {
var instance *infrav1.Instance

// Parse the ProviderID.
//nolint:staticcheck
// Usage of noderefutil pkg would be removed in a future release.
pid, err := noderefutil.NewProviderID(scope.GetProviderID())
pid, err := scope.NewProviderID(machineScope.GetProviderID())
if err != nil {
//nolint:staticcheck
// Usage of noderefutil pkg would be removed in a future release.
if !errors.Is(err, noderefutil.ErrEmptyProviderID) {
if !errors.Is(err, scope.ErrEmptyProviderID) {
richardcase marked this conversation as resolved.
Show resolved Hide resolved
return nil, errors.Wrapf(err, "failed to parse Spec.ProviderID")
}
// If the ProviderID is empty, try to query the instance using tags.
// If an instance cannot be found, GetRunningInstanceByTags returns empty instance with nil error.
instance, err = ec2svc.GetRunningInstanceByTags(scope)
instance, err = ec2svc.GetRunningInstanceByTags(machineScope)
if err != nil {
return nil, errors.Wrapf(err, "failed to query AWSMachine instance by tags")
}
} else {
// If the ProviderID is populated, describe the instance using the ID.
// InstanceIfExists() returns error (ErrInstanceNotFoundByID or ErrDescribeInstance) if the instance could not be found.
//nolint:staticcheck
instance, err = ec2svc.InstanceIfExists(pointer.String(pid.ID()))
instance, err = ec2svc.InstanceIfExists(ptr.To[string](pid.ID()))
if err != nil {
return nil, err
}
Expand Down
Loading