Add --docker-pull-policy flag to register command (closes #39304)

Summary

The --docker-pull-policy flag was previously invisible to the CLI flag parser despite having a long:"pull-policy" struct tag because the field type (StringOrArray []string) only implemented UnmarshalTOML and not UnmarshalFlag from the golang-cli-helpers library. The reflection-based flag generator fell through to the generic slice converter, which produced a broken flag.

Root cause

StringOrArray is a named slice type at common/config.go:244. The convertUnmarshal function in golang-cli-helpers checks for the Unmarshaler interface (UnmarshalFlag(string) error). Without it, the converter used the generic reflect.Slice branch, which does not correctly map a named type to a reusable cli.Flag. The flag was auto-generated in help text but could not be parsed.

Fix

Added UnmarshalFlag to StringOrArray in common/config.go, following the established pattern of KubernetesHostAliasesFlag.UnmarshalFlag in the same file. This lets golang-cli-helpers properly convert the CLI string value into the slice. Also updated the docs to include --docker-pull-policy in all Docker non-interactive registration examples.

Verification

  • go build ./... passes
  • go vet ./... passes (no new warnings)
  • go test -race ./common/... -run TestStringOrArray -v — all 11 tests pass
  • make lint — 0 new issues
  • --docker-pull-policy now appears and works in gitlab-runner register --help

Merge request reports

Loading