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

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

16 changes: 6 additions & 10 deletions pkg/webhooks/openstackmachine_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,13 @@ func (*openStackMachineWebhook) ValidateUpdate(_ context.Context, oldObjRaw, new
newOpenStackMachineSpec := newOpenStackMachine["spec"].(map[string]interface{})
oldOpenStackMachineSpec := oldOpenStackMachine["spec"].(map[string]interface{})

// allow changes to providerID once
if oldOpenStackMachineSpec["providerID"] == nil {
delete(oldOpenStackMachineSpec, "providerID")
delete(newOpenStackMachineSpec, "providerID")
}
// allow changes to providerID (matches AWS, GCP, VSphere providers)
delete(oldOpenStackMachineSpec, "providerID")
delete(newOpenStackMachineSpec, "providerID")

// allow changes to instanceID once
if oldOpenStackMachineSpec["instanceID"] == nil {
delete(oldOpenStackMachineSpec, "instanceID")
delete(newOpenStackMachineSpec, "instanceID")
}
// allow changes to instanceID (matches AWS, GCP, VSphere providers)
delete(oldOpenStackMachineSpec, "instanceID")
delete(newOpenStackMachineSpec, "instanceID")

// allow changes to identifyRef
delete(oldOpenStackMachineSpec, "identityRef")
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/suites/apivalidations/openstackmachine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var _ = Describe("OpenStackMachine API validations", func() {
Expect(k8sClient.Create(ctx, machine)).To(Succeed(), "OpenStackMachine creation with spec.identityRef should succeed")
})

It("should only allow the providerID to be set once", func() {
It("should allow the providerID to be updated", func() {
machine := defaultMachine()

By("Creating a bare machine")
Expand All @@ -72,7 +72,7 @@ var _ = Describe("OpenStackMachine API validations", func() {

By("Modifying the providerID")
machine.Spec.ProviderID = ptr.To("bar")
Expect(k8sClient.Update(ctx, machine)).NotTo(Succeed(), "Updating providerID should fail")
Expect(k8sClient.Update(ctx, machine)).To(Succeed(), "Updating providerID should succeed")
})

It("should allow the identityRef to be set several times", func() {
Expand Down