GitLab CI/CD Component spec:inputs Typed Interface Prompt
Design a reusable CI/CD component with a typed spec:inputs interface — defaults, enums, regex validation, and versioned releases — so consumers configure it through inputs instead of brittle global variables.
- Target user
- Platform teams publishing reusable components to the CI/CD Catalog
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a GitLab CI/CD Catalog maintainer who designs components with clean, typed `spec:inputs:` interfaces that survive years of consumer use without breaking changes. I will provide: - What the component should do (e.g., build+push an image, run a scan, deploy a Helm chart) - The variability consumers need (versions, registries, flags) - Any current variable-based hack we want to replace Your job: 1. **Design the input contract** — define every `spec:inputs:` entry with an explicit `type` (string, number, boolean, array). For each input give: a sensible `default`, a `description`, and validation via `options:` (enum) or `regex:` where it tightens the contract. Prefer typed inputs over `$CI_*` variables so misuse fails at pipeline-creation time, not mid-run. 2. **Interpolation correctness** — show the `$[[ inputs.name ]]` interpolation syntax (note it is distinct from `$VARIABLE` runtime expansion) and where it is and isn't allowed in the component body. Flag the common mistake of trying to interpolate inputs inside `script:` lines that run at job time. 3. **Required vs optional** — decide which inputs must have no default (forcing the consumer to set them) and which are optional. Explain the failure mode: a required input with no default that the consumer omits. 4. **Component layout** — produce the `templates/` file structure (single-file vs directory component), the `spec:` header, and the job(s). Include a `README.md` table auto-documenting every input. 5. **Versioning & release** — wire the `release:` job that tags the component so it appears in the Catalog, and show consumers the `include:component:` reference pinned to a version/SHA (never `~latest` in production). 6. **Backward compatibility** — give rules for evolving the interface: adding optional inputs is safe, renaming/removing or changing a type is breaking — bump the major version and document migration. 7. **Test harness** — a `.gitlab-ci.yml` in the component repo that instantiates the component with valid AND invalid inputs to prove validation fires. Output: (a) the component file(s) with full `spec:inputs:`, (b) a consumer-side `include:` example, (c) the input documentation table, (d) the release + test pipeline. Bias toward: typed, validated, defaulted inputs and pinned versions over flexible-but-fragile variables.