https://pulumi.com logo
#automation-api
Title
# automation-api
l

limited-rainbow-51650

03/11/2021, 7:46 PM
Does the
ConfigMap
type in:
Copy code
// SetAllConfig sets all values in the provided config map.
func (s *Stack) SetAllConfig(ctx context.Context, config ConfigMap) error {
	return s.Workspace().SetAllConfig(ctx, s.Name(), config)
}
support Pulumi structured configuration? It doesn’t look like it.
r

red-match-15116

03/11/2021, 7:50 PM
It does not probably the way you expect it. You can, however, pass in structured configuration as serialized json strings.
l

limited-rainbow-51650

03/11/2021, 7:56 PM
I guess I’m missing something about your suggestion. Do you have a small code snippet to expand on your thinking?
r

red-match-15116

03/11/2021, 7:57 PM
There are some rough edges, for instance: https://github.com/pulumi/pulumi/issues/6352 But it is possible to work with structured configuration as long as you handle the (de)serialization in your code. Would welcome contributions to make this better if you feel inspired, but it’s not in our list of immediately prioritized items.
I guess I’m missing something about your suggestion. Do you have a small code snippet to expand on your thinking?
I think the issue I linked might be helpful to understand what goes on, but essentially to set a map you would have to set the top-level config key
Copy code
s.Workspace().SetConfig(ctx, s.Name, "myTopLevelKey", ConfigValue{Value: "{'inner': 'foo', 'another': 'bar}", Secret: false})
To get that config, you would have to get the top-level config:
Copy code
s.Workspace().GetConfig(ctx, s.Name, "myTopLevelKey")
And then Unmarshal the resulting json string into a struct and then access the inner keys.
As I said, definitely not an ideal flow but it is possible to work around the current limitations using the pattern I described.
l

limited-rainbow-51650

03/11/2021, 8:08 PM
Context is this: https://github.com/ringods/pulumi-resource This is a Pulumi integration with Concourse CI. To run Pulumi from Concourse, I have to create a binary accepting JSON from concourse on stdin and Unmarshal that to a Go type. I hoped that I could use
ConfigMap
at the right depth of my struct type so unmarshalling would be based on the
ConfigMap
type. But I guess I will have to intercept with a custom JSON marshaller.
So, a substructure of the
params
I receive, would be additional stack config I would pass as-is via
stack.SetAllConfig
. At least, that was my intent.
r

red-match-15116

03/11/2021, 8:19 PM
Ah yeah that makes sense. Honestly this is definitely a thing I would love to improve but alas there are too many things!
b

bored-oyster-3147

03/18/2021, 1:05 PM
It's even more difficult to support structured config in strongly typed languages like .net. I put a good amount of effort into trying to do that before we ultimately decided leaving deserialization to the consumer would be the safest way