dhall-kubernetes/examples/ingress.dhall

73 lines
2.0 KiB
Plaintext
Raw Normal View History

API v2 (#57) This ports the conversion script from Python to Haskell (fix #7) The main reasons for this port are that: - the Python script was really hard to maintain for reasons like "converting from Swagger to Dhall is interleaved with string formatting" - in Haskell we can use the dhall library to generate always syntactically correct Dhall AST. It's also much easier to keep an eye on correctness, because types and pattern matching. It also forces us to deal with things like cyclic imports from the get go. Things happening here: - remove the `api` folder, removing the difference between "raw api" and "nice api" - move defaults from `default` to `defaults` folder, as it is in `dhall-nethack` - transition to the new syntax for `Optional` (fix #49) - add `types.dhall` and `defaults.dhall`, so that one can now easily "pin a version" by just importing these two records at a specific commit/tag. They also make it really easy to access objects, e.g. `let types = https://raw.githubusercontent... sha256:... in types.Deployment` - also add typesUnion.dhall (fix #54), so one is able to send to Kubernetes different objects in the same stream. This is also documented in the README - defaults are resolved recursively (fix #46): if there's an import of a "nullable" record, then it's not marked as Optional, making merging objects much easier - default objects are not lambdas anymore, and instead they just don't include the required fields (that is, the ones that are not nullable records), as suggested in dhall-lang/dhall-lang#382 - for objects that are simple types we used to generate a simple lambda `\(a : Text) -> a` as a default, now we just don't generate a default (e.g. see `io.k8s.apimachinery.pkg.apis.meta.v1.Time`) - autoformat all generated Dhall code - remove cyclic imports (fix #47) - update to dhall-1.22 and dhall-json-1.2.8
2019-05-01 19:13:18 +03:00
let Prelude = ../Prelude.dhall
let map = Prelude.List.map
API v2 (#57) This ports the conversion script from Python to Haskell (fix #7) The main reasons for this port are that: - the Python script was really hard to maintain for reasons like "converting from Swagger to Dhall is interleaved with string formatting" - in Haskell we can use the dhall library to generate always syntactically correct Dhall AST. It's also much easier to keep an eye on correctness, because types and pattern matching. It also forces us to deal with things like cyclic imports from the get go. Things happening here: - remove the `api` folder, removing the difference between "raw api" and "nice api" - move defaults from `default` to `defaults` folder, as it is in `dhall-nethack` - transition to the new syntax for `Optional` (fix #49) - add `types.dhall` and `defaults.dhall`, so that one can now easily "pin a version" by just importing these two records at a specific commit/tag. They also make it really easy to access objects, e.g. `let types = https://raw.githubusercontent... sha256:... in types.Deployment` - also add typesUnion.dhall (fix #54), so one is able to send to Kubernetes different objects in the same stream. This is also documented in the README - defaults are resolved recursively (fix #46): if there's an import of a "nullable" record, then it's not marked as Optional, making merging objects much easier - default objects are not lambdas anymore, and instead they just don't include the required fields (that is, the ones that are not nullable records), as suggested in dhall-lang/dhall-lang#382 - for objects that are simple types we used to generate a simple lambda `\(a : Text) -> a` as a default, now we just don't generate a default (e.g. see `io.k8s.apimachinery.pkg.apis.meta.v1.Time`) - autoformat all generated Dhall code - remove cyclic imports (fix #47) - update to dhall-1.22 and dhall-json-1.2.8
2019-05-01 19:13:18 +03:00
let kv = Prelude.JSON.keyText
let types =
2019-07-30 10:25:00 +03:00
../types.dhall sha256:e48e21b807dad217a6c3e631fcaf3e950062310bfb4a8bbcecc330eb7b2f60ed
API v2 (#57) This ports the conversion script from Python to Haskell (fix #7) The main reasons for this port are that: - the Python script was really hard to maintain for reasons like "converting from Swagger to Dhall is interleaved with string formatting" - in Haskell we can use the dhall library to generate always syntactically correct Dhall AST. It's also much easier to keep an eye on correctness, because types and pattern matching. It also forces us to deal with things like cyclic imports from the get go. Things happening here: - remove the `api` folder, removing the difference between "raw api" and "nice api" - move defaults from `default` to `defaults` folder, as it is in `dhall-nethack` - transition to the new syntax for `Optional` (fix #49) - add `types.dhall` and `defaults.dhall`, so that one can now easily "pin a version" by just importing these two records at a specific commit/tag. They also make it really easy to access objects, e.g. `let types = https://raw.githubusercontent... sha256:... in types.Deployment` - also add typesUnion.dhall (fix #54), so one is able to send to Kubernetes different objects in the same stream. This is also documented in the README - defaults are resolved recursively (fix #46): if there's an import of a "nullable" record, then it's not marked as Optional, making merging objects much easier - default objects are not lambdas anymore, and instead they just don't include the required fields (that is, the ones that are not nullable records), as suggested in dhall-lang/dhall-lang#382 - for objects that are simple types we used to generate a simple lambda `\(a : Text) -> a` as a default, now we just don't generate a default (e.g. see `io.k8s.apimachinery.pkg.apis.meta.v1.Time`) - autoformat all generated Dhall code - remove cyclic imports (fix #47) - update to dhall-1.22 and dhall-json-1.2.8
2019-05-01 19:13:18 +03:00
let kubernetes =
../schemas.dhall sha256:9704063d1e2d17050cb18afae199a24f4cd1264e6c8e696ca94781309e213785
API v2 (#57) This ports the conversion script from Python to Haskell (fix #7) The main reasons for this port are that: - the Python script was really hard to maintain for reasons like "converting from Swagger to Dhall is interleaved with string formatting" - in Haskell we can use the dhall library to generate always syntactically correct Dhall AST. It's also much easier to keep an eye on correctness, because types and pattern matching. It also forces us to deal with things like cyclic imports from the get go. Things happening here: - remove the `api` folder, removing the difference between "raw api" and "nice api" - move defaults from `default` to `defaults` folder, as it is in `dhall-nethack` - transition to the new syntax for `Optional` (fix #49) - add `types.dhall` and `defaults.dhall`, so that one can now easily "pin a version" by just importing these two records at a specific commit/tag. They also make it really easy to access objects, e.g. `let types = https://raw.githubusercontent... sha256:... in types.Deployment` - also add typesUnion.dhall (fix #54), so one is able to send to Kubernetes different objects in the same stream. This is also documented in the README - defaults are resolved recursively (fix #46): if there's an import of a "nullable" record, then it's not marked as Optional, making merging objects much easier - default objects are not lambdas anymore, and instead they just don't include the required fields (that is, the ones that are not nullable records), as suggested in dhall-lang/dhall-lang#382 - for objects that are simple types we used to generate a simple lambda `\(a : Text) -> a` as a default, now we just don't generate a default (e.g. see `io.k8s.apimachinery.pkg.apis.meta.v1.Time`) - autoformat all generated Dhall code - remove cyclic imports (fix #47) - update to dhall-1.22 and dhall-json-1.2.8
2019-05-01 19:13:18 +03:00
let Service = { name : Text, host : Text, version : Text }
let services = [ { name = "foo", host = "foo.example.com", version = "2.3" } ]
let makeTLS
: Service → types.IngressTLS
= λ(service : Service)
→ { hosts = [ service.host ]
, secretName = Some "${service.name}-certificate"
}
API v2 (#57) This ports the conversion script from Python to Haskell (fix #7) The main reasons for this port are that: - the Python script was really hard to maintain for reasons like "converting from Swagger to Dhall is interleaved with string formatting" - in Haskell we can use the dhall library to generate always syntactically correct Dhall AST. It's also much easier to keep an eye on correctness, because types and pattern matching. It also forces us to deal with things like cyclic imports from the get go. Things happening here: - remove the `api` folder, removing the difference between "raw api" and "nice api" - move defaults from `default` to `defaults` folder, as it is in `dhall-nethack` - transition to the new syntax for `Optional` (fix #49) - add `types.dhall` and `defaults.dhall`, so that one can now easily "pin a version" by just importing these two records at a specific commit/tag. They also make it really easy to access objects, e.g. `let types = https://raw.githubusercontent... sha256:... in types.Deployment` - also add typesUnion.dhall (fix #54), so one is able to send to Kubernetes different objects in the same stream. This is also documented in the README - defaults are resolved recursively (fix #46): if there's an import of a "nullable" record, then it's not marked as Optional, making merging objects much easier - default objects are not lambdas anymore, and instead they just don't include the required fields (that is, the ones that are not nullable records), as suggested in dhall-lang/dhall-lang#382 - for objects that are simple types we used to generate a simple lambda `\(a : Text) -> a` as a default, now we just don't generate a default (e.g. see `io.k8s.apimachinery.pkg.apis.meta.v1.Time`) - autoformat all generated Dhall code - remove cyclic imports (fix #47) - update to dhall-1.22 and dhall-json-1.2.8
2019-05-01 19:13:18 +03:00
let makeRule
: Service → types.IngressRule
= λ(service : Service)
→ { host = Some service.host
, http =
Some
API v2 (#57) This ports the conversion script from Python to Haskell (fix #7) The main reasons for this port are that: - the Python script was really hard to maintain for reasons like "converting from Swagger to Dhall is interleaved with string formatting" - in Haskell we can use the dhall library to generate always syntactically correct Dhall AST. It's also much easier to keep an eye on correctness, because types and pattern matching. It also forces us to deal with things like cyclic imports from the get go. Things happening here: - remove the `api` folder, removing the difference between "raw api" and "nice api" - move defaults from `default` to `defaults` folder, as it is in `dhall-nethack` - transition to the new syntax for `Optional` (fix #49) - add `types.dhall` and `defaults.dhall`, so that one can now easily "pin a version" by just importing these two records at a specific commit/tag. They also make it really easy to access objects, e.g. `let types = https://raw.githubusercontent... sha256:... in types.Deployment` - also add typesUnion.dhall (fix #54), so one is able to send to Kubernetes different objects in the same stream. This is also documented in the README - defaults are resolved recursively (fix #46): if there's an import of a "nullable" record, then it's not marked as Optional, making merging objects much easier - default objects are not lambdas anymore, and instead they just don't include the required fields (that is, the ones that are not nullable records), as suggested in dhall-lang/dhall-lang#382 - for objects that are simple types we used to generate a simple lambda `\(a : Text) -> a` as a default, now we just don't generate a default (e.g. see `io.k8s.apimachinery.pkg.apis.meta.v1.Time`) - autoformat all generated Dhall code - remove cyclic imports (fix #47) - update to dhall-1.22 and dhall-json-1.2.8
2019-05-01 19:13:18 +03:00
{ paths =
[ { backend =
{ serviceName = service.name
, servicePort = types.IntOrString.Int 80
API v2 (#57) This ports the conversion script from Python to Haskell (fix #7) The main reasons for this port are that: - the Python script was really hard to maintain for reasons like "converting from Swagger to Dhall is interleaved with string formatting" - in Haskell we can use the dhall library to generate always syntactically correct Dhall AST. It's also much easier to keep an eye on correctness, because types and pattern matching. It also forces us to deal with things like cyclic imports from the get go. Things happening here: - remove the `api` folder, removing the difference between "raw api" and "nice api" - move defaults from `default` to `defaults` folder, as it is in `dhall-nethack` - transition to the new syntax for `Optional` (fix #49) - add `types.dhall` and `defaults.dhall`, so that one can now easily "pin a version" by just importing these two records at a specific commit/tag. They also make it really easy to access objects, e.g. `let types = https://raw.githubusercontent... sha256:... in types.Deployment` - also add typesUnion.dhall (fix #54), so one is able to send to Kubernetes different objects in the same stream. This is also documented in the README - defaults are resolved recursively (fix #46): if there's an import of a "nullable" record, then it's not marked as Optional, making merging objects much easier - default objects are not lambdas anymore, and instead they just don't include the required fields (that is, the ones that are not nullable records), as suggested in dhall-lang/dhall-lang#382 - for objects that are simple types we used to generate a simple lambda `\(a : Text) -> a` as a default, now we just don't generate a default (e.g. see `io.k8s.apimachinery.pkg.apis.meta.v1.Time`) - autoformat all generated Dhall code - remove cyclic imports (fix #47) - update to dhall-1.22 and dhall-json-1.2.8
2019-05-01 19:13:18 +03:00
}
, path = None Text
API v2 (#57) This ports the conversion script from Python to Haskell (fix #7) The main reasons for this port are that: - the Python script was really hard to maintain for reasons like "converting from Swagger to Dhall is interleaved with string formatting" - in Haskell we can use the dhall library to generate always syntactically correct Dhall AST. It's also much easier to keep an eye on correctness, because types and pattern matching. It also forces us to deal with things like cyclic imports from the get go. Things happening here: - remove the `api` folder, removing the difference between "raw api" and "nice api" - move defaults from `default` to `defaults` folder, as it is in `dhall-nethack` - transition to the new syntax for `Optional` (fix #49) - add `types.dhall` and `defaults.dhall`, so that one can now easily "pin a version" by just importing these two records at a specific commit/tag. They also make it really easy to access objects, e.g. `let types = https://raw.githubusercontent... sha256:... in types.Deployment` - also add typesUnion.dhall (fix #54), so one is able to send to Kubernetes different objects in the same stream. This is also documented in the README - defaults are resolved recursively (fix #46): if there's an import of a "nullable" record, then it's not marked as Optional, making merging objects much easier - default objects are not lambdas anymore, and instead they just don't include the required fields (that is, the ones that are not nullable records), as suggested in dhall-lang/dhall-lang#382 - for objects that are simple types we used to generate a simple lambda `\(a : Text) -> a` as a default, now we just don't generate a default (e.g. see `io.k8s.apimachinery.pkg.apis.meta.v1.Time`) - autoformat all generated Dhall code - remove cyclic imports (fix #47) - update to dhall-1.22 and dhall-json-1.2.8
2019-05-01 19:13:18 +03:00
}
]
}
}
API v2 (#57) This ports the conversion script from Python to Haskell (fix #7) The main reasons for this port are that: - the Python script was really hard to maintain for reasons like "converting from Swagger to Dhall is interleaved with string formatting" - in Haskell we can use the dhall library to generate always syntactically correct Dhall AST. It's also much easier to keep an eye on correctness, because types and pattern matching. It also forces us to deal with things like cyclic imports from the get go. Things happening here: - remove the `api` folder, removing the difference between "raw api" and "nice api" - move defaults from `default` to `defaults` folder, as it is in `dhall-nethack` - transition to the new syntax for `Optional` (fix #49) - add `types.dhall` and `defaults.dhall`, so that one can now easily "pin a version" by just importing these two records at a specific commit/tag. They also make it really easy to access objects, e.g. `let types = https://raw.githubusercontent... sha256:... in types.Deployment` - also add typesUnion.dhall (fix #54), so one is able to send to Kubernetes different objects in the same stream. This is also documented in the README - defaults are resolved recursively (fix #46): if there's an import of a "nullable" record, then it's not marked as Optional, making merging objects much easier - default objects are not lambdas anymore, and instead they just don't include the required fields (that is, the ones that are not nullable records), as suggested in dhall-lang/dhall-lang#382 - for objects that are simple types we used to generate a simple lambda `\(a : Text) -> a` as a default, now we just don't generate a default (e.g. see `io.k8s.apimachinery.pkg.apis.meta.v1.Time`) - autoformat all generated Dhall code - remove cyclic imports (fix #47) - update to dhall-1.22 and dhall-json-1.2.8
2019-05-01 19:13:18 +03:00
let mkIngress
: List Service → types.Ingress
= λ(inputServices : List Service)
→ let annotations =
[ kv "kubernetes.io/ingress.class" "nginx"
, kv "kubernetes.io/ingress.allow-http" "false"
]
let defaultService =
{ name = "default"
, host = "default.example.com"
, version = " 1.0"
}
let ingressServices = inputServices # [ defaultService ]
let spec =
kubernetes.IngressSpec::{
, tls = map Service types.IngressTLS makeTLS ingressServices
, rules = map Service types.IngressRule makeRule ingressServices
}
in kubernetes.Ingress::{
, metadata =
kubernetes.ObjectMeta::{
, name = "nginx"
, annotations = annotations
API v2 (#57) This ports the conversion script from Python to Haskell (fix #7) The main reasons for this port are that: - the Python script was really hard to maintain for reasons like "converting from Swagger to Dhall is interleaved with string formatting" - in Haskell we can use the dhall library to generate always syntactically correct Dhall AST. It's also much easier to keep an eye on correctness, because types and pattern matching. It also forces us to deal with things like cyclic imports from the get go. Things happening here: - remove the `api` folder, removing the difference between "raw api" and "nice api" - move defaults from `default` to `defaults` folder, as it is in `dhall-nethack` - transition to the new syntax for `Optional` (fix #49) - add `types.dhall` and `defaults.dhall`, so that one can now easily "pin a version" by just importing these two records at a specific commit/tag. They also make it really easy to access objects, e.g. `let types = https://raw.githubusercontent... sha256:... in types.Deployment` - also add typesUnion.dhall (fix #54), so one is able to send to Kubernetes different objects in the same stream. This is also documented in the README - defaults are resolved recursively (fix #46): if there's an import of a "nullable" record, then it's not marked as Optional, making merging objects much easier - default objects are not lambdas anymore, and instead they just don't include the required fields (that is, the ones that are not nullable records), as suggested in dhall-lang/dhall-lang#382 - for objects that are simple types we used to generate a simple lambda `\(a : Text) -> a` as a default, now we just don't generate a default (e.g. see `io.k8s.apimachinery.pkg.apis.meta.v1.Time`) - autoformat all generated Dhall code - remove cyclic imports (fix #47) - update to dhall-1.22 and dhall-json-1.2.8
2019-05-01 19:13:18 +03:00
}
, spec = Some spec
}
API v2 (#57) This ports the conversion script from Python to Haskell (fix #7) The main reasons for this port are that: - the Python script was really hard to maintain for reasons like "converting from Swagger to Dhall is interleaved with string formatting" - in Haskell we can use the dhall library to generate always syntactically correct Dhall AST. It's also much easier to keep an eye on correctness, because types and pattern matching. It also forces us to deal with things like cyclic imports from the get go. Things happening here: - remove the `api` folder, removing the difference between "raw api" and "nice api" - move defaults from `default` to `defaults` folder, as it is in `dhall-nethack` - transition to the new syntax for `Optional` (fix #49) - add `types.dhall` and `defaults.dhall`, so that one can now easily "pin a version" by just importing these two records at a specific commit/tag. They also make it really easy to access objects, e.g. `let types = https://raw.githubusercontent... sha256:... in types.Deployment` - also add typesUnion.dhall (fix #54), so one is able to send to Kubernetes different objects in the same stream. This is also documented in the README - defaults are resolved recursively (fix #46): if there's an import of a "nullable" record, then it's not marked as Optional, making merging objects much easier - default objects are not lambdas anymore, and instead they just don't include the required fields (that is, the ones that are not nullable records), as suggested in dhall-lang/dhall-lang#382 - for objects that are simple types we used to generate a simple lambda `\(a : Text) -> a` as a default, now we just don't generate a default (e.g. see `io.k8s.apimachinery.pkg.apis.meta.v1.Time`) - autoformat all generated Dhall code - remove cyclic imports (fix #47) - update to dhall-1.22 and dhall-json-1.2.8
2019-05-01 19:13:18 +03:00
in mkIngress services