How to set a list of strings for a key in config-map
Howdy! I'm trying to find a way to set a list of strings for a key via the pulumi/actions config-map property. This is a follow-up on the discussion in Slack.
I tried to set it with: "some-key":{"value":["some-value-a","some-value-b"]} which leads to a comma-separated string some-value-a,some-value-b in the Pulumi.stack.yaml.
I also tried to send: {"some-other-key":[{"value":"some-other-value-a"},{"value":"some-other-value-b"}]} which leads to a string undefined in the Pulumi.stack.yaml.
What I would like to see is:
<pulumi-project>:some-key:
- some-value-a
- some-value-b
This could be defined via cli with pulumi config set --path "some-key[0]" "some-value-a" but how do you do it via automation api?
@jalmeroth thanks for reporting this. If I have this right, you have an @pulumi/actions job like so:
- uses: pulumi/actions@v3
with:
config-map:
some-key:
value:
- some-value-a
- some-value-b
And when the program runs, this is being turned into a string, or something like that?
@jalmeroth thanks for reporting this. If I have this right, you have an @pulumi/actions job like so:
- uses: pulumi/actions@v3 with: config-map: some-key: value: - some-value-a - some-value-bAnd when the program runs, this is being turned into a string, or something like that?
@AaronFriel thanks for digging into this.
No, I think one needs to provide a string here, otherwise it breaks the GH Workflow syntax.
What we provide looks like this:
- uses: pulumi/actions@v3
with:
config-map: "some-key": {"value": ["some-value-a", "some-value-b"]}
"some-other-key": [{"value": "some-other-value-a"}, {"value": "some-other-value-b"}]
Ha, I finally found it! The problematic code is here.
This line uses Template literals to convert the list of strings into a comma-seperated str:
args = [...args, secretArg, `${key}=${value.value}`];
I'm not into Typescript at all, but I wrote some pseudo-code that could fix the issue:
async setAllConfig(stackName: string, config: ConfigMap): Promise<void> {
let args = ["config", "set-all", "--stack", stackName];
for (const [key, value] of Object.entries(config)) {
const secretArg = value.secret ? "--secret" : "--plaintext";
if (Array.isArray(value.value)) {
args = [...args, "--path"];
value.value.forEach((value, index) => {
args = [...args, secretArg, `"${key}[${index}]"=${value}`];
});
} else {
args = [...args, secretArg, `${key}=${value.value}`];
}
}
await this.runPulumiCmd(args);
}
@AaronFriel could you please review this issue and/or remove the awaiting-feedback label. Thank you!
Hello 👋 any updates on this? Currently, we're able to work around this issue by using comma-separated string, but it would be great to be able to pass in an actual array to the config-map.
- uses: pulumi/actions@v5
with:
command: up
upsert: true
config-map: "{ ConfigKeyName: { value: "configValue1,configValue2,configValue3", secret: false } }"