Skip to content
  • Stan Hu's avatar
    Fix parsing of --kubernetes-host_aliases command-line flag · c35d2a28
    Stan Hu authored
    Previously the `--kubernetes-host_aliases` flag would be ignored. The
    CLI flag module uses Go Reflection to recursively generate
    command-line flags for the `RunnerConfig` structure. However, the flag
    parser inside `golang-cli-helpers` does not attempt to unmarshal a
    slice of `KubernetesHostAliases` structs because it does not know how
    to map a string to that struct.
    
    As documented in https://github.com/jessevdk/go-flags, a struct can
    define an `UnmarshalFlag` method.  We can define this method to parse
    JSON data from the command-line.
    
    Using Go Reflection, I also determined that this was the only
    command-line argument that needed this custom parsing. I omitted that
    test case to keep the review straightforward, but I can add it in a
    separate commit.
    
    Relates to https://gitlab.com/gitlab-org/gitlab-runner/-/issues/37802
    
    Changelog: changed
    c35d2a28