-
Notifications
You must be signed in to change notification settings - Fork 897
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
Add support for exporting and importing generic object definitions #18688
Conversation
@miq-bot add_label enhancement tools |
@romanblanco Cannot apply the following label because they are not recognized: enhancement tools |
--- | ||
- GenericObjectDefinition: | ||
name: Apep | ||
description: Ancient Egyptian deity who embodied chaos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOOOL. I love this.
@@ -21,6 +23,7 @@ class GenericObjectDefinition < ApplicationRecord | |||
REG_ATTRIBUTE_NAME = /\A[a-z][a-zA-Z_0-9]*\z/ | |||
REG_METHOD_NAME = /\A[a-z][a-zA-Z_0-9]*[!?]?\z/ | |||
ALLOWED_ASSOCIATION_TYPES = (MiqReport.reportable_models + %w(GenericObject)).freeze | |||
IMPORT_CLASS_NAMES = %w(GenericObjectDefinition).freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fryguy yes, to validate the imported data
@gtanzillo Please review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eclarizio can you help review this one?
@@ -18,7 +18,7 @@ | |||
before do | |||
@user_admin = FactoryBot.create(:user_admin) | |||
report_string = MiqReport.export_to_yaml([@old_report.id], MiqReport) | |||
@new_report = YAML.load(report_string).first | |||
@new_report = YAML.load(report_string).first["MiqReport"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These report changes should be moved to a separate PR to keep this GenericObject focused.
end | ||
end | ||
|
||
describe "when the source file modifies an existing report" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several references to report
here which seem like remnants from copy/paste.
fe74675
to
0278221
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code seems fine, but you could probably separate the new methods in GenericObjectDefinition
into a mixin since that seems to be the pattern we have for MiqWidget
, MiqReport
, and MiqPolicy
. They all just have an ImportExport
module with at least the import_from_hash
and export_to_array
methods in them, and then the object in question just does include_concern 'ImportExport'
.
Checked commits romanblanco/manageiq@fc78b82~...77e1879 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Just fyi the description of the commands looks copypasted with an error: (you should probably take the slash off the import command line in the description) |
These rake scripts and classes provide functionality for exporting/importing of the Generic Object Definitions.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1595259
Assuming the generic object definitions are all created by user, and therefore there are no default / custom generic object definitions.
For that reason, we don't work with
--all
argument as can be seen in other ManageIQ exportable objects.While importing, the
overwrite
switch defaults totrue
. To disable overwriting of imported objects use--no-overwrite
switch.Links
Steps for Testing/QA
Exporting
Create a directory for the exports
Export user defined
Importing