Skip to content

Commit e5bddcc

Browse files
committed
Convert machineSpec.Versions to a pointer
1 parent 750b022 commit e5bddcc

File tree

7 files changed

+15
-8
lines changed

7 files changed

+15
-8
lines changed

cmd/clusterctl/clusterdeployer/clusterdeployer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ func generateTestMasterMachine(name string) *clusterv1.Machine {
11931193
Name: name,
11941194
},
11951195
Spec: clusterv1.MachineSpec{
1196-
Versions: clusterv1.MachineVersionInfo{
1196+
Versions: &clusterv1.MachineVersionInfo{
11971197
ControlPlane: "1.10.1",
11981198
},
11991199
},

pkg/apis/cluster/v1alpha1/machine_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type MachineSpec struct {
7070
// should populate the values it uses when persisting Machine objects.
7171
// A Machine spec missing this field at runtime is invalid.
7272
// +optional
73-
Versions MachineVersionInfo `json:"versions,omitempty"`
73+
Versions *MachineVersionInfo `json:"versions,omitempty"`
7474

7575
// To populate in the associated Node for dynamic kubelet config. This
7676
// field already exists in Node, so any updates to it in the Machine

pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/controller/machine/machine_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestReconcile(t *testing.T) {
3939
instance := &clusterv1alpha1.Machine{
4040
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "default"},
4141
Spec: clusterv1alpha1.MachineSpec{
42-
Versions: clusterv1alpha1.MachineVersionInfo{Kubelet: "1.10.3"},
42+
Versions: &clusterv1alpha1.MachineVersionInfo{Kubelet: "1.10.3"},
4343
},
4444
}
4545

pkg/controller/machinedeployment/machinedeployment_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestReconcile(t *testing.T) {
5959
Labels: labels,
6060
},
6161
Spec: clusterv1alpha1.MachineSpec{
62-
Versions: clusterv1alpha1.MachineVersionInfo{Kubelet: "1.10.3"},
62+
Versions: &clusterv1alpha1.MachineVersionInfo{Kubelet: "1.10.3"},
6363
},
6464
},
6565
},

pkg/controller/machineset/machineset_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestReconcile(t *testing.T) {
4343
Replicas: &replicas,
4444
Template: clusterv1alpha1.MachineTemplateSpec{
4545
Spec: clusterv1alpha1.MachineSpec{
46-
Versions: clusterv1alpha1.MachineVersionInfo{Kubelet: "1.10.3"},
46+
Versions: &clusterv1alpha1.MachineVersionInfo{Kubelet: "1.10.3"},
4747
},
4848
},
4949
},

pkg/util/util.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"strings"
2828
"time"
2929

30-
"k8s.io/api/core/v1"
30+
v1 "k8s.io/api/core/v1"
3131
"k8s.io/apimachinery/pkg/api/errors"
3232
"k8s.io/klog"
3333
clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
@@ -118,7 +118,10 @@ func GetMachineIfExists(c client.Client, namespace, name string) (*clusterv1.Mac
118118

119119
// TODO(robertbailey): Remove this function
120120
func IsMaster(machine *clusterv1.Machine) bool {
121-
return machine.Spec.Versions.ControlPlane != ""
121+
if machine.Spec.Versions != nil {
122+
return machine.Spec.Versions.ControlPlane != ""
123+
}
124+
return false
122125
}
123126

124127
func IsNodeReady(node *v1.Node) bool {

0 commit comments

Comments
 (0)