Skip to content

Commit

Permalink
Merge pull request #7396 from killianmuldoon/update/deprecated-pointe…
Browse files Browse the repository at this point in the history
…r-methods

🌱 Replace deprecated functions from k8s.io/utils/pointer
  • Loading branch information
k8s-ci-robot authored Oct 12, 2022
2 parents 84b1728 + dba69ff commit bb6df67
Show file tree
Hide file tree
Showing 73 changed files with 368 additions and 371 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha3/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (in FailureDomains) FilterControlPlane() FailureDomains {
func (in FailureDomains) GetIDs() []*string {
ids := make([]*string, 0, len(in))
for id := range in {
ids = append(ids, pointer.StringPtr(id))
ids = append(ids, pointer.String(id))
}
return ids
}
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha3/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestMachineSetConversion(t *testing.T) {
ClusterName: clusterName,
Template: newFakeMachineTemplate(ns.Name, clusterName),
MinReadySeconds: 10,
Replicas: pointer.Int32Ptr(1),
Replicas: pointer.Int32(1),
DeletePolicy: "Random",
},
}
Expand All @@ -89,7 +89,7 @@ func TestMachineDeploymentConversion(t *testing.T) {
Spec: MachineDeploymentSpec{
ClusterName: clusterName,
Template: newFakeMachineTemplate(ns.Name, clusterName),
Replicas: pointer.Int32Ptr(0),
Replicas: pointer.Int32(0),
},
}

Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha4/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func (in FailureDomains) FilterControlPlane() FailureDomains {
func (in FailureDomains) GetIDs() []*string {
ids := make([]*string, 0, len(in))
for id := range in {
ids = append(ids, pointer.StringPtr(id))
ids = append(ids, pointer.String(id))
}
return ids
}
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ func (in FailureDomains) FilterControlPlane() FailureDomains {
func (in FailureDomains) GetIDs() []*string {
ids := make([]*string, 0, len(in))
for id := range in {
ids = append(ids, pointer.StringPtr(id))
ids = append(ids, pointer.String(id))
}
return ids
}
Expand Down
6 changes: 3 additions & 3 deletions api/v1beta1/machine_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestMachineDefault(t *testing.T) {
},
Spec: MachineSpec{
Bootstrap: Bootstrap{ConfigRef: &corev1.ObjectReference{}},
Version: pointer.StringPtr("1.17.5"),
Version: pointer.String("1.17.5"),
},
}
t.Run("for Machine", utildefaulting.DefaultValidateTest(m))
Expand All @@ -62,7 +62,7 @@ func TestMachineBootstrapValidation(t *testing.T) {
},
{
name: "should not return error if dataSecretName is set",
bootstrap: Bootstrap{ConfigRef: nil, DataSecretName: pointer.StringPtr("test")},
bootstrap: Bootstrap{ConfigRef: nil, DataSecretName: pointer.String("test")},
expectErr: false,
},
{
Expand Down Expand Up @@ -234,7 +234,7 @@ func TestMachineVersionValidation(t *testing.T) {
m := &Machine{
Spec: MachineSpec{
Version: &tt.version,
Bootstrap: Bootstrap{ConfigRef: nil, DataSecretName: pointer.StringPtr("test")},
Bootstrap: Bootstrap{ConfigRef: nil, DataSecretName: pointer.String("test")},
},
}

Expand Down
6 changes: 3 additions & 3 deletions api/v1beta1/machinedeployment_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ func PopulateDefaultsMachineDeployment(d *MachineDeployment) {
d.Labels[ClusterLabelName] = d.Spec.ClusterName

if d.Spec.MinReadySeconds == nil {
d.Spec.MinReadySeconds = pointer.Int32Ptr(0)
d.Spec.MinReadySeconds = pointer.Int32(0)
}

if d.Spec.RevisionHistoryLimit == nil {
d.Spec.RevisionHistoryLimit = pointer.Int32Ptr(1)
d.Spec.RevisionHistoryLimit = pointer.Int32(1)
}

if d.Spec.ProgressDeadlineSeconds == nil {
d.Spec.ProgressDeadlineSeconds = pointer.Int32Ptr(600)
d.Spec.ProgressDeadlineSeconds = pointer.Int32(600)
}

if d.Spec.Selector.MatchLabels == nil {
Expand Down
6 changes: 3 additions & 3 deletions api/v1beta1/machinedeployment_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ func TestMachineDeploymentDefault(t *testing.T) {
md.Default()

g.Expect(md.Labels[ClusterLabelName]).To(Equal(md.Spec.ClusterName))
g.Expect(md.Spec.MinReadySeconds).To(Equal(pointer.Int32Ptr(0)))
g.Expect(md.Spec.RevisionHistoryLimit).To(Equal(pointer.Int32Ptr(1)))
g.Expect(md.Spec.ProgressDeadlineSeconds).To(Equal(pointer.Int32Ptr(600)))
g.Expect(md.Spec.MinReadySeconds).To(Equal(pointer.Int32(0)))
g.Expect(md.Spec.RevisionHistoryLimit).To(Equal(pointer.Int32(1)))
g.Expect(md.Spec.ProgressDeadlineSeconds).To(Equal(pointer.Int32(600)))
g.Expect(md.Spec.Strategy).ToNot(BeNil())
g.Expect(md.Spec.Selector.MatchLabels).To(HaveKeyWithValue(MachineDeploymentLabelName, "test-md"))
g.Expect(md.Spec.Template.Labels).To(HaveKeyWithValue(MachineDeploymentLabelName, "test-md"))
Expand Down
18 changes: 9 additions & 9 deletions bootstrap/kubeadm/api/v1beta1/kubeadmconfig_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestKubeadmConfigDefault(t *testing.T) {
Spec: KubeadmConfigSpec{},
}
updateDefaultingKubeadmConfig := kubeadmConfig.DeepCopy()
updateDefaultingKubeadmConfig.Spec.Verbosity = pointer.Int32Ptr(4)
updateDefaultingKubeadmConfig.Spec.Verbosity = pointer.Int32(4)
t.Run("for KubeadmConfig", utildefaulting.DefaultValidateTest(updateDefaultingKubeadmConfig))

kubeadmConfig.Default()
Expand Down Expand Up @@ -187,7 +187,7 @@ func TestKubeadmConfigValidate(t *testing.T) {
Spec: KubeadmConfigSpec{
Users: []User{
{
Passwd: pointer.StringPtr("foo"),
Passwd: pointer.String("foo"),
},
},
},
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestKubeadmConfigValidate(t *testing.T) {
Users: []User{
{
PasswdFrom: &PasswdSource{},
Passwd: pointer.StringPtr("foo"),
Passwd: pointer.String("foo"),
},
},
},
Expand All @@ -244,7 +244,7 @@ func TestKubeadmConfigValidate(t *testing.T) {
Key: "bar",
},
},
Passwd: pointer.StringPtr("foo"),
Passwd: pointer.String("foo"),
},
},
},
Expand All @@ -265,7 +265,7 @@ func TestKubeadmConfigValidate(t *testing.T) {
Name: "foo",
},
},
Passwd: pointer.StringPtr("foo"),
Passwd: pointer.String("foo"),
},
},
},
Expand Down Expand Up @@ -308,7 +308,7 @@ func TestKubeadmConfigValidate(t *testing.T) {
Format: Ignition,
Users: []User{
{
Inactive: pointer.BoolPtr(true),
Inactive: pointer.Bool(true),
},
},
},
Expand All @@ -327,7 +327,7 @@ func TestKubeadmConfigValidate(t *testing.T) {
DiskSetup: &DiskSetup{
Partitions: []Partition{
{
TableType: pointer.StringPtr("MS-DOS"),
TableType: pointer.String("MS-DOS"),
},
},
},
Expand Down Expand Up @@ -388,7 +388,7 @@ func TestKubeadmConfigValidate(t *testing.T) {
DiskSetup: &DiskSetup{
Filesystems: []Filesystem{
{
ReplaceFS: pointer.StringPtr("ntfs"),
ReplaceFS: pointer.String("ntfs"),
},
},
},
Expand All @@ -408,7 +408,7 @@ func TestKubeadmConfigValidate(t *testing.T) {
DiskSetup: &DiskSetup{
Filesystems: []Filesystem{
{
Partition: pointer.StringPtr("1"),
Partition: pointer.String("1"),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestKubeadmConfigTemplateDefault(t *testing.T) {
},
}
updateDefaultingKubeadmConfigTemplate := kubeadmConfigTemplate.DeepCopy()
updateDefaultingKubeadmConfigTemplate.Spec.Template.Spec.Verbosity = pointer.Int32Ptr(4)
updateDefaultingKubeadmConfigTemplate.Spec.Template.Spec.Verbosity = pointer.Int32(4)
t.Run("for KubeadmConfigTemplate", utildefaulting.DefaultValidateTest(updateDefaultingKubeadmConfigTemplate))

kubeadmConfigTemplate.Default()
Expand Down
4 changes: 2 additions & 2 deletions bootstrap/kubeadm/internal/cloudinit/cloudinit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ func TestNewInitControlPlaneDiskMounts(t *testing.T) {
{
Device: "test-device",
Layout: true,
Overwrite: pointer.BoolPtr(false),
TableType: pointer.StringPtr("gpt"),
Overwrite: pointer.Bool(false),
TableType: pointer.String("gpt"),
},
},
Filesystems: []bootstrapv1.Filesystem{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ func (r *KubeadmConfigReconciler) storeBootstrapData(ctx context.Context, scope
Kind: "KubeadmConfig",
Name: scope.Config.Name,
UID: scope.Config.UID,
Controller: pointer.BoolPtr(true),
Controller: pointer.Bool(true),
},
},
},
Expand All @@ -1017,7 +1017,7 @@ func (r *KubeadmConfigReconciler) storeBootstrapData(ctx context.Context, scope
return errors.Wrapf(err, "failed to update bootstrap data secret for KubeadmConfig %s/%s", scope.Config.Namespace, scope.Config.Name)
}
}
scope.Config.Status.DataSecretName = pointer.StringPtr(secret.Name)
scope.Config.Status.DataSecretName = pointer.String(secret.Name)
scope.Config.Status.Ready = true
conditions.MarkTrue(scope.Config, bootstrapv1.DataSecretAvailableCondition)
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestKubeadmConfigReconciler_Reconcile_ReturnEarlyIfMachineHasDataSecretName
WithVersion("v1.19.1").
WithBootstrapTemplate(bootstrapbuilder.KubeadmConfig(metav1.NamespaceDefault, "cfg").Unstructured()).
Build()
machine.Spec.Bootstrap.DataSecretName = pointer.StringPtr("something")
machine.Spec.Bootstrap.DataSecretName = pointer.String("something")

config := newKubeadmConfig(metav1.NamespaceDefault, "cfg")
objects := []client.Object{
Expand Down Expand Up @@ -844,7 +844,7 @@ func TestKubeadmConfigSecretCreatedStatusNotPatched(t *testing.T) {
Kind: "KubeadmConfig",
Name: workerJoinConfig.Name,
UID: workerJoinConfig.UID,
Controller: pointer.BoolPtr(true),
Controller: pointer.Bool(true),
},
},
},
Expand Down Expand Up @@ -1482,7 +1482,7 @@ func TestKubeadmConfigReconciler_Reconcile_DynamicDefaultsForClusterConfiguratio
},
machine: &clusterv1.Machine{
Spec: clusterv1.MachineSpec{
Version: pointer.StringPtr("otherVersion"),
Version: pointer.String("otherVersion"),
},
},
},
Expand All @@ -1508,7 +1508,7 @@ func TestKubeadmConfigReconciler_Reconcile_DynamicDefaultsForClusterConfiguratio
},
machine: &clusterv1.Machine{
Spec: clusterv1.MachineSpec{
Version: pointer.StringPtr("myversion"),
Version: pointer.String("myversion"),
},
},
},
Expand Down
Loading

0 comments on commit bb6df67

Please sign in to comment.