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: [s][c][t] Add xml resource plugin #823

Merged
merged 6 commits into from
Aug 28, 2022
Merged

Conversation

olblak
Copy link
Member

@olblak olblak commented Aug 26, 2022

Signed-off-by: Olblak me@olblak.com

Fix #371

This pullrequest is a second attempt after #336

This time I am leveraging https://github.com/beevik/etree library

It went smoothly, and after some testing, I didn't notify any major change done to the xml file after an update

Accept spec parameters are:

  • file: Define the xml file to manipulate
  • path: Specify the xml path query
  • value: Specify the xml value

Test

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

cd pkg/plugins/resources/xml
go test

The path accept xpath query such as https://docs.python.org/3/library/xml.etree.elementtree.html#supported-xpath-syntax:w
Note that I didn't test all of them.

Additional Information

Tradeoff

/

Potential improvement

/

Signed-off-by: Olblak <me@olblak.com>
@olblak olblak added enhancement New feature or request resource-xml Modify resource of type xml labels Aug 26, 2022
@olblak olblak mentioned this pull request Aug 26, 2022
2 tasks
@olblak
Copy link
Member Author

olblak commented Aug 26, 2022

@jetersen I may have found an integrated solution

@olblak
Copy link
Member Author

olblak commented Aug 26, 2022

Combined with the autodiscovery feature introduced in "#763", we could automate pom.xml

@jetersen
Copy link
Member

jetersen commented Aug 26, 2022

If you want we can easily test it on Jenkinsci/bom since manifests are generated

@olblak
Copy link
Member Author

olblak commented Aug 26, 2022

Seems to working. I created this pullrequest https://github.com/olblak/bom/pull/1/files
using the following file

scms:
  default:
    kind: github
    spec:
      user: updatecli
      email: me@olblak.com
      owner: olblak
      repository: bom 
      token: '{{ requiredEnv "UPDATECLI_GITHUB_TOKEN" }}'
      username: '{{ requiredEnv "UPDATECLI_GITHUB_ACTOR" }}'
      branch: master
 
sources:
  jenkins-weekly:
    name: Get Latest Jenkins weekly version
    kind: jenkins
    spec:
      release: weekly

conditions:
  jenkins-weekly:
    name: Ensure bom properties is set to jenkins weekly
    kind: xml 
    scmid: default
    disablesourceinput: true
    spec:
      file: sample-plugin/pom.xml
      path: "./project/properties/bom"
      value: weekly
  
targets:
  jenkins-weekly:
    name: Bump Jenkins weekly version
    kind: xml 
    scmid: default
    spec:
      file: sample-plugin/pom.xml
      path: "./project/properties/jenkins.version"

pullrequests:
  default:
    title: '[updatecli] Bump Jenkins Weekly version to {{ source "jenkins-weekly" }}'
    kind: github
    scmid: default
    # Will soon be dropped, once https://github.com/updatecli/updatecli/pull/763 is merged
    targets:
      - jenkins-weekly

    spec:
      labels:
        - dependencies
        - skip-changelog

@olblak
Copy link
Member Author

olblak commented Aug 26, 2022

@hervelemeur If you have some time, I would appreciate your review on this PR as you are pretty good at catching things I don't see

@olblak
Copy link
Member Author

olblak commented Aug 26, 2022

Imho the PR is ready to be merged

@olblak olblak enabled auto-merge (squash) August 27, 2022 12:21
@olblak olblak disabled auto-merge August 28, 2022 07:15
@olblak
Copy link
Member Author

olblak commented Aug 28, 2022

I am moving forward so I can already start using this in production

@olblak olblak changed the title Feat: Add xml resource plugin Feat: [s][c][t] Add xml resource plugin Aug 28, 2022
@olblak olblak merged commit 2fe7f7d into updatecli:main Aug 28, 2022
@lemeurherve
Copy link
Member

lemeurherve commented Aug 29, 2022

@hervelemeur If you have some time, I would appreciate your review on this PR as you are pretty good at catching things I don't see

Erf, I had some (small) suggestions indeed, too late.

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-xml Modify resource of type xml
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add XML resources
3 participants