Parsing YAML key/values as list of structs in Go

step
#1

In a step that I’m working on, I want the user to be able to provide a list of optional YAML key/value pairs for a specific step input, currently trying to implement as:

inputs:
        - uri_actions:
            - button_text: Some text
              uri: www.google.com
            - button_text: Some text 2
              uri: www.google2.com
            - button_text: Some text 3
              uri: www.google3.com

and then attempting to parse in Go as structs:

type config struct {
    UriActionList []UriAction `env:"uri_actions"`
}

type UriAction struct {
    ButtonText string `env:"button_text"`
    Uri        string `env:"uri"`
}

But this isn’t playing nice at all… what am I doing wrong? Is there a more civilised way to go about this?

0 Likes

#2

Hi @jastley!

I saw your discussion on our public slack too, so hoping this is sorted out, but in case anyone comes across this in the future, the recommended approach would be:

- my_step@1:
    inputs:
          - my_list: '[{"name":"obj","value": "123" }]'
0 Likes

#3

hey @bitce thanks for that, yeah this is what I ended up falling back to, but I don’t think it’s very user-friendly and it seemed far more intuitive to be able to set these values via YAML :confused:

0 Likes

#4

I see, thanks for letting us know! Seems like a fair request, I’ll make sure to take note :slight_smile:

0 Likes

#5

For reference, I opened a GitHub issue requesting a way to pass a list of objects to steps, while it remains intuitive for the user to continue writing YAML rather than stringified JSON workarounds :slight_smile:

0 Likes