-
Notifications
You must be signed in to change notification settings - Fork 36
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 replacements capture groups #702
Comments
Hmm this is largely left to a package I use I believe. If you could give me an example of the helm chart and regex I can see what I can do. |
Sure.... # Chart.yaml
version: 1.0.0
name: common
description: Common chart to be shared
dependencies:
- name: other
version: 2.0.0
repository: https://fake-registry.com/other
- name: dependency
repository: https://fake-registry.com/dependency
condition: dependency.enabled
version: 1.0.0 Regex to find what I'm looking for and replace a version number:
This would find the dependency chart # changie.yaml
projects:
- key: other
label: Other
replacements:
- path: other/Chart.yaml
find: "^version: .*"
replace: "version: {{ .VersionNoPrefix }}"
- path: common/Chart.yaml
find: "(- name: other.+?version): \\d+\\.\\d+\\.\\d+"
replace: "{{ index .CaptureGroups 0 }}: {{ .VersionNoPrefix }}"
flags: s The thing I tested out was adding a |
Hey there @Magic-Mayo I did some testing and found I don't actually need a package for this as the regexp has one already. Go uses # changie.yaml
projects:
- key: other
label: Other
replacements:
- path: other/Chart.yaml
find: "^version: .*"
replace: "version: {{ .VersionNoPrefix }}"
- path: common/Chart.yaml
find: "(- name: other.+?version): \\d+\\.\\d+\\.\\d+"
replace: "$1: {{ .VersionNoPrefix }}"
flags: s ^ is what you will be able to do, should have this up and pushed this weekend. |
Is your feature request related to a problem? Please describe.
Currently,
Replacement
only allows you to replace with a hardcoded string or withReplaceData
when processing replacements. I'd like to use the shortest possible regex since I'm covering multiple lines of text to find what I'm looking for.Specifically, I'm trying to update versions of dependencies in a helm chart so I can't just do something like
version: .*
as there will be multiple lines in the Chart.yaml that have that. I need to get the specific list item and update the version so my regex would look something like this when updating a single dependency:I'd like to use the capture group to put whatever string I found back in place. This helps with not having to format each of those files very specifically and ensures no mistakes are made. It also keeps us from having to do a bunch tedious formatting as well as making sure we don't have to follow a specific format in the future.
Describe the solution you'd like
Supporting regex capture groups
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
I've tested out some changes and can post a PR if you think the feature is worthwhile
The text was updated successfully, but these errors were encountered: