Skip to content

Commit

Permalink
Fix README.md.dhall
Browse files Browse the repository at this point in the history
… to match the changes made to `README.md` in #183
  • Loading branch information
Gabriella439 committed Aug 25, 2022
1 parent ece5035 commit a958c95
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions docs/README.md.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -117,33 +117,29 @@ ${../examples/out/ingress.yaml as Text}

#### Can I generate a YAML file with many objects in it?

It is usual for k8s YAML files to include multiple objects separated by `---` ("documents" in YAML lingo),
so you might want to do it too.
Kubernetes YAML files commonly include multiple resources as documents separated
by `---`. To generate a single file with a different resource type per
document, you'll need to produce a `List Resource` (where `Resource` is a
union provided by `dhall-kubernetes` that can wrap any resource type), like
this:

If the objects have the same type, this is very easy: you return a Dhall list containing the
objects, and use the `--documents` flag, e.g.:

```bash
dhall-to-yaml --documents <<< "let a = ./examples/deploymentSimple.dhall in [a, a]"
```dhall
let k8s = ./package.dhall

in [ k8s.Resource.Deployment k8s.Deployment::{
,
}
, k8s.Resource.Service k8s.Service::{
,
}
]
```

If the objects are of different type, it's not possible to have separate documents in the same YAML file.
However, since [k8s has a builtin `List` type for these cases](https://github.com/kubernetes/kubernetes/blob/master/hack/testdata/list.yaml),
it's possible to use it together with the [union type of all k8s types that we generate][typesUnion].
and then render the `List` of `Resource`s using the `--documents` flag, like
this:

So if we want to deploy e.g. a Deployment and a Service together, we can do:

```dhall
let k8s = ./typesUnion.dhall

in
{ apiVersion = "v1"
, kind = "List"
, items =
[ k8s.Deployment ./my-deployment.dhall
, k8s.Service ./my-service.dhall
]
}
```bash
dhall-to-yaml --documents --file ./resources.dhall
```

## Projects Using `dhall-kubernetes`
Expand Down

0 comments on commit a958c95

Please sign in to comment.