https://pulumi.com logo
Title
a

agreeable-ram-97887

03/27/2021, 7:00 PM
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

billowy-army-68599

03/27/2021, 7:07 PM
Use triple quotes to start and end them
“”” A long String With multiple Lines “””
a

agreeable-ram-97887

03/27/2021, 7:20 PM
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

billowy-army-68599

03/27/2021, 7:56 PM
you could construct the YAML from a dict using the standard YAML function of your language
a

agreeable-ram-97887

03/27/2021, 8:18 PM
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

billowy-army-68599

03/28/2021, 5:22 PM
There’s also kube2pulumi https://www.pulumi.com/kube2pulumi/
😍 2
a

agreeable-ram-97887

03/28/2021, 6:35 PM
Great tip!!