-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import YAML files containing multiple documents as arrays
For example, in Kubernetes deployments it is common practice to package multiple YAML documents into a single file. For processing such files with Nickel we need to support importing multiple YAML documents from a single file. The concern with this is: how does such a file fit into Nickel's data model? Importing it as an array of Nickel values felt most reasonable to me. At the same time, a YAML file containing a single document should still be transparently serialized as that document, not as a single element array.
- Loading branch information
Showing
5 changed files
with
56 additions
and
3 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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
type: event | ||
id: 1 | ||
--- | ||
type: event | ||
id: 2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# test.type = 'pass' | ||
|
||
let {check, ..} = import "../pass/lib/assert.ncl" in | ||
[ | ||
(import "imported/empty.yaml") == null, | ||
|
||
(import "imported/multiple.yaml") == [ | ||
{ type = "event", id = 1 }, | ||
{ type = "event", id = 2 } | ||
], | ||
] | ||
|> check |
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