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
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ func (v VSphereProviderConfig) InjectFailureDomain(fd machinev1.VSphereFailureDo
func (v VSphereProviderConfig) ExtractFailureDomain() machinev1.VSphereFailureDomain { //nolint:cyclop
workspace := v.providerConfig.Workspace

// If workspace is not set on the CPMS's config, the Machines will have one injected from the Infra object.
if workspace == nil {
return machinev1.VSphereFailureDomain{}
}

if v.infrastructure.Spec.PlatformSpec.Type != configv1.VSpherePlatformType {
return machinev1.VSphereFailureDomain{}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,15 @@ var _ = Describe("VSphere Provider Config", Label("vSphereProviderConfig"), func
Expect(expected).To(Equal(v1.VSphereFailureDomain{}))
})
})

Context("no workspace configured in provider spec", func() {
BeforeEach(func() {
providerConfig.providerConfig.Workspace = nil
})

It("should return empty failure domain without panicking", func() {
Expect(providerConfig.ExtractFailureDomain()).To(Equal(v1.VSphereFailureDomain{}),
"expected empty failure domain when workspace is nil, but ExtractFailureDomain panicked")
})
})
})