Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extension @dotnet {
"TEAMCITY_VERSION"
"JB_SPACE_API_URL"
]
defaults = {
configuration: $configuration
defaults {
`configuration` = $configuration
}
}
10 changes: 5 additions & 5 deletions src/Terrabuild.Configuration.Tests/TestFiles/PROJECT
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# comment at top of file

extension @dotnet {
defaults = { # comment at end of line
configuration : $configuration
defaults { # comment at end of line
`configuration` = $configuration
}
}

extension @docker {
defaults = {
configuration: $configuration
image : "ghcr.io/magnusopera/dotnet-app"
defaults {
`configuration` = $configuration
`image` = "ghcr.io/magnusopera/dotnet-app"
}

variables = [ "ARM_TENANT_ID" ]
Expand Down
4 changes: 2 additions & 2 deletions src/Terrabuild.Configuration.Tests/TestFiles/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ configuration dummy

extension dotnet {
container = "mcr.microsoft.com/dotnet/sdk:8.0.101"
defaults = {
configuration: $configuration
defaults {
`configuration` = $configuration
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/Terrabuild.Configuration.Tests/TestFiles/WORKSPACE2
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ configuration {

extension dotnet {
container = "mcr.microsoft.com/dotnet/sdk:8.0.101"
defaults = {
configuration1: $map.toto
configuration2: $map.?titi
configuration3: replace("toto titi", "toto", "titi")
defaults {
configuration1 = $map.toto
configuration2 = $map.?titi
configuration3 = replace("toto titi", "toto", "titi")
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Terrabuild.Configuration/AST.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type ExtensionComponents =
| Platform of Expr
| Variables of Expr list
| Script of Expr
| Defaults of Map<string, Expr>
| Defaults of (string * Expr) list

type ExtensionBlock =
{ Container: Expr option
Expand Down Expand Up @@ -43,9 +43,9 @@ with
| _ -> raiseParseError "multiple script declared"

let defaults =
match components |> List.choose (function | ExtensionComponents.Defaults value -> Some value | _ -> None) with
match components |> List.choose (function | ExtensionComponents.Defaults values -> Some values | _ -> None) with
| [] -> Map.empty
| [value] -> value
| [values] -> values |> Map.ofList
| _ -> raiseParseError "multiple defaults declared"

name, { Container = container
Expand Down
947 changes: 493 additions & 454 deletions src/Terrabuild.Configuration/Gen/ProjectParser.fs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Terrabuild.Configuration/Gen/ProjectParser.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ type nonTerminalId =
| NONTERM_ExtensionVariables
| NONTERM_ExtensionScript
| NONTERM_ExtensionDefaults
| NONTERM_ExtensionDefaultsComponents
| NONTERM_ExtensionDefaultsComponentsVariable
| NONTERM_Project
| NONTERM_ProjectComponents
| NONTERM_ProjectDependencies
Expand Down
723 changes: 381 additions & 342 deletions src/Terrabuild.Configuration/Gen/WorkspaceParser.fs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Terrabuild.Configuration/Gen/WorkspaceParser.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ type nonTerminalId =
| NONTERM_ExtensionVariables
| NONTERM_ExtensionScript
| NONTERM_ExtensionDefaults
| NONTERM_ExtensionDefaultsComponents
| NONTERM_ExtensionDefaultsComponentsVariable
| NONTERM_Expr
| NONTERM_InterpolatedExpr
| NONTERM_TargetIdentifier
Expand Down
7 changes: 6 additions & 1 deletion src/Terrabuild.Configuration/ProjectParser/Parser.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ ExtensionVariables:
ExtensionScript:
| SCRIPT EQUAL String { ExtensionComponents.Script $3 }
ExtensionDefaults:
| DEFAULTS EQUAL ExprMap { ExtensionComponents.Defaults $3 }
| DEFAULTS LBRACE ExtensionDefaultsComponents RBRACE { ExtensionComponents.Defaults $3 }
ExtensionDefaultsComponents:
| /* empty */ { [] }
| ExtensionDefaultsComponents ExtensionDefaultsComponentsVariable { $1 @ [$2] }
ExtensionDefaultsComponentsVariable:
| IDENTIFIER EQUAL Expr { ($1, $3) }


Project:
Expand Down
9 changes: 8 additions & 1 deletion src/Terrabuild.Configuration/WorkspaceParser/Parser.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,14 @@ ExtensionVariables:
ExtensionScript:
| SCRIPT EQUAL String { ExtensionComponents.Script $3 }
ExtensionDefaults:
| DEFAULTS EQUAL ExprMap { ExtensionComponents.Defaults $3 }
| DEFAULTS LBRACE ExtensionDefaultsComponents RBRACE { ExtensionComponents.Defaults $3 }
ExtensionDefaultsComponents:
| /* empty */ { [] }
| ExtensionDefaultsComponents ExtensionDefaultsComponentsVariable { $1 @ [$2] }
ExtensionDefaultsComponentsVariable:
| IDENTIFIER EQUAL Expr { ($1, $3) }



Expr:
/* structures */
Expand Down
4 changes: 2 additions & 2 deletions src/Terrabuild/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ project @dotnet {
}

extension @docker {
defaults = {
image: "ghcr.io/magnusopera/terrabuild"
defaults {
`image` = "ghcr.io/magnusopera/terrabuild"
}
}

Expand Down
8 changes: 4 additions & 4 deletions tests/simple/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ target deploy {
extension @dotnet {
container = "mcr.microsoft.com/dotnet/sdk:9.0.202"
platform = "linux/amd64"
defaults = {
configuration: $configuration
defaults {
`configuration` = $configuration
}
}

extension @terraform {
container = "hashicorp/terraform:1.10"
platform = "linux/amd64"
defaults = {
workspace: $workspace
defaults {
`workspace` = $workspace
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/simple/projects/dotnet-app/PROJECT
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

extension @docker {
defaults = {
image: "ghcr.io/magnusopera/dotnet-app"
arguments: { configuration: $configuration }
defaults {
`image` = "ghcr.io/magnusopera/dotnet-app"
arguments = { configuration: $configuration }
}
}

Expand Down