-
Notifications
You must be signed in to change notification settings - Fork 463
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
Initial prototype of a XML transformation hook based on XSLT #431
Conversation
7829ec4
to
21f9bfa
Compare
i will have a look more in details on this during the week. Generally i think is a good idea to have this kind of A part of this, i think as reminder we should keep in mind to take care also the following mechanism:
In this case we should keep in mind that an user can modify the created initial xlst with other parameters in the file and this imho should force the recreation of the Basically:
Also as corner case , we should not have a Diff if the xlst has spaces/tab etc, so we don't force recreation of resource for nothing ( see past cloudinit bug). I will have look more and think about it more with calm 😃 |
That is a great idea, and I think I might need that feature very soon! ❤️ ❤️ ❤️ |
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.
sofar looks good but as corner case we might consider the update
of resources
d6e0499
to
52417f9
Compare
@dmacvicar What about skipping the transformation if Rationale: make transformation optional based on some other boolean. For example, in my use case, I need to leave the XML unchanged if there is no need to change the declared "hardware type". Alternatively (more powerful, but also more complicated), we could pass parameters ( Note: I'm currently able to work around with code like:
|
We can make it a no-op if xslt.(string) is empty. But then you would end with: xslt = "${var.hardware_type ? file(var.hardware_type) : ""}" Is that ok? |
@dmacvicar yes, that was exactly the idea. That would spare writing the An alternate idea could be to make |
@MalloZup I am using this feature for the test suite, so I would need it packaged. For me it is good enough in this current state, and it just works smoothly. |
I still need to do a last pass before merging. Hook the diff function and add the transformation to the other resources. |
https://github.com/dmacvicar/terraform-provider-libvirt/blob/master/libvirt/resource_libvirt_cloud_init_test.go#L72 |
Blocked by #459 (can't run acceptance tests locally) |
i will revert the PR today ( for having like before the testacc) |
52417f9
to
7551401
Compare
One function to depend on ResourceData and to be shared across resources. One function used to test the transformation itself.
0d65599
to
53f7811
Compare
I think I have addressed all points. If you are fine with the nested This is a very advanced feature that should not be for day to day use, but to address shortcomings of the schema and corner cases, like our teams running testsuites with it. //cc @Bischoff |
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.
I like the ability of having temporary fixes while an official fix is not ready yet. In general, it is a much saner approach not to have a functionality rather to have it wrong - while still providing a way out to users (C#'s initially minimalistic approach, with very slow additions only when problems and solutions are very well understood comes to mind).
I had a look at the code and could not find surprises, although I do not feel authoritative at all yet!
Thanks @dmacvicar !!! |
Sometimes the provider does not allow to set some libvirt attributes. Good examples are #350 (the provider does not allow to change the NIC model) #419 (one needs to add a touch device).
This PR explores the idea of allowing for a transformation hook before creating the domain. The hook is in the form of a XSLT stylesheet. This allow for almost unlimited capabilities when "editing" the generated XML.
nicmodel.xsl:
Some notes about the implementation:
xslt
property nested into anxml
element.The idea is of this PR is to gather some feedback and foresee problems I may not be seeing yet.
//cc @ncsurfus @unsubtleguy
TODO