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

Remove hardcoded types in favor of a supports feature check #20486

Merged
merged 1 commit into from
Aug 26, 2020

Conversation

@Fryguy Fryguy requested a review from agrare as a code owner August 26, 2020 16:06
@Fryguy
Copy link
Member Author

Fryguy commented Aug 26, 2020

[2] pry(main)> ManageIQ::Providers::CloudManager::Template.descendants.select(&:supports_provisioning?).map(&:name)
=> ["ManageIQ::Providers::Amazon::CloudManager::Template",
 "ManageIQ::Providers::Azure::CloudManager::Template",
 "ManageIQ::Providers::Google::CloudManager::Template",
 "ManageIQ::Providers::IbmCloud::PowerVirtualServers::CloudManager::Template",
 "ManageIQ::Providers::Openstack::CloudManager::BaseTemplate",
 "ManageIQ::Providers::Openstack::CloudManager::Template",
 "ManageIQ::Providers::Openstack::CloudManager::VolumeSnapshotTemplate",
 "ManageIQ::Providers::Openstack::CloudManager::VolumeTemplate"]

[3] pry(main)> ManageIQ::Providers::InfraManager::Template.descendants.select(&:supports_provisioning?).map(&:name)
=> ["ManageIQ::Providers::Kubevirt::InfraManager::Template",
 "ManageIQ::Providers::Redhat::InfraManager::Template",
 "ManageIQ::Providers::Microsoft::InfraManager::Template",
 "ManageIQ::Providers::Vmware::InfraManager::Template"]

Note that ManageIQ::Providers::Openstack::CloudManager::BaseTemplate is in the list, but it shouldn't affect the query. i can move it into the specific subclasses in the openstack plugin if that's preferable (see ManageIQ/manageiq-providers-openstack#628)

@Fryguy
Copy link
Member Author

Fryguy commented Aug 26, 2020

cc @jaywcarman

@miq-bot
Copy link
Member

miq-bot commented Aug 26, 2020

Checked commit Fryguy@9792d9e with ruby 2.6.3, rubocop 0.69.0, haml-lint 0.28.0, and yamllint
3 files checked, 0 offenses detected
Everything looks fine. ⭐

@Fryguy
Copy link
Member Author

Fryguy commented Aug 26, 2020

Not sure how I could add specs for this... I don't really like the current spec

it "#supports_provisioning?" do
template = FactoryBot.create(:template_openstack)
FactoryBot.create(:ems_openstack, :miq_templates => [template])
expect(template.supports_provisioning?).to be_truthy
template = FactoryBot.create(:template_openstack)
expect(template.supports_provisioning?).to be_falsey
template = FactoryBot.create(:template_microsoft)
expect(template.supports_provisioning?).to be_falsey
template = FactoryBot.create(:template_microsoft)
FactoryBot.create(:ems_openstack, :miq_templates => [template])
expect(template.supports_provisioning?).to be_truthy
end

because it's not very pluggable. Was thinking maybe each plugin should have their own method that checks that's it's in the eligible list? WDYT?

@agrare
Copy link
Member

agrare commented Aug 26, 2020

Yeah since we're getting rid of the list in core and moving to supports_feature in the plugins, makes sense the specs would move to the plugins also

@Fryguy
Copy link
Member Author

Fryguy commented Aug 26, 2020

Ok, maybe I should do that in a follow up PR, because that will entail a lot more moving parts.

@agrare agrare merged commit 8ec5c49 into ManageIQ:master Aug 26, 2020
@Fryguy Fryguy deleted the eligible_for_provisioning branch August 26, 2020 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants