Skip to content

Commit 24500c3

Browse files
Add type definitions for environment() & deployment() built-ins (#983)
1 parent 4ffcead commit 24500c3

25 files changed

+570
-65
lines changed

src/Bicep.Core.Samples/Files/InvalidVariables_LF/Completions/objectVarTopLevelIndexes.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,48 @@
419419
"newText": "intersection($0)"
420420
}
421421
},
422+
{
423+
"label": "invalidEnvAuthVar",
424+
"kind": "variable",
425+
"detail": "invalidEnvAuthVar",
426+
"deprecated": false,
427+
"preselect": false,
428+
"sortText": "2_invalidEnvAuthVar",
429+
"insertTextFormat": "plainText",
430+
"insertTextMode": "asIs",
431+
"textEdit": {
432+
"range": {},
433+
"newText": "invalidEnvAuthVar"
434+
}
435+
},
436+
{
437+
"label": "invalidEnvironmentVar",
438+
"kind": "variable",
439+
"detail": "invalidEnvironmentVar",
440+
"deprecated": false,
441+
"preselect": false,
442+
"sortText": "2_invalidEnvironmentVar",
443+
"insertTextFormat": "plainText",
444+
"insertTextMode": "asIs",
445+
"textEdit": {
446+
"range": {},
447+
"newText": "invalidEnvironmentVar"
448+
}
449+
},
450+
{
451+
"label": "invalidLocationVar",
452+
"kind": "variable",
453+
"detail": "invalidLocationVar",
454+
"deprecated": false,
455+
"preselect": false,
456+
"sortText": "2_invalidLocationVar",
457+
"insertTextFormat": "plainText",
458+
"insertTextMode": "asIs",
459+
"textEdit": {
460+
"range": {},
461+
"newText": "invalidLocationVar"
462+
}
463+
},
422464
{
423465
"label": "invalidNamespaceAssignment",
424466
"kind": "variable",

src/Bicep.Core.Samples/Files/InvalidVariables_LF/Completions/symbols.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,48 @@
419419
"newText": "intersection($0)"
420420
}
421421
},
422+
{
423+
"label": "invalidEnvAuthVar",
424+
"kind": "variable",
425+
"detail": "invalidEnvAuthVar",
426+
"deprecated": false,
427+
"preselect": false,
428+
"sortText": "2_invalidEnvAuthVar",
429+
"insertTextFormat": "plainText",
430+
"insertTextMode": "asIs",
431+
"textEdit": {
432+
"range": {},
433+
"newText": "invalidEnvAuthVar"
434+
}
435+
},
436+
{
437+
"label": "invalidEnvironmentVar",
438+
"kind": "variable",
439+
"detail": "invalidEnvironmentVar",
440+
"deprecated": false,
441+
"preselect": false,
442+
"sortText": "2_invalidEnvironmentVar",
443+
"insertTextFormat": "plainText",
444+
"insertTextMode": "asIs",
445+
"textEdit": {
446+
"range": {},
447+
"newText": "invalidEnvironmentVar"
448+
}
449+
},
450+
{
451+
"label": "invalidLocationVar",
452+
"kind": "variable",
453+
"detail": "invalidLocationVar",
454+
"deprecated": false,
455+
"preselect": false,
456+
"sortText": "2_invalidLocationVar",
457+
"insertTextFormat": "plainText",
458+
"insertTextMode": "asIs",
459+
"textEdit": {
460+
"range": {},
461+
"newText": "invalidLocationVar"
462+
}
463+
},
422464
{
423465
"label": "invalidNamespaceAssignment",
424466
"kind": "variable",

src/Bicep.Core.Samples/Files/InvalidVariables_LF/Completions/twoIndexPlusSymbols.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,48 @@
437437
"newText": "intersection($0)"
438438
}
439439
},
440+
{
441+
"label": "invalidEnvAuthVar",
442+
"kind": "variable",
443+
"detail": "invalidEnvAuthVar",
444+
"deprecated": false,
445+
"preselect": false,
446+
"sortText": "2_invalidEnvAuthVar",
447+
"insertTextFormat": "plainText",
448+
"insertTextMode": "asIs",
449+
"textEdit": {
450+
"range": {},
451+
"newText": "invalidEnvAuthVar"
452+
}
453+
},
454+
{
455+
"label": "invalidEnvironmentVar",
456+
"kind": "variable",
457+
"detail": "invalidEnvironmentVar",
458+
"deprecated": false,
459+
"preselect": false,
460+
"sortText": "2_invalidEnvironmentVar",
461+
"insertTextFormat": "plainText",
462+
"insertTextMode": "asIs",
463+
"textEdit": {
464+
"range": {},
465+
"newText": "invalidEnvironmentVar"
466+
}
467+
},
468+
{
469+
"label": "invalidLocationVar",
470+
"kind": "variable",
471+
"detail": "invalidLocationVar",
472+
"deprecated": false,
473+
"preselect": false,
474+
"sortText": "2_invalidLocationVar",
475+
"insertTextFormat": "plainText",
476+
"insertTextMode": "asIs",
477+
"textEdit": {
478+
"range": {},
479+
"newText": "invalidLocationVar"
480+
}
481+
},
440482
{
441483
"label": "invalidNamespaceAssignment",
442484
"kind": "variable",

src/Bicep.Core.Samples/Files/InvalidVariables_LF/main.bicep

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ var doubleString = "bad string"
9090
var resourceGroup = ''
9191
var rgName = resourceGroup().name
9292

93+
// this does not work at the resource group scope
94+
var invalidLocationVar = deployment().location
95+
96+
var invalidEnvironmentVar = environment().aosdufhsad
97+
var invalidEnvAuthVar = environment().authentication.asdgdsag
98+
9399
// invalid use of reserved namespace
94100
var az = 1
95101

src/Bicep.Core.Samples/Files/InvalidVariables_LF/main.diagnostics.bicep

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ var resourceGroup = ''
146146
var rgName = resourceGroup().name
147147
//@[13:26) [BCP059 (Error)] The name "resourceGroup" is not a function. |resourceGroup|
148148

149+
// this does not work at the resource group scope
150+
var invalidLocationVar = deployment().location
151+
//@[38:46) [BCP053 (Error)] The type "environment" does not contain property "location". Available properties include "name". |location|
152+
153+
var invalidEnvironmentVar = environment().aosdufhsad
154+
//@[42:52) [BCP053 (Error)] The type "environment" does not contain property "aosdufhsad". Available properties include "activeDirectoryDataLake", "authentication", "batch", "gallery", "graph", "graphAudience", "locations", "media", "name", "portal", "resourceManager", "sqlManagement", "suffixes", "vmImageAliasDoc". |aosdufhsad|
155+
var invalidEnvAuthVar = environment().authentication.asdgdsag
156+
//@[53:61) [BCP053 (Error)] The type "authentication" does not contain property "asdgdsag". Available properties include "audiences", "identityProvider", "loginEndpoint", "tenant". |asdgdsag|
157+
149158
// invalid use of reserved namespace
150159
var az = 1
151160
//@[4:6) [BCP084 (Error)] The symbolic name "az" is reserved. Please use a different symbolic name. Reserved namespaces are "az", "sys". |az|

src/Bicep.Core.Samples/Files/InvalidVariables_LF/main.formatted.bicep

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ var doubleString = "bad string"
8989
var resourceGroup = ''
9090
var rgName = resourceGroup().name
9191

92+
// this does not work at the resource group scope
93+
var invalidLocationVar = deployment().location
94+
95+
var invalidEnvironmentVar = environment().aosdufhsad
96+
var invalidEnvAuthVar = environment().authentication.asdgdsag
97+
9298
// invalid use of reserved namespace
9399
var az = 1
94100

src/Bicep.Core.Samples/Files/InvalidVariables_LF/main.symbols.bicep

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ var resourceGroup = ''
119119
var rgName = resourceGroup().name
120120
//@[4:10) Variable rgName. Type: error. Declaration start char: 0, length: 33
121121

122+
// this does not work at the resource group scope
123+
var invalidLocationVar = deployment().location
124+
//@[4:22) Variable invalidLocationVar. Type: error. Declaration start char: 0, length: 46
125+
126+
var invalidEnvironmentVar = environment().aosdufhsad
127+
//@[4:25) Variable invalidEnvironmentVar. Type: error. Declaration start char: 0, length: 52
128+
var invalidEnvAuthVar = environment().authentication.asdgdsag
129+
//@[4:21) Variable invalidEnvAuthVar. Type: error. Declaration start char: 0, length: 61
130+
122131
// invalid use of reserved namespace
123132
var az = 1
124133
//@[4:6) Variable az. Type: int. Declaration start char: 0, length: 10

src/Bicep.Core.Samples/Files/InvalidVariables_LF/main.syntax.bicep

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,62 @@ var rgName = resourceGroup().name
514514
//@[29:33) Identifier |name|
515515
//@[33:35) NewLine |\n\n|
516516

517+
// this does not work at the resource group scope
518+
//@[49:50) NewLine |\n|
519+
var invalidLocationVar = deployment().location
520+
//@[0:46) VariableDeclarationSyntax
521+
//@[0:3) Identifier |var|
522+
//@[4:22) IdentifierSyntax
523+
//@[4:22) Identifier |invalidLocationVar|
524+
//@[23:24) Assignment |=|
525+
//@[25:46) PropertyAccessSyntax
526+
//@[25:37) FunctionCallSyntax
527+
//@[25:35) IdentifierSyntax
528+
//@[25:35) Identifier |deployment|
529+
//@[35:36) LeftParen |(|
530+
//@[36:37) RightParen |)|
531+
//@[37:38) Dot |.|
532+
//@[38:46) IdentifierSyntax
533+
//@[38:46) Identifier |location|
534+
//@[46:48) NewLine |\n\n|
535+
536+
var invalidEnvironmentVar = environment().aosdufhsad
537+
//@[0:52) VariableDeclarationSyntax
538+
//@[0:3) Identifier |var|
539+
//@[4:25) IdentifierSyntax
540+
//@[4:25) Identifier |invalidEnvironmentVar|
541+
//@[26:27) Assignment |=|
542+
//@[28:52) PropertyAccessSyntax
543+
//@[28:41) FunctionCallSyntax
544+
//@[28:39) IdentifierSyntax
545+
//@[28:39) Identifier |environment|
546+
//@[39:40) LeftParen |(|
547+
//@[40:41) RightParen |)|
548+
//@[41:42) Dot |.|
549+
//@[42:52) IdentifierSyntax
550+
//@[42:52) Identifier |aosdufhsad|
551+
//@[52:53) NewLine |\n|
552+
var invalidEnvAuthVar = environment().authentication.asdgdsag
553+
//@[0:61) VariableDeclarationSyntax
554+
//@[0:3) Identifier |var|
555+
//@[4:21) IdentifierSyntax
556+
//@[4:21) Identifier |invalidEnvAuthVar|
557+
//@[22:23) Assignment |=|
558+
//@[24:61) PropertyAccessSyntax
559+
//@[24:52) PropertyAccessSyntax
560+
//@[24:37) FunctionCallSyntax
561+
//@[24:35) IdentifierSyntax
562+
//@[24:35) Identifier |environment|
563+
//@[35:36) LeftParen |(|
564+
//@[36:37) RightParen |)|
565+
//@[37:38) Dot |.|
566+
//@[38:52) IdentifierSyntax
567+
//@[38:52) Identifier |authentication|
568+
//@[52:53) Dot |.|
569+
//@[53:61) IdentifierSyntax
570+
//@[53:61) Identifier |asdgdsag|
571+
//@[61:63) NewLine |\n\n|
572+
517573
// invalid use of reserved namespace
518574
//@[36:37) NewLine |\n|
519575
var az = 1

src/Bicep.Core.Samples/Files/InvalidVariables_LF/main.tokens.bicep

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,42 @@ var rgName = resourceGroup().name
342342
//@[29:33) Identifier |name|
343343
//@[33:35) NewLine |\n\n|
344344

345+
// this does not work at the resource group scope
346+
//@[49:50) NewLine |\n|
347+
var invalidLocationVar = deployment().location
348+
//@[0:3) Identifier |var|
349+
//@[4:22) Identifier |invalidLocationVar|
350+
//@[23:24) Assignment |=|
351+
//@[25:35) Identifier |deployment|
352+
//@[35:36) LeftParen |(|
353+
//@[36:37) RightParen |)|
354+
//@[37:38) Dot |.|
355+
//@[38:46) Identifier |location|
356+
//@[46:48) NewLine |\n\n|
357+
358+
var invalidEnvironmentVar = environment().aosdufhsad
359+
//@[0:3) Identifier |var|
360+
//@[4:25) Identifier |invalidEnvironmentVar|
361+
//@[26:27) Assignment |=|
362+
//@[28:39) Identifier |environment|
363+
//@[39:40) LeftParen |(|
364+
//@[40:41) RightParen |)|
365+
//@[41:42) Dot |.|
366+
//@[42:52) Identifier |aosdufhsad|
367+
//@[52:53) NewLine |\n|
368+
var invalidEnvAuthVar = environment().authentication.asdgdsag
369+
//@[0:3) Identifier |var|
370+
//@[4:21) Identifier |invalidEnvAuthVar|
371+
//@[22:23) Assignment |=|
372+
//@[24:35) Identifier |environment|
373+
//@[35:36) LeftParen |(|
374+
//@[36:37) RightParen |)|
375+
//@[37:38) Dot |.|
376+
//@[38:52) Identifier |authentication|
377+
//@[52:53) Dot |.|
378+
//@[53:61) Identifier |asdgdsag|
379+
//@[61:63) NewLine |\n\n|
380+
345381
// invalid use of reserved namespace
346382
//@[36:37) NewLine |\n|
347383
var az = 1

src/Bicep.Core.Samples/Files/Outputs_CRLF/main.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ output myArr array = [
4141

4242
output rgLocation string = resourceGroup().location
4343

44-
output crossRegion bool = resourceGroup().location == deployment().location ? false : true
44+
output isWestUs bool = resourceGroup().location != 'westus' ? false : true
4545

4646
output expressionBasedIndexer string = {
4747
eastus: {

0 commit comments

Comments
 (0)