Add GraphQL types
What does this MR do and why?
Final part of #563376
- Add ConditionType, RuleType GraphQL types
- Add rules field to SpecType
- Add BaseInput#rules accessor
- RuleType converts expressionz to json via RulesConverter
References
| MR | Status | Description |
|---|---|---|
| Input lexeme | !206891 (merged) | Parse $[[ inputs.X ]] syntax in expressions |
| Rules converter | In review: !209135 (merged) | Convert expression AST to JSON |
| Semantic validation | In review: !209496 | Validate input references and circular dependencies, error handlin |
| GraphQL API |
|
Expose rules with condition trees |
How to set up and validate locally
query:
query {
project(fullPath: "root/house-of-1000-pipelines") {
ciPipelineCreationInputs(ref: "main") {
name
type
options
rules {
if
conditionTree {
operator
field
value
children {
operator
field
value
}
}
options
default
}
}
}
}
response will be something like:
{
"data": {
"project": {
"ciPipelineCreationInputs": [
{
"name": "deployment_type",
"type": "STRING",
"options": [
"rolling",
"blue_green",
"canary"
],
"rules": null
},
{
"name": "target_environment",
"type": "STRING",
"options": [
"development",
"staging",
"production"
],
"rules": null
},
{
"name": "resource_tier",
"type": "STRING",
"options": null,
"rules": [
{
"if": "$[[ inputs.target_environment ]] == \"development\"",
"conditionTree": {
"operator": "equals",
"field": "target_environment",
"value": "development",
"children": null
},
"options": [
"small",
"medium"
],
"default": "small"
},
{
"if": "$[[ inputs.target_environment ]] == \"staging\"",
"conditionTree": {
"operator": "equals",
"field": "target_environment",
"value": "staging",
"children": null
},
"options": [
"medium",
"large"
],
"default": "medium"
},
{
"if": "$[[ inputs.target_environment ]] == \"production\" && $[[ inputs.deployment_type ]] == \"canary\"",
"conditionTree": {
"operator": "AND",
"field": null,
"value": null,
"children": [
{
"operator": "equals",
"field": "target_environment",
"value": "production"
},
{
"operator": "equals",
"field": "deployment_type",
"value": "canary"
}
]
},
"options": [
"large",
"xlarge",
"xxlarge"
],
"default": "large"
},
{
"if": "$[[ inputs.target_environment ]] == \"production\"",
"conditionTree": {
"operator": "equals",
"field": "target_environment",
"value": "production",
"children": null
},
"options": [
"large",
"xlarge"
],
"default": "xlarge"
},
{
"if": null,
"conditionTree": null,
"options": [
"small"
],
"default": null
}
]
}
]
}
},
"correlationId": "01K8AXA1M0NV1RHVAD4TFT5X80"
}
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Laura Montemayor