forked from dhall-lang/dhall-haskell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for explicit splitting of definitions
The motivation behind this is better user experience when dealing with Kubernetes CRDs. CRDs in an openapi definition are expressed as one massive definition rather than the Kubernetes builtin types which rarely nest and instead make use of references within openapi. These references are desirable as it makes it more manageable to sparsely define resources utilizing the nested defaults as you go down the structure. Unfortunately it looks like support for references wrt CRDs is unlikely to be supported in the near future: kubernetes/kubernetes#62872 As a workaround, this adds a new option `--splitPaths` that takes a path and an optional new model name. The path roughly emulates the idea behind `kubectl explain` but I ended up using the `~` character instead of `.` such that the full parent model name could still be used without ambiguities. During type conversion any matches of path will cause a Dhall reference to be injected with the nested definition being pushed back on the stack of definitions to convert. The top level model name can either be specified on the command line via `=com.some.ModelName` or be guessed in the case the CRD author follows the best practice of using the field name as the first word in the description. Some future work that might need exploring related to this are: 1. Allow specifying `splitPaths` from a file 2. Clean up which types get accumulated into the `typesUnion`. I noticed while doing this that all? top level definitions are being dumped into this union where really it should only be top level definitions that have an `apiVersion` and `kind` 3. See if the `mergeNoConflicts` function needs to be improved such that it takes semantic equality (traversing imports) into account.
- Loading branch information
Showing
3 changed files
with
164 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters