Skip to content

Commit e7f77c1

Browse files
webwarrior-wsknocte
authored andcommitted
FileConventions: skip values not in env dict
When searching for vars referenced in Github workflow files. This is needed because workflows in pulumi-deploy now load vars from .env file and so there can be references to variables that are not in env dictionary of .yaml file.
1 parent 01eacf8 commit e7f77c1

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

src/FileConventions/Library.fs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -391,25 +391,24 @@ let private DetectInconsistentVersionsInYamlFiles
391391
if variableRegexMatch.Success then
392392
let yamlDict = yamlDoc :?> YamlMappingNode
393393

394-
let envDict =
395-
yamlDict.Children.["env"]
396-
:?> YamlMappingNode
397-
398-
let referenceString =
399-
variableRegexMatch.Groups.[1].Value
400-
401-
let envVarName =
402-
if referenceString.StartsWith "env." then
403-
referenceString.[4..]
404-
else
405-
referenceString
406-
407-
match envDict.Children.TryGetValue envVarName
408-
with
409-
| true, envVarValue ->
410-
(envVarValue :?> YamlScalarNode).Value
411-
| false, _ ->
412-
failwithf "env. var %s not found" envVarName
394+
match yamlDict.Children.TryGetValue "env" with
395+
| true, (:? YamlMappingNode as envDict) ->
396+
let referenceString =
397+
variableRegexMatch.Groups.[1].Value
398+
399+
let envVarName =
400+
if referenceString.StartsWith "env." then
401+
referenceString.[4..]
402+
else
403+
referenceString
404+
405+
match
406+
envDict.Children.TryGetValue envVarName
407+
with
408+
| true, envVarValue ->
409+
(envVarValue :?> YamlScalarNode).Value
410+
| false, _ -> value
411+
| _ -> value
413412
else
414413
value
415414

0 commit comments

Comments
 (0)