Skip to content
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

feat(yaml): add advanced yamlpath support #1741

Merged
merged 11 commits into from
Nov 7, 2023

Conversation

olblak
Copy link
Member

@olblak olblak commented Nov 7, 2023

Fix #1412

Thanks @mavimo for introducing me the jsonschema library and sorry that it took me so long to finish your work

This pullrequest introduces the ability to pick another Golang library for the yaml plugin.
The reasoning is the library "https://github.com/vmware-labs/yaml-jsonpath/" allows more advance yamlpath key but it is based on the go-yaml/v3 library which has many limitation.

On the other side, the Updatecli project moved to "goccy/go-yaml" which has limited yamlpath support...

So I propose an key yaml setting named engine which accept one of the following values

This pullrequest shouldn't introduce changes for current pipeline as we keep the current default behavior

Here is an example to retrieve a value from a specific array item in a Github Action

sources:
  getGo-Version-File:
    name: Test complex key 
    kind: yaml
    spec:
      engine: yamlpath
      file: .github/workflows/updatecli.yaml
      key: $.jobs.updatecli.steps[?(@.id =='go')].uses

Test

To test this pull request, you can run the following commands:

cd pkg/plugins/resources/yaml
go test
go build -o bin/updatecli .
./bin/updatecli diff --config e2e/updatecli.d/success.d/yaml/noscm.yaml

Additional Information

Tradeoff

Potential improvement

@olblak olblak added the resource-yaml Resource of kind YAML label Nov 7, 2023
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak added the enhancement New feature or request label Nov 7, 2023
@olblak olblak merged commit 68a3078 into updatecli:main Nov 7, 2023
6 checks passed
@olblak olblak deleted the addYamlPathSupport branch November 7, 2023 12:13
@olblak olblak changed the title feat(yaml): add yaml path support by using another engine feat(yaml): add advanced yamlpath support Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request resource-yaml Resource of kind YAML
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants