Hi people, when generating "spec" and "metadata" i...
# python
a
Hi people, when generating "spec" and "metadata" inputs for kubernetes resources, how would you all suggest handling inputs that should be given as multi-line literals?
for example, a section such as this:
b
Use triple quotes to start and end them
“”” A long String With multiple Lines “””
a
even when inserting resource IDs and such from other dynamic resources?
And, if im not mistaken, these lines should remove all indentation? If so, that will lead to some not-so-pretty code. But I guess that's alright 🤷. TBH, I was hoping Pulumi had some sort of elegant helper object for this to avoid having to write yaml-in-python
but anyway, thanks @billowy-army-68599!
b
you could construct the YAML from a dict using the standard YAML function of your language
a
yeah, normally that is what I would do. But specifically the multi-line literals seemed to be the crux, there, since I don't think it can be expressed with a simple dictionary 🙈. If I'm not mistaken, the examples you provided don't include this either? (although I'm not super-great as TS, so maybe I'm missing it)
btw, going about it the """ way leads to some weird code structure. One can't easily read the yaml anymore. But it works 😅
To connect this with a parallel question (which @billowy-army-68599 was also helpful with 🙏), it's possible that using a transformation would have been the better way to go, here, rather than resorting to fully re-building the yaml file's contents
b
There’s also kube2pulumi https://www.pulumi.com/kube2pulumi/
😍 2
a
Great tip!!