Skip to content
Open
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
1 change: 0 additions & 1 deletion api/v1alpha2/linodemachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ type LinodeMachineSpec struct {

// image is the Linode image to use for the instance.
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
Image string `json:"image,omitempty"`

// interfaces is a list of legacy network interfaces to use for the instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,6 @@ spec:
image:
description: image is the Linode image to use for the instance.
type: string
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
instanceID:
description: instanceID is the Linode instance ID for this machine.
type: integer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,6 @@ spec:
image:
description: image is the Linode image to use for the instance.
type: string
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
instanceID:
description: instanceID is the Linode instance ID for this
machine.
Expand Down
14 changes: 14 additions & 0 deletions internal/webhook/v1alpha2/linodemachine_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ func (r *linodeMachineValidator) ValidateUpdate(ctx context.Context, oldObj, new
}
linodemachinelog.Info("validate update", "name", old.Name)

newMachine, ok := newObj.(*infrav1alpha2.LinodeMachine)
if !ok {
return nil, apierrors.NewBadRequest("expected a LinodeMachine Resource")
}

// ensure that spec.Image is immutable
if old.Spec.Image != newMachine.Spec.Image {
return nil, &field.Error{
Field: "spec.image",
Type: field.ErrorTypeInvalid,
Detail: "Field is immutable",
}
}

// TODO(user): fill in your validation logic upon object update.
return nil, nil
}
Expand Down
Loading