Skip to content

Commit

Permalink
azp: add lost context access for pipeline.extends
Browse files Browse the repository at this point in the history
Fixes #371
  • Loading branch information
ChristopherHX committed Jul 19, 2024
1 parent d026547 commit 3b6cd8b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/Sdk/AzurePipelines/azurepiplines.json
Original file line number Diff line number Diff line change
Expand Up @@ -2087,7 +2087,11 @@
"type": "azp-mapping"
}
}
}
},
"context": [
"parameters",
"variables"
]
},
"jobsTemplate-0": {
"mapping": {
Expand Down
25 changes: 20 additions & 5 deletions src/Sdk/AzurePipelines/json-schema-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,28 @@ for(var id in schema.definitions) {
}

var pathsWithExpressions = [
[ "pipeline", "variables" ],
[ "pipeline", "stages" ],
[ "pipeline", "jobs" ],
[ "pipeline", "steps" ],
[ "resources", "containers" ],
[ ["pipeline", "variablesTemplate"], "variables" ],
[ ["pipeline", "stagesTemplate"], "stages" ],
[ ["pipeline", "jobsTemplate" ], "jobs" ],
[ ["pipeline", "stepsTemplate"], "steps" ],
[ "pipeline", "extends" ],
[ "pipeline", "resources", "containers" ],
[ "any_allowExpressions" ],
[ "string_allowExpressions" ],
[ "sequenceOfString_allowExpressions" ],
]

function * traverse(path) {
var comp = path[0];
if(comp instanceof Array) {
for(var sk of comp) {
var subPath = [...path]
subPath[0] = sk
for(var r of traverse(subPath)) {
yield r;
}
}
}
var schema = targetSchema.definitions[comp];
if(!schema) {
return;
Expand Down Expand Up @@ -288,4 +298,9 @@ targetSchema.definitions["nonEmptyString"] = {

targetSchema.definitions["task-task"] = targetSchema.definitions["nonEmptyString"]

// delete targetSchema.definitions["any"]

targetSchema.definitions["azp-any"]["one-of"].push("boolean", "null", "number")
targetSchema.definitions["any_allowExpressions"]["one-of"].push("boolean", "null", "number")

console.log(JSON.stringify(targetSchema, null, 4))
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ private void HandleMappingWithWellKnownProperties(
}

// Only one
if (mappingDefinitions.Count > 1)
if (mappingDefinitions.Count > 1 && !hasExpressionKey)
{
var hitCount = new Dictionary<String, Int32>();
foreach (MappingDefinition mapdef in mappingDefinitions)
Expand Down
3 changes: 3 additions & 0 deletions src/azure-pipelines-vscode-ext/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### v0.0.21 (Preview)
- Add lost context access for pipeline.extends of v0.0.20

### v0.0.20 (Preview)
- Use a full azure pipelines schema generated from the official extension / yamlschema service

Expand Down
2 changes: 1 addition & 1 deletion src/azure-pipelines-vscode-ext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"Programming Languages"
],
"icon": "pipeline-rocket.png",
"version": "0.0.20",
"version": "0.0.21",
"publisher": "christopherhx",
"repository": "https://github.com/ChristopherHX/runner.server",
"engines": {
Expand Down

0 comments on commit 3b6cd8b

Please sign in to comment.