-
Notifications
You must be signed in to change notification settings - Fork 12
pipelineymlgen: make inlinerange more consistent and usable #462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dagood
wants to merge
5
commits into
main
Choose a base branch
from
dev/dagood/inlinerange
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
66b2b27
pipelineymlgen: make inlinerange more consistent and usable
dagood f5160ad
Check inlinerange type consistency; fix empty map handling
dagood 4673d76
"list" -> "collection" in readme
dagood 0c66f7e
Test that two inlinerange in a mapping both contribute
dagood 44b0ac9
Fix evalRange to return nil for empty collection instead of mapping node
dagood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
3 changes: 3 additions & 0 deletions
3
internal/pipelineymlgen/testdata/TestIndividualFileErrors/inline-seq-into-map.gen.yml
This file contains hidden or 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,3 @@ | ||
| title: example | ||
| ${ inlinerange (list 1) }: | ||
| - ${ . } |
2 changes: 2 additions & 0 deletions
2
internal/pipelineymlgen/testdata/TestIndividualFileErrors/inline-seq-into-map.golden.txt
This file contains hidden or 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,2 @@ | ||
| failed to evaluate `testdata/TestIndividualFileErrors/inline-seq-into-map.gen.yml` content (with config): | ||
| eval "Document" at testdata/TestIndividualFileErrors/inline-seq-into-map.gen.yml:1:1 failed: converting doc content result to YAML node: during final conversion of mapping to YAML node(s): mapping contains multiple kinds: had Mapping, now also Sequence |
3 changes: 3 additions & 0 deletions
3
internal/pipelineymlgen/testdata/TestIndividualFileErrors/inline-value-into-map.gen.yml
This file contains hidden or 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,3 @@ | ||
| title: example | ||
| ${ inlinerange (list 1) }: | ||
| ${ . } |
2 changes: 2 additions & 0 deletions
2
internal/pipelineymlgen/testdata/TestIndividualFileErrors/inline-value-into-map.golden.txt
This file contains hidden or 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,2 @@ | ||
| failed to evaluate `testdata/TestIndividualFileErrors/inline-value-into-map.gen.yml` content (with config): | ||
| eval "Document" at testdata/TestIndividualFileErrors/inline-value-into-map.gen.yml:1:1 failed: converting doc content result to YAML node: during final conversion of mapping to YAML node(s): converting mapping item result to YAML node: inlinerange iteration 0: inlinerange body evaluated to scalar "1"; use "- value" for sequence items or "key: value" for mapping entries |
3 changes: 3 additions & 0 deletions
3
internal/pipelineymlgen/testdata/TestIndividualFileErrors/inline-value-into-seq.gen.yml
This file contains hidden or 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,3 @@ | ||
| - example | ||
| - ${ inlinerange (list 1) }: | ||
| ${ . } |
3 changes: 3 additions & 0 deletions
3
internal/pipelineymlgen/testdata/TestIndividualFileErrors/inline-value-into-seq.golden.txt
This file contains hidden or 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,3 @@ | ||
| failed to evaluate `testdata/TestIndividualFileErrors/inline-value-into-seq.gen.yml` content (with config): | ||
| eval "Document" at testdata/TestIndividualFileErrors/inline-value-into-seq.gen.yml:1:1 failed: converting doc content result to YAML node: during final conversion of sequence to YAML node(s): converting sequence item result to YAML node: | ||
| during final conversion of mapping to YAML node(s): converting mapping item result to YAML node: inlinerange iteration 0: inlinerange body evaluated to scalar "1"; use "- value" for sequence items or "key: value" for mapping entries |
5 changes: 5 additions & 0 deletions
5
internal/pipelineymlgen/testdata/TestIndividualFileErrors/inlinerange-mixed-kinds.gen.yml
This file contains hidden or 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,5 @@ | ||
| - ${ inlinerange (list "a" "b") }: | ||
| ${ inlineif (eq . "a") }: | ||
| key: value | ||
| ${ inlineelse }: | ||
| - item |
3 changes: 3 additions & 0 deletions
3
internal/pipelineymlgen/testdata/TestIndividualFileErrors/inlinerange-mixed-kinds.golden.txt
This file contains hidden or 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,3 @@ | ||
| failed to evaluate `testdata/TestIndividualFileErrors/inlinerange-mixed-kinds.gen.yml` content (with config): | ||
| eval "Document" at testdata/TestIndividualFileErrors/inlinerange-mixed-kinds.gen.yml:1:1 failed: converting doc content result to YAML node: during final conversion of sequence to YAML node(s): converting sequence item result to YAML node: | ||
| during final conversion of mapping to YAML node(s): converting mapping item result to YAML node: inlinerange: body produced inconsistent YAML node kinds across iterations: first was Mapping, got Sequence |
6 changes: 6 additions & 0 deletions
6
internal/pipelineymlgen/testdata/TestIndividualFiles/empty-map-in-seq.gen.yml
This file contains hidden or 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 @@ | ||
| # Verify that legitimate empty mappings in sequences are preserved, | ||
| # not dropped by the dissolved-content logic. | ||
| items: | ||
| - name: first | ||
| - {} | ||
| - name: third |
6 changes: 6 additions & 0 deletions
6
internal/pipelineymlgen/testdata/TestIndividualFiles/empty-map-in-seq.golden.yml
This file contains hidden or 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 @@ | ||
| # Verify that legitimate empty mappings in sequences are preserved, | ||
| # not dropped by the dissolved-content logic. | ||
| items: | ||
| - name: first | ||
| - {} | ||
| - name: third |
2 changes: 2 additions & 0 deletions
2
internal/pipelineymlgen/testdata/TestIndividualFiles/inlinerange-1arg-map.gen.yml
This file contains hidden or 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,2 @@ | ||
| - ${ inlinerange (dict "x" 1 "y" 2) }: | ||
| - ${ . } |
2 changes: 2 additions & 0 deletions
2
internal/pipelineymlgen/testdata/TestIndividualFiles/inlinerange-1arg-map.golden.yml
This file contains hidden or 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,2 @@ | ||
| - "1" | ||
| - "2" |
2 changes: 2 additions & 0 deletions
2
internal/pipelineymlgen/testdata/TestIndividualFiles/inlinerange-1arg.gen.yml
This file contains hidden or 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,2 @@ | ||
| - ${ inlinerange (list 1 2) }: | ||
| - value: ${ . } |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...tIndividualFiles/inlinerange-list.gen.yml → ...tIndividualFiles/inlinerange-2arg.gen.yml
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| # Range over a list with a value name. | ||
| - ${ inlinerange "v" (list "a" "b" "c") }: | ||
| ${ .v } | ||
| - ${ .v } |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...stIndividualFiles/inlinerange-map.gen.yml → ...tIndividualFiles/inlinerange-3arg.gen.yml
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| # Range over a dict with key and value names. | ||
| - ${ inlinerange "k" "v" (dict "x" 1 "y" 2) }: | ||
| ${ .k }: ${ yml .v } | ||
| - ${ .k }: ${ yml .v } |
File renamed without changes.
54 changes: 54 additions & 0 deletions
54
internal/pipelineymlgen/testdata/TestIndividualFiles/inlinerange-examples.gen.yml
This file contains hidden or 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,54 @@ | ||
| # Test and demonstration of how inlinerange can be used to generate any seq/map | ||
| # structure despite always attempting to inline the result. | ||
|
|
||
| # Baseline: inlinerange inserts key value pairs into a map. | ||
| insertMap: | ||
| name: Geomys bursarius | ||
| ${ inlinerange "k" "v" (dict "family" "Geomyidae" "status" "least concern") }: | ||
| ${ .k }: ${ .v } | ||
| # inlinerange also inserts items into an otherwise-empty map. | ||
| properties: | ||
| ${ inlinerange "k" "v" (dict "diet" "herbivore" "tunnel" "2059cm/wk") }: | ||
| ${ .k }: ${ .v } | ||
|
|
||
| # inlinerange can insert items into a sequence. | ||
| insertSeq: | ||
| - 1 | ||
| - ${ inlinerange (list 2 3 4) }: | ||
| - ${ yml . } | ||
|
|
||
| # More than one element per iteration can be inserted. | ||
| insertSeqGaps: | ||
| - 1 | ||
| - ${ inlinerange (list 2 3 4) }: | ||
| - gap | ||
| - ${ yml . } | ||
|
|
||
| # It can produce a sequence of sequences by explicitly including an extra dash. | ||
| # The dash forms an otherwise-empty sequence for inlinerange to insert into. | ||
| insertSeqOfSeq: | ||
| - initialize | ||
| - - ${ inlinerange (list "parallel-calculate" "parallel-telemetry") }: | ||
| - ${ yml . } | ||
|
|
||
| # If the child element is a map and the target is a sequence, the map as a whole | ||
| # is inserted as a single element in the sequence. | ||
| insertMapElementIntoSeq: | ||
| - 1 | ||
| - ${ inlinerange (list 2 3 4) }: | ||
| ${ yml . }: present | ||
|
|
||
| # If the child element is a sequence and the target is a map, this is an error: | ||
| # | ||
| # insertSeqElementIntoMap: | ||
| # begin: 1 | ||
| # next: | ||
| # ${ inlinerange (list 2 3 4) }: | ||
| # - ${ yml . } | ||
| # | ||
| # The intent was probably to include a "-" to insert elements into a sequence: | ||
| insertSeqElementIntoMap: | ||
| begin: 1 | ||
| next: | ||
| - ${ inlinerange (list 2 3 4) }: | ||
| - ${ yml . } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.