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

[WIP] Remove to_xml #430

Closed
wants to merge 1 commit into from
Closed

Conversation

d-m-u
Copy link
Contributor

@d-m-u d-m-u commented Mar 5, 2020

This is follow-up to #429.

This was what I could remove without specs failing, and it's kinda late, so I'll get back to it tomorrow.

there are a few more:

lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:193:    def attribute_value_to_xml(value, xml)
lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:204:            xml.Element(:index => i + 1) { attribute_value_to_xml(value[i], xml) }
lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:210:            xml.Key(:name => k.to_s) { attribute_value_to_xml(v, xml) }
lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:221:    def to_xml(options = {})
lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:227:          xml.MiqAeAttribute(:name => k) { attribute_value_to_xml(@attributes[k], xml) }
lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:230:        children.each { |c| c.to_xml(:builder => xml) }
lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb:201:        objs.each { |obj| obj.to_xml(:builder => xml) }
lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb:205:    def to_xml(path = nil)
lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb:209:      XmlHash.from_hash({"MiqAeObject" => result}, {:rootname => "MiqAeWorkspace"}).to_xml.write(s, 2)

but with those removed as well,

expect(ws.root['ae_result']).to eq('ok')
fails with ae_result of error rather than ok.

Maybe also app/models/miq_ae_datastore/xml_import.rb can go, but I have to look closer at it tomorrow cause it causes uninitialized constant constant problems

@d-m-u
Copy link
Contributor Author

d-m-u commented Mar 5, 2020

@miq-bot add_label technical debt

@coveralls
Copy link

coveralls commented Mar 5, 2020

Pull Request Test Coverage Report for Build 4367

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.5%) to 86.232%

Files with Coverage Reduction New Missed Lines %
lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_builtin_method.rb 1 52.6%
lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb 1 86.4%
Totals Coverage Status
Change from base Build 4366: 0.5%
Covered Lines: 4973
Relevant Lines: 5767

💛 - Coveralls

@gmcculloug gmcculloug self-assigned this Mar 9, 2020
@gmcculloug
Copy link
Member

@mkanoor Any concern with trying to get rid of all the XML stuff on master? It likely needs to happen over the course of a few PRs, but feels like a good technical debt cleanup. Thoughts?

@mkanoor
Copy link
Contributor

mkanoor commented Mar 9, 2020

@gmcculloug I think the UI uses this to display the output of simulation, we would have to coordinate with them to start using JSON instead of XML when displaying the simulation output.
https://github.com/ManageIQ/manageiq-ui-classic/blob/b0e5666b3d3abfa857856c4bae70759039f84c6c/app/presenters/tree_builder_automate_simulation_results.rb#L17
There might be other places in the UI. Otherwise looks good

@skateman
Copy link
Member

The Automate->Simulation in the UI depends on the to_xml method as the simulation results can be displayed as XML and the tree view is being built by parsing the same XML. I can try to build the tree directly from the result object, but it doesn't really help if we don't get rid of the XML view.

Screenshot-from-2020-03-11-11-15-10

@gmcculloug
Copy link
Member

@skateman I see little use for the XML View tab so I feel it is safe to remove. @mkanoor Do we have the methods to support building the Tree View from YAML or JSON?

@skateman
Copy link
Member

@gmcculloug we don't really need the YAML or JSON version, I can just build the tree directly from the objects. Faster to build directly and avoid parsing of formats...

@d-m-u
Copy link
Contributor Author

d-m-u commented Mar 13, 2020

there's also to_expanded_xml which I'm not sure if I can remove or not because we use it in miq_log_workspace(obj, _inputs) inside miq_ae_builtin_method

@skateman
Copy link
Member

That's the one I'm dependent on in the UI, but it's getting close...

@d-m-u
Copy link
Contributor Author

d-m-u commented Mar 13, 2020

gotcha, thanks

@skateman
Copy link
Member

I'm blocked by #418 but @jrafanie is working on it

@d-m-u
Copy link
Contributor Author

d-m-u commented Mar 13, 2020

it's fine, this's got that failing spec that i'm looking into, there's no rush

@skateman
Copy link
Member

Orienting in the code is way too complicated for me, so maybe @mkanoor's idea about you implementing a to_json version isn't that bad...if you can.

@gmcculloug gmcculloug assigned tinaafitz and unassigned gmcculloug Apr 2, 2020
@lfu
Copy link
Member

lfu commented May 28, 2020

How about xml_import? Do we not remove it this time?

@djberg96
Copy link
Contributor

@skateman, @lfu is the baked in Rails method something we could use?

https://apidock.com/rails/Hash/to_xml

@miq-bot
Copy link
Member

miq-bot commented Aug 11, 2020

Checked commit d-m-u@9a57516 with ruby 2.5.7, rubocop 0.69.0, haml-lint 0.28.0, and yamllint
5 files checked, 0 offenses detected
Everything looks fine. 👍

@d-m-u
Copy link
Contributor Author

d-m-u commented Dec 11, 2020

I don't think we can make this change without an implementation of to_json.

@d-m-u d-m-u closed this Dec 11, 2020
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.

9 participants