Skip to content

Commit

Permalink
MGMT-15015 Provider IsHostSupported panic if platform is not found (#…
Browse files Browse the repository at this point in the history
…5306)

Print the platform from the arguments and not the reply from the get function to avoid using nil reply
  • Loading branch information
filanov committed Jun 21, 2023
1 parent cab4a19 commit 052e7fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/provider/registry/registry.go
Expand Up @@ -103,7 +103,7 @@ func (r *registry) IsHostSupported(p models.PlatformType, host *models.Host) (bo
currentProvider, err := r.Get(string(p))
if err != nil {
return false, fmt.Errorf("error while checking if hosts are supported by platform %s, error %w",
currentProvider.Name(), err)
string(p), err)
}
return currentProvider.IsHostSupported(host)
}
Expand Down
9 changes: 9 additions & 0 deletions internal/provider/registry/registry_test.go
Expand Up @@ -142,6 +142,15 @@ var _ = Describe("Test GetSupportedProvidersByHosts", func() {
})
})

var _ = Describe("IsHostSupported", func() {
It("platform not found", func() {
providerRegistry = InitProviderRegistry(common.GetTestLog())
found, err := providerRegistry.IsHostSupported("none-existing-platform-type", &models.Host{})
Expect(err).NotTo(Succeed())
Expect(found).To(BeFalse())
})
})

var _ = Describe("Test AddPlatformToInstallConfig", func() {
BeforeEach(func() {
providerRegistry = InitProviderRegistry(common.GetTestLog())
Expand Down

0 comments on commit 052e7fa

Please sign in to comment.