Skip to content

Commit

Permalink
Convert machineSpec.Versions to a pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
enxebre committed Jan 16, 2019
1 parent 750b022 commit e5bddcc
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/clusterctl/clusterdeployer/clusterdeployer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ func generateTestMasterMachine(name string) *clusterv1.Machine {
Name: name,
},
Spec: clusterv1.MachineSpec{
Versions: clusterv1.MachineVersionInfo{
Versions: &clusterv1.MachineVersionInfo{
ControlPlane: "1.10.1",
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/cluster/v1alpha1/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type MachineSpec struct {
// should populate the values it uses when persisting Machine objects.
// A Machine spec missing this field at runtime is invalid.
// +optional
Versions MachineVersionInfo `json:"versions,omitempty"`
Versions *MachineVersionInfo `json:"versions,omitempty"`

// To populate in the associated Node for dynamic kubelet config. This
// field already exists in Node, so any updates to it in the Machine
Expand Down
6 changes: 5 additions & 1 deletion pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/controller/machine/machine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestReconcile(t *testing.T) {
instance := &clusterv1alpha1.Machine{
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "default"},
Spec: clusterv1alpha1.MachineSpec{
Versions: clusterv1alpha1.MachineVersionInfo{Kubelet: "1.10.3"},
Versions: &clusterv1alpha1.MachineVersionInfo{Kubelet: "1.10.3"},
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestReconcile(t *testing.T) {
Labels: labels,
},
Spec: clusterv1alpha1.MachineSpec{
Versions: clusterv1alpha1.MachineVersionInfo{Kubelet: "1.10.3"},
Versions: &clusterv1alpha1.MachineVersionInfo{Kubelet: "1.10.3"},
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/machineset/machineset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestReconcile(t *testing.T) {
Replicas: &replicas,
Template: clusterv1alpha1.MachineTemplateSpec{
Spec: clusterv1alpha1.MachineSpec{
Versions: clusterv1alpha1.MachineVersionInfo{Kubelet: "1.10.3"},
Versions: &clusterv1alpha1.MachineVersionInfo{Kubelet: "1.10.3"},
},
},
},
Expand Down
7 changes: 5 additions & 2 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"strings"
"time"

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

// TODO(robertbailey): Remove this function
func IsMaster(machine *clusterv1.Machine) bool {
return machine.Spec.Versions.ControlPlane != ""
if machine.Spec.Versions != nil {
return machine.Spec.Versions.ControlPlane != ""
}
return false
}

func IsNodeReady(node *v1.Node) bool {
Expand Down

0 comments on commit e5bddcc

Please sign in to comment.