-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Support using YAML's anchors and aliases in runbooks #722
Support using YAML's anchors and aliases in runbooks #722
Conversation
19949dc
to
acd345e
Compare
@h6ah4i Thank you for your GREAT WORK!! That is a very powerful feature. And since it is a YAML feature, it is good that it does not affect the runn features. By the way, can you think of any disadvantages of implementing this powerful feature? @k2tzumi I would like to hear your opinion too! |
I think anchors and aliases are basic YAML feature and it's natural that we can use them. However, in terms of the implementation it depends on goccy/go-yaml heavily and it may introduce some incompatibilities that the current test code does not cover. |
@h6ah4i There was a time when I too was wondering why docker-compose has an anchor function and GitHub Actions does not. I have not checked the behavior with the improved content, but if an error occurs in a step expanded by this anchor function, how will the error content be displayed? If it is a configuration file, the Anchor function works very well, but when describing a flow like Github Actions, I think it is also important to be able to easily understand the step when an error is displayed. |
acd345e
to
ee1c804
Compare
Adding |
ee1c804
to
6edf31d
Compare
6edf31d
to
71b1d0a
Compare
71b1d0a
to
d0ca454
Compare
Thank you for your advice. I have added more test patterns to the For your reference, here is the example runn command output for error steps using aliases. ❯ go run cmd/runn/main.go run ./testdata/book/yaml_anchor_alias_always_failure.yml
F
1) ./testdata/book/yaml_anchor_alias_always_failure.yml b1497eb73af72ed261ca8858c6566a4646b8ec74
Failure/Error: test failed on "YAML's anchor & alias check".steps.check_1 "with anchor & alias": condition is not true
Condition:
compare(vars.my_hash_anchor_merged, {a: 1, b: 2, c: 3, d: 100})
│
├── compare(vars["my_hash_anchor_merged"], {a: 1, b: 2, c: 3, d: 100}) => false
├── vars["my_hash_anchor_merged"] => {"a":1,"b":2,"c":3,"d":4}
└── {a: 1, b: 2, c: 3, d: 100} => {"a":1,"b":2,"c":3,"d":100}
Failure step (./testdata/book/yaml_anchor_alias_always_failure.yml):
24 check_1:
25 desc: 'with anchor & alias'
26 test: |
27 compare(vars.my_hash_anchor_merged, {a: 1, b: 2, c: 3, d: 100})
28
2) ./testdata/book/yaml_anchor_alias_always_failure.yml b1497eb73af72ed261ca8858c6566a4646b8ec74
Failure/Error: test failed on "YAML's anchor & alias check".steps.check_2 "merging in HTTP header part": condition is not true
Condition:
current.res.status != 418
│
├── current.res.status => 418
└── 418 => 418
Failure step (./testdata/book/yaml_anchor_alias_always_failure.yml):
29 check_2:
30 desc: 'merging in HTTP header part'
31 httpbin:
32 /status/418:
33 get:
34 headers:
35 <<: *common_req_headers
36 test:
37 current.res.status != 418
1 scenario, 0 skipped, 1 failure
exit status 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks GREAT To Me!!!
We have checked the output content in the event of an error.
Although this is an extreme case, I thought it would be good to be able to identify the error even with this content 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thank you so much for accepting my proposal🙌 |
This pull request introduces YAML's anchors & aliases support in runbooks.
example
The aliases are very useful if you want to re-use same fields multiple times.
FYI: This PR is the 4th one that I implemented yesterday.
https://github.com/h6ah4i/runn/tree/feature/add-built-in-function-pick(Thx, already merged 🙏)https://github.com/h6ah4i/runn/tree/feature/add-built-in-function-omit(Thx, already merged 🙏)https://github.com/h6ah4i/runn/tree/feature/add-built-in-function-merge(Thx, already merged 🙏)