Skip to content

Commit

Permalink
Implement conditional resources and modules (Azure#1014)
Browse files Browse the repository at this point in the history
* Add support to conditional resource and module declarations

* Add tests and refactor code

* Simplify grammar to not use recursion

* Finetune error recovery and add more test cases

* Block runtime functions in resource and module conditions

* Fix completions
  • Loading branch information
shenglol authored Dec 14, 2020
1 parent 612eac6 commit 4b3e8b1
Show file tree
Hide file tree
Showing 71 changed files with 17,294 additions and 13,959 deletions.
4 changes: 3 additions & 1 deletion docs/grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ parameterDefaultValue -> "=" expression
variableDecl -> "variable" IDENTIFIER(name) "=" expression NL
resourceDecl -> "resource" IDENTIFIER(name) interpString(type) "=" object NL
resourceDecl -> "resource" IDENTIFIER(name) interpString(type) "=" ifCondition? object NL
moduleDecl -> "module" IDENTIFIER(name) interpString(type) "=" object NL
Expand Down Expand Up @@ -85,6 +85,8 @@ argumentList -> expression ("," expression)*
parenthesizedExpression -> "(" expression ")"
ifCondition -> "if" parenthesizedExpression
interpString -> interpStringLeftPiece ( expression interpStringMiddlePiece )* expression interpStringRightPiece | literalString
interpStringLeftPiece -> "'" STRINGCHAR* "${"
interpStringMiddlePiece -> "}" STRINGCHAR* "${"
Expand Down
14 changes: 6 additions & 8 deletions src/Bicep.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
using Bicep.Cli.CommandLine;
using Bicep.Cli.CommandLine.Arguments;
using Bicep.Cli.Logging;
using Bicep.Core.Diagnostics;
using Bicep.Core.Emit;
using Bicep.Core.FileSystem;
using Bicep.Core.Semantics;
using Bicep.Core.Syntax;
using Bicep.Core.Text;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Bicep.Cli.CommandLine.Arguments;
using Bicep.Core.TypeSystem.Az;
using Bicep.Core.TypeSystem;
using Bicep.Core.Diagnostics;
using Bicep.Core.FileSystem;
using Bicep.Core.TypeSystem.Az;
using Bicep.Core.Workspaces;
using Bicep.Decompiler;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;

namespace Bicep.Cli
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[
{
"label": "arrayOutput",
"kind": "property",
"detail": "arrayOutput",
"documentation": {
"kind": "markdown",
"value": "Type: `array` \nRead-only property \n"
},
"deprecated": false,
"preselect": false,
"sortText": "2_arrayOutput",
"insertTextFormat": "plainText",
"insertTextMode": "asIs",
"textEdit": {
"range": {},
"newText": "arrayOutput"
},
"commitCharacters": [
"."
]
},
{
"label": "objOutput",
"kind": "property",
"detail": "objOutput",
"documentation": {
"kind": "markdown",
"value": "Type: `object` \nRead-only property \n"
},
"deprecated": false,
"preselect": false,
"sortText": "2_objOutput",
"insertTextFormat": "plainText",
"insertTextMode": "asIs",
"textEdit": {
"range": {},
"newText": "objOutput"
},
"commitCharacters": [
"."
]
},
{
"label": "stringOutputA",
"kind": "property",
"detail": "stringOutputA",
"documentation": {
"kind": "markdown",
"value": "Type: `string` \nRead-only property \n"
},
"deprecated": false,
"preselect": false,
"sortText": "2_stringOutputA",
"insertTextFormat": "plainText",
"insertTextMode": "asIs",
"textEdit": {
"range": {},
"newText": "stringOutputA"
},
"commitCharacters": [
"."
]
},
{
"label": "stringOutputB",
"kind": "property",
"detail": "stringOutputB",
"documentation": {
"kind": "markdown",
"value": "Type: `string` \nRead-only property \n"
},
"deprecated": false,
"preselect": false,
"sortText": "2_stringOutputB",
"insertTextFormat": "plainText",
"insertTextMode": "asIs",
"textEdit": {
"range": {},
"newText": "stringOutputB"
},
"commitCharacters": [
"."
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[
{
"label": "arrayParam",
"kind": "property",
"detail": "arrayParam (Required)",
"documentation": {
"kind": "markdown",
"value": "Type: `array` \nWrite-only property \n"
},
"deprecated": false,
"preselect": false,
"sortText": "2_arrayParam",
"insertTextFormat": "plainText",
"insertTextMode": "asIs",
"textEdit": {
"range": {},
"newText": "arrayParam"
},
"commitCharacters": [
":"
]
},
{
"label": "objParam",
"kind": "property",
"detail": "objParam (Required)",
"documentation": {
"kind": "markdown",
"value": "Type: `object` \nWrite-only property \n"
},
"deprecated": false,
"preselect": false,
"sortText": "2_objParam",
"insertTextFormat": "plainText",
"insertTextMode": "asIs",
"textEdit": {
"range": {},
"newText": "objParam"
},
"commitCharacters": [
":"
]
},
{
"label": "stringParamA",
"kind": "property",
"detail": "stringParamA",
"documentation": {
"kind": "markdown",
"value": "Type: `string` \nWrite-only property \n"
},
"deprecated": false,
"preselect": false,
"sortText": "2_stringParamA",
"insertTextFormat": "plainText",
"insertTextMode": "asIs",
"textEdit": {
"range": {},
"newText": "stringParamA"
},
"commitCharacters": [
":"
]
},
{
"label": "stringParamB",
"kind": "property",
"detail": "stringParamB (Required)",
"documentation": {
"kind": "markdown",
"value": "Type: `string` \nWrite-only property \n"
},
"deprecated": false,
"preselect": false,
"sortText": "2_stringParamB",
"insertTextFormat": "plainText",
"insertTextMode": "asIs",
"textEdit": {
"range": {},
"newText": "stringParamB"
},
"commitCharacters": [
":"
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[
{
"label": "dependsOn",
"kind": "property",
"detail": "dependsOn",
"documentation": {
"kind": "markdown",
"value": "Type: `resource | module[]` \nWrite-only property \n"
},
"deprecated": false,
"preselect": false,
"sortText": "2_dependsOn",
"insertTextFormat": "plainText",
"insertTextMode": "asIs",
"textEdit": {
"range": {},
"newText": "dependsOn"
},
"commitCharacters": [
":"
]
},
{
"label": "name",
"kind": "property",
"detail": "name (Required)",
"documentation": {
"kind": "markdown",
"value": "Type: `string` \n"
},
"deprecated": false,
"preselect": false,
"sortText": "2_name",
"insertTextFormat": "plainText",
"insertTextMode": "asIs",
"textEdit": {
"range": {},
"newText": "name"
},
"commitCharacters": [
":"
]
},
{
"label": "params",
"kind": "property",
"detail": "params (Required)",
"documentation": {
"kind": "markdown",
"value": "Type: `params` \nWrite-only property \n"
},
"deprecated": false,
"preselect": false,
"sortText": "2_params",
"insertTextFormat": "plainText",
"insertTextMode": "asIs",
"textEdit": {
"range": {},
"newText": "params"
},
"commitCharacters": [
":"
]
},
{
"label": "scope",
"kind": "property",
"detail": "scope",
"documentation": {
"kind": "markdown",
"value": "Type: `resourceGroup` \nWrite-only property \n"
},
"deprecated": false,
"preselect": false,
"sortText": "2_scope",
"insertTextFormat": "plainText",
"insertTextMode": "asIs",
"textEdit": {
"range": {},
"newText": "scope"
},
"commitCharacters": [
":"
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[
{
"label": "dependsOn",
"kind": "property",
"detail": "dependsOn",
"documentation": {
"kind": "markdown",
"value": "Type: `resource | module[]` \nWrite-only property \n"
},
"deprecated": false,
"preselect": false,
"sortText": "2_dependsOn",
"insertTextFormat": "plainText",
"insertTextMode": "asIs",
"textEdit": {
"range": {},
"newText": "dependsOn"
},
"commitCharacters": [
":"
]
},
{
"label": "params",
"kind": "property",
"detail": "params (Required)",
"documentation": {
"kind": "markdown",
"value": "Type: `params` \nWrite-only property \n"
},
"deprecated": false,
"preselect": false,
"sortText": "2_params",
"insertTextFormat": "plainText",
"insertTextMode": "asIs",
"textEdit": {
"range": {},
"newText": "params"
},
"commitCharacters": [
":"
]
},
{
"label": "scope",
"kind": "property",
"detail": "scope",
"documentation": {
"kind": "markdown",
"value": "Type: `resourceGroup` \nWrite-only property \n"
},
"deprecated": false,
"preselect": false,
"sortText": "2_scope",
"insertTextFormat": "plainText",
"insertTextMode": "asIs",
"textEdit": {
"range": {},
"newText": "scope"
},
"commitCharacters": [
":"
]
}
]
Loading

0 comments on commit 4b3e8b1

Please sign in to comment.