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

Allow plugins to bring their own miq_reports #19391

Merged
merged 1 commit into from
Oct 22, 2019

Conversation

agrare
Copy link
Member

@agrare agrare commented Oct 11, 2019

Check vmdb::plugins for product/reports and product/compare when seeding
MiqReports

#14840

@agrare agrare force-pushed the pluggable_miq_reports branch 2 times, most recently from 5b550a3 to 54b4c44 Compare October 11, 2019 18:53
@durandom durandom mentioned this pull request Oct 11, 2019
38 tasks
@agrare agrare force-pushed the pluggable_miq_reports branch 3 times, most recently from 0b23020 to ac0d3f0 Compare October 11, 2019 19:26
Copy link
Member

@NickLaMuro NickLaMuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, this is just nitpicking, but figured I would throw out the suggestion anyway.

Dir.glob(REPORT_DIR.join("**/*.yaml")).sort + Dir.glob(COMPARE_DIR.join("**/*.yaml")).sort
end

def seed_plugin_files
Vmdb::Plugins.flat_map do |plugin|
Dir.glob(plugin.root.join("#{RELATIVE_REPORT_DIR}/**/*.yaml")).sort + Dir.glob(plugin.root.join("#{RELATIVE_COMPARE_DIR}/**/*.yaml")).sort
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seed_core_files and seed_plugin_files seem pretty similar. Wonder if you could do something like this instead:

def seed_files
  Vmdb::Plugins.flat_map.unshift(Rails) do |plugin|
    seed_files_for plugin.root
  end
end

def seed_files_for pathname
  Dir.glob(dir.join("product", "{report|compare}", "**", "*.yaml")).sort
end

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only weird part might be the sorting, but I'm not sure that's important with respect to reports coming before compare or not.

Dir.glob(REPORT_DIR.join("**/*.yaml")).sort + Dir.glob(COMPARE_DIR.join("**/*.yaml")).sort
end

def seed_plugin_files
Vmdb::Plugins.flat_map do |plugin|
Dir.glob(plugin.root.join("#{RELATIVE_REPORT_DIR}/**/*.yaml")).sort + Dir.glob(plugin.root.join("#{RELATIVE_COMPARE_DIR}/**/*.yaml")).sort
Copy link
Member

@Fryguy Fryguy Oct 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to avoid the "product" part in the plugin path...I've been trying to standardize on /content/thing, so in this case I'd expect for plugins /content/reports and content/compare.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm okay, I assume we'd want to keep the current reports in product/ and only the plugin reports would be in content/?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah for now they will stay in product in core. Over time I'd like to move them to either a content directory in core, or a content directory in manageiq-content.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm okay, I assume we'd want to keep the current reports in product/ and only the plugin reports would be in content/?

@agrare My 2cents would be to move them in both. Makes the code here easier to read, and just keeps things consistent between plugin and core.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@Fryguy Fryguy Oct 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not move the reports from core right now, particularly because reports are central to how the UI works and that's where they know them to exist.

elsif File.dirname(path).include?("compare")
path.split("compare/").last
else
path
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that seed_filename is sometimes passed not the full path but just the filename from the db record here and here, so it is possible to not have either "reports" or "compare" in the path.

Since those records have the filename set by seed_filename(path) I don't think we could index_by(&:filename) which simplifies this method but want to check to see if I'm missing something.

Check vmdb::plugins for product/reports and product/compare when seeding
MiqReports
@miq-bot
Copy link
Member

miq-bot commented Oct 12, 2019

Checked commit agrare@4b8fd72 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. 🏆

@Fryguy
Copy link
Member

Fryguy commented Oct 22, 2019

@agrare Can you run the UI specs as well since they have a special reports spec there?

@agrare
Copy link
Member Author

agrare commented Oct 22, 2019

@Fryguy Fryguy merged commit 97b94da into ManageIQ:master Oct 22, 2019
@Fryguy Fryguy added this to the Sprint 123 Ending Oct 28, 2019 milestone Oct 22, 2019
@agrare agrare deleted the pluggable_miq_reports branch October 22, 2019 16:36
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.

4 participants