mirror of
https://github.com/dhall-lang/dhall-kubernetes.git
synced 2024-08-15 00:40:41 +03:00
Fixes https://github.com/dhall-lang/dhall-kubernetes/issues/191 … by no longer mistakenly preferring `v1` or `v2beta{1,2}` over all other versions
87 lines
2.5 KiB
Plaintext
87 lines
2.5 KiB
Plaintext
let Prelude =
|
|
../Prelude.dhall
|
|
sha256:10db3c919c25e9046833df897a8ffe2701dc390fa0893d958c3430524be5a43e
|
|
|
|
let map = Prelude.List.map
|
|
|
|
let kubernetes =
|
|
../package.dhall
|
|
sha256:263ee915ef545f2d771fdcd5cfa4fbb7f62772a861b5c197f998e5b71219112c
|
|
|
|
let Service = { name : Text, host : Text, version : Text }
|
|
|
|
let services = [ { name = "foo", host = "foo.example.com", version = "2.3" } ]
|
|
|
|
let makeTLS
|
|
: Service → kubernetes.IngressTLS.Type
|
|
= λ(service : Service) →
|
|
{ hosts = Some [ service.host ]
|
|
, secretName = Some "${service.name}-certificate"
|
|
}
|
|
|
|
let makeRule
|
|
: Service → kubernetes.IngressRule.Type
|
|
= λ(service : Service) →
|
|
{ host = Some service.host
|
|
, http = Some
|
|
{ paths =
|
|
[ kubernetes.HTTPIngressPath::{
|
|
, backend = kubernetes.IngressBackend::{
|
|
, service = Some kubernetes.IngressServiceBackend::{
|
|
, name = service.name
|
|
, port = Some kubernetes.ServiceBackendPort::{
|
|
, number = Some 80
|
|
}
|
|
}
|
|
}
|
|
, pathType = "Exact"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
|
|
let mkIngress
|
|
: List Service → kubernetes.Ingress.Type
|
|
= λ(inputServices : List Service) →
|
|
let annotations =
|
|
toMap
|
|
{ `kubernetes.io/ingress.class` = "nginx"
|
|
, `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 = Some
|
|
( map
|
|
Service
|
|
kubernetes.IngressTLS.Type
|
|
makeTLS
|
|
ingressServices
|
|
)
|
|
, rules = Some
|
|
( map
|
|
Service
|
|
kubernetes.IngressRule.Type
|
|
makeRule
|
|
ingressServices
|
|
)
|
|
}
|
|
|
|
in kubernetes.Ingress::{
|
|
, metadata = kubernetes.ObjectMeta::{
|
|
, name = Some "nginx"
|
|
, annotations = Some annotations
|
|
}
|
|
, spec = Some spec
|
|
}
|
|
|
|
in mkIngress services
|