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: 4 additions & 0 deletions src/Terrabuild.Configuration.Tests/Project.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@ let parseProject() =

let extDotnet =
{ Container = None
Platform = None
Variables = Set.empty
Script = None
Defaults = Map [ "configuration", Expr.Variable "configuration" ] }
let extDocker =
{ Container = None
Platform = None
Variables = Set [ "ARM_TENANT_ID" ]
Script = None
Defaults = Map [ "configuration", Expr.Variable "configuration"
"image", Expr.String "ghcr.io/magnusopera/dotnet-app" ] }
let extDummy =
{ Container = None
Platform = None
Variables = Set.empty
Script = Some "dummy.fsx"
Defaults = Map.empty }
Expand Down Expand Up @@ -97,6 +100,7 @@ let parseProject2() =

let extDotnet =
{ Container = None
Platform = None
Variables = Set.empty
Script = None
Defaults = Map.empty }
Expand Down
5 changes: 5 additions & 0 deletions src/Terrabuild.Configuration.Tests/Workspace.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ let parseWorkspace() =

let extDotnet =
{ Container = Some (Expr.String "mcr.microsoft.com/dotnet/sdk:8.0.101")
Platform = None
Variables = Set.empty
Script = None
Defaults = Map [ "configuration", Expr.Variable "configuration" ] }
let extDocker =
{ Container = None
Platform = None
Variables = Set.empty
Script = None
Defaults = Map.empty }
let extNpm =
{ Container = Some (Expr.String "node:20")
Platform = None
Variables = Set.empty
Script = Some "scripts/npm.fsx"
Defaults = Map.empty }
Expand Down Expand Up @@ -107,13 +110,15 @@ let parseWorkspace2() =

let extDotnet =
{ Container = Some (Expr.String "mcr.microsoft.com/dotnet/sdk:8.0.101")
Platform = None
Variables = Set.empty
Script = None
Defaults = Map [ "configuration1", Expr.Function (Function.Item, [Expr.Variable "map"; Expr.String "toto"])
"configuration2", Expr.Function (Function.TryItem, [Expr.Variable "map"; Expr.String "titi"])
"configuration3", Expr.Function (Function.Replace, [Expr.String "toto titi"; Expr.String "toto"; Expr.String "titi"]) ] }
let extDocker =
{ Container = None
Platform = None
Variables = Set.empty
Script = None
Defaults = Map.empty }
Expand Down
9 changes: 9 additions & 0 deletions src/Terrabuild.Configuration/AST.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ open Errors
[<RequireQualifiedAccess>]
type ExtensionComponents =
| Container of Expr
| Platform of Expr
| Variables of string list
| Script of string
| Defaults of Map<string, Expr>

type Extension = {
Container: Expr option
Platform: Expr option
Variables: string Set
Script: string option
Defaults: Map<string, Expr>
Expand All @@ -23,6 +25,12 @@ with
| [value] -> Some value
| _ -> TerrabuildException.Raise("multiple container declared")

let platform =
match components |> List.choose (function | ExtensionComponents.Platform value -> Some value | _ -> None) with
| [] -> None
| [value] -> Some value
| _ -> TerrabuildException.Raise("multiple platform declared")

let variables =
match components |> List.choose (function | ExtensionComponents.Variables value -> Some value | _ -> None) with
| [] -> Set.empty
Expand All @@ -42,6 +50,7 @@ with
| _ -> TerrabuildException.Raise("multiple defaults declared")

name, { Container = container
Platform = platform
Variables = variables
Script = script
Defaults = defaults }
Expand Down
417 changes: 218 additions & 199 deletions src/Terrabuild.Configuration/Gen/ProjectLexer.fs

Large diffs are not rendered by default.

Loading