File tree Expand file tree Collapse file tree 11 files changed +147
-1
lines changed Expand file tree Collapse file tree 11 files changed +147
-1
lines changed Original file line number Diff line number Diff line change 1717 - uses : dhall-lang/setup-dhall@v4
1818 - run : dhall text --file examples/single-job.dhall
1919 - run : dhall text --file examples/multiple-jobs.dhall
20+ - run : dhall text --file examples/inehrit-examples.dhall
Original file line number Diff line number Diff line change 1+ -- Several fields either allow you to set a global default (true/false)
2+ -- or a list of keywords (such as variable names). So we define `Choice`
3+ -- to represent those fields.
4+ let Choice = < Defaults : Bool | Keywords : List Text >
5+
6+ -- Implements the `inherit` keyword provided for jobs (https://docs.gitlab.com/ee/ci/yaml/index.html#inherit)
7+
8+ let Inherit = {
9+ `default` : Optional Choice ,
10+ variables: Optional Choice
11+ }
12+
13+ in { Inherit , Choice }
Original file line number Diff line number Diff line change 1+ let Types = ./ Type. dhall
2+
3+ in { Type = Types. Inherit
4+ , Choice = Types. Choice
5+ , default = None Types. Inherit
6+ , toJSON = ./ toJSON. dhall
7+ }
Original file line number Diff line number Diff line change 1+ let Prelude = ../ Prelude. dhall
2+
3+ let Optional / map = Prelude.Optional. map
4+
5+ let Map = Prelude. Map
6+
7+ let JSON = Prelude. JSON
8+
9+ let dropNones = ../ utils/ dropNones. dhall
10+
11+ let Types = ./ Type. dhall
12+
13+ let choiceToJSON = λ(choice : Types. Choice ) → merge {
14+ Defaults = λ(b : Bool ) → JSON. bool b,
15+ Keywords = λ(ks : List Text ) -> JSON. array
16+ ( Prelude.List. map
17+ Text
18+ JSON. Type
19+ JSON. string
20+ ks
21+ )
22+ } choice
23+
24+ let Inherit / toJSON : Types. Inherit → JSON. Type = λ(inherit : Types. Inherit ) →
25+ let everything = toMap {
26+ `default` = Optional / map Types. Choice JSON. Type choiceToJSON inherit. `default` ,
27+ variables = Optional / map Types. Choice JSON. Type choiceToJSON inherit. variables
28+ }
29+
30+ in JSON. object (dropNones Text JSON. Type everything)
31+
32+ in Inherit / toJSON
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ let Rule = ../Rule/Type.dhall
1616
1717let Trigger = ../ Trigger / Type. dhall
1818
19+ let Inherit = ../ Inherit / package. dhall
20+
1921in { stage : Optional Text
2022 , image : Optional Image
2123 , variables : Prelude.Map. Type Text Text
@@ -35,4 +37,5 @@ in { stage : Optional Text
3537 , trigger : Optional Trigger
3638 , timeout : Optional Text
3739 , extends : List Text
40+ , inherit : Optional Inherit. Type
3841 }
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ let Rule = ../Rule/package.dhall
1919
2020let Trigger = ../ Trigger / package. dhall
2121
22+ let Inherit = ../ Inherit / package. dhall
23+
2224let mergeOptional = ../ utils/ mergeOptional. dhall
2325
2426let mergeOptionalRight = ../ utils/ mergeOptionalRight. dhall
@@ -60,6 +62,7 @@ let append
6062 mergeOptional Trigger. Type Trigger. append a. trigger b. trigger
6163 , timeout = mergeOptionalRight Text a. timeout b. timeout
6264 , extends = a. extends # b. extends
65+ , inherit = mergeOptionalRight Inherit. Type a. inherit b. inherit
6366 }
6467
6568in append
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ let Environment = ../Environment/Type.dhall
1616
1717let Trigger = ../ Trigger / Type. dhall
1818
19+ let Inherit = ../ Inherit / package. dhall
20+
1921in { stage = None Text
2022 , image = None Image
2123 , variables = Prelude.Map. empty Text Text
@@ -35,5 +37,6 @@ in { stage = None Text
3537 , trigger = None Trigger
3638 , timeout = None Text
3739 , extends = [] : List Text
40+ , inherit = None Inherit. Type
3841 }
3942 : ./ Type. dhall
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ let Optional/map = Prelude.Optional.map
3232
3333let Optional / toList = Prelude.Optional. toList
3434
35+ let Inherit = ../ Inherit / package. dhall
36+
37+ let Inherit / toJSON = Inherit. toJSON
38+
3539in let Job / toJSON
3640 : Job → JSON. Type
3741 = λ(job : Job ) →
@@ -155,6 +159,8 @@ in let Job/toJSON
155159 job. extends
156160 )
157161 )
162+ , inherit =
163+ Optional / map Inherit. Type JSON. Type Inherit / toJSON job. inherit
158164 }
159165
160166 in JSON. object (dropNones Text JSON. Type everything)
Original file line number Diff line number Diff line change 1717, Defaults = ./ Defaults / package. dhall
1818, Service = ./ Service / package. dhall
1919, CachePolicy = ./ CachePolicy / package. dhall
20+ , Inherit = ./ Inherit / package. dhall
2021}
Original file line number Diff line number Diff line change 2121-}
2222
2323 env: DHALL_PRELUDE
24- ? https:// raw. githubusercontent. com/ dhall- lang/ dhall- lang/ v17. 0.0 / Prelude / package. dhall sha256: 0 c04cbe34f1f2d408e8c8b8cb0aa3ff4d5656336910f7e86190a6d14326f966d
24+ ? https:// raw. githubusercontent. com/ dhall- lang/ dhall- lang/ v17. 0.0 / Prelude / package. dhall sha256: 10 db3c919c25e9046833df897a8ffe2701dc390fa0893d958c3430524be5a43e
2525? https:// raw. githubusercontent. com/ dhall- lang/ dhall- lang/ v17. 0.0 / Prelude / package. dhall
You can’t perform that action at this time.
0 commit comments