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

Convert machineSpec.Versions to a pointer #683

Closed
wants to merge 1 commit 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
2 changes: 1 addition & 1 deletion cmd/clusterctl/clusterdeployer/clusterdeployer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ func generateTestControlPlaneMachine(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"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All consumers of the field will be required to change the field access logic. Their code will start to panic in cases where the Versions field is nil.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

such changes are usually more suited in v1alphaX increments.


// ConfigSource is used 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 @@ -60,7 +60,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
5 changes: 4 additions & 1 deletion pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ func GetMachineIfExists(c client.Client, namespace, name string) (*clusterv1.Mac

// TODO(robertbailey): Remove this function
func IsControlPlaneMachine(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