Kind of a weird question about formatting, and how it translates here, but for some of our applications we would like to set a nodeSelector.
Currently, I believe the HELM charts we have accept.
nodeSelector: {}
In the app, we have
- name: example_node_selector
title: Example
help_text: The nodeSelector you would like to assign to the scanner ( Formatted like foo: "bar")
type: text
default: {}
when: repl{{ ConfigOptionEquals "example_trigger" "1" }}
So in this example we would like this to be an empty array if it’s left blank, versus empty string.
And the example in our deployment.yaml would be…
Note: indentation number might differ. I specified 6 because you mentioned this is for a deployment.
Also, I would recommend passing --lint when creating releases via the CLI as it would’ve caught some of these issues. Or you can try using the vendor portal UI and the lint results would show up as you’re modifying the release resources.
Thanks for clarifying, I was just wondering primarily about the spec of how the kubernetes deployment would interpret the above since it’s a nodeLabel.
For example, most nodeLabels are read in as…
nodeSelector: { foo: "bar" }
Which I believe translates to.
nodeSelector:
foo: "bar"
I was just wondering if it would properly interpret the braces here specifically for nodeLabels I just didn’t want it to interpret the key as a stringified value as well, since I don’t believe they should be.
If you follow the changes I recommended above, it wouldn’t translate to a stringified value, it would end up as a map/object of key/value pairs and the deployment should interpret them correctly. and the default value would end up as {} not “{}” so that should also work just fine.
So we hit the same question, but now for hard mode.
We want to take another “foo: bar” string from a ConfigOption and optionally add it to the node selector map. The naive approach did not work for us,
hoping that template line will just expand to nothing, but which fails replicated release lint with yaml: line 24: could not find expected ':' That and various experiments with different quoting types. Is there a right way to make that work?
This seems better, at least it passes lint. I parse the option and reconstruct the dict using merge and convert to one-line json.