Allow spec:input type of hash or allow variable passthrough in template
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Proposal
Example problem
.gitlab-ci.yml
include:
- project: "my-project"
ref: v2
file: "/gitlab-template.yml"
inputs:
env: "development"
a_url: "https://localhost:8080"
b_url: "https://localhost:8081"
c_url: "https://localhost:8082"
my-project/gitlab-template.yml
spec:
inputs:
env:
options:
- "development"
- "staging"
- "production"
a_url: # Optional Input
type: string
default: ""
b_url: # Optional Input
type: string
default: ""
c_url: # Optional Input
type: string
default: ""
---
"plan $[[ inputs.env ]]":
stage: "plan"
image: "my-test:latest"
variables:
ENV: "$[[ inputs.env ]]"
A_URL: $[[ inputs.a_url ]] <----- --|
B_URL: $[[ inputs.b_url ]] <----- | These variables are optional, repetitive, unpredictable
C_URL: $[[ inputs.c_url ]] <----- --|
parallel:
matrix:
- AWS_REGION: us-east-1
- AWS_REGION: us-west-2
script:
- terraform init # will use env vars set
- terraform plan # will use env vars set
The problem is clearly seen that spec:inputs are not scalable as you would expect a template to be because there is no way to say "just pass these inputs in as env vars.". This creates a big problem for things like running terraform where the providers or other aspects can take any random environment variable. My 2 ideas were below:
1. allow a hash type for the spec inputs. This would allow us to do something like the following:
include:
- project: "my-project"
ref: v2
file: "/gitlab-template.yml"
inputs:
env: "dev"
extra_vars:
a_url: "https://localhost:8080"
b_url: "https://localhost:8081"
c_url: "https://localhost:8082"
spec:
inputs:
env:
options:
- "development"
- "staging"
- "production"
extra_vars:
type: hash
default:
test_var: "test"
---
"plan $[[ inputs.env ]]":
stage: "plan"
image: "my-test:latest"
variables:
ENV: "$[[ inputs.env ]]"
"$[[ inputs.extra_vars ]]" <------- This is a problem because of expected variable hash block :(
script:
- terraform init # will use env vars set
- terraform plan # will use env vars set
2. allow variable passthrough.
This would basically be setting all inputs as env vars
Edited by 🤖 GitLab Bot 🤖