Backend: Support `options:` with inputs defining `default:` value
## Problem In https://gitlab.com/gitlab-org/gitlab/-/merge_requests/112296+ we merged support for `options:` to be used for validating that the input value is one of the provided options. However, `options:` is not currently a supported keyword in the `spec:inputs` entry and the implementation in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/112296 for the `Ci::Input::Arguments::Options` only supports required inputs (without `default:` value). We also need to support optional inputs with validation through `options:` ```yaml spec: inputs: env: options: [test, staging, production] default: test ``` ## Proposal - Support `options:` keyword in `spec:inputs` entry: https://gitlab.com/gitlab-org/gitlab/-/blob/71ebc9ba40f3f1522a2d4d8e539b33a624bc3c5c/lib/gitlab/ci/config/header/input.rb#L13 - Ensure `options:` is used to validate the final value from both required and optional inputs. - In case of an invalid input (not part of `options`), we should print out an error message `input $[input_name] should be one of the following...` ## Implementation Table <!-- _NOTE: If the issue is not part of an epic, the implementation table can be removed. If it is part of an epic, make sure that the implementation table below mirrors the corresponding epic's implementation table content._ --> | Group | Issue Link | | ------ | ------ | | ~backend | https://gitlab.com/gitlab-org/gitlab/-/issues/426596 | | ~backend | :point_left: You are here |
issue
Advertisement
Advertisement