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: replacement support for more autoreplace managers #17476

Closed

Conversation

t-kulmburg
Copy link
Contributor

@t-kulmburg t-kulmburg commented Aug 29, 2022

Changes

This is based on a PR from @JamieMagee about adding support for replacements for autoreplace managers

Context

After fixing building errors I added the name-replacement into the doAutoReplace function as they share most of their logic.
If you have any good ideas for better structure, I can refactor the code further.

I also crated a gitlab demo-repo containing a dependency for all managers listed in the PR of @JamieMagee.
As can be seen in the repo README and the Renovate created merge requests, more then half of them are already working with my rather minimal changes.
I also added a brief description of the problems the other managers currently have.
To test the feature even further I added unit tests for Managers that worked in the demo-repo.

My question now would be how you would like to proceed with this topic in general.
Getting the feature to work for all supported managers will probably require a lot more work,
but supporting only the currently working ones will require a detailed documentation on the current status.

I am willing to spend some more time on this in the next days/weeks, so reviews would be appreciated.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@t-kulmburg t-kulmburg changed the title Feat: replacement support for more autoreplace managers feat: replacement support for more autoreplace managers Aug 29, 2022
@t-kulmburg t-kulmburg marked this pull request as draft August 29, 2022 13:49
@JamieMagee
Copy link
Contributor

@t-kulmburg Thanks for taking this over. I am going to close #13211 in favour of your PR.

@t-kulmburg
Copy link
Contributor Author

I just pushed a fix to enable replacing the same dependency with different other dependencies, based on the 'matchCurrentVersion' constraint. Example Mr.

I am now investigating and trying to fix the problem that replacement doesnt work for docker images with digest.

If you want any documentation/more tests etc. just let me know!

@t-kulmburg
Copy link
Contributor Author

Another update:

  • Docker digests are now also updated correctly. MergeRequest
  • Python version restrictions (pep440) are now ignored for replacements (as the replacement version could carry it's own restrictions), these now also work. MergeRequest
  • Found an issue with kustomize, the replacement is not as expected --> will investigate tomorrow

There are several manager that would need additional fields, to be fully supported (gitlab-ci-include needs file, helmv3 would need URL etc., all documented in my demo README).
My proposal is that I fix kustomize, so that there are no "bugs" only missing "features", that could be implemented at a later date.

I plan to mark my PR as "Ready for Review" as soon as I have that kustomize issue resolved,
or do you have anything else you would want me to do, before this feature is merge worthy?

@t-kulmburg
Copy link
Contributor Author

t-kulmburg commented Sep 2, 2022

Kustomize is actually replacing as expected, but the option to replace subdirectories is missing as they are not part of the 'depName': MR

@t-kulmburg t-kulmburg marked this pull request as ready for review September 2, 2022 09:06
@chezsmithy
Copy link
Contributor

@t-kulmburg is it possible to replace the docker registry and the image with this change?

@t-kulmburg
Copy link
Contributor Author

@t-kulmburg is it possible to replace the docker registry and the image with this change?

I assume you mean in a Dockerfile, yes it is possible.
I added two more examples to the demo repo: MR-1, MR-2

@chezsmithy
Copy link
Contributor

@t-kulmburg you might need to request a new review from viceice and paging @JamieMagee for a review.

@t-kulmburg t-kulmburg requested review from viceice and removed request for JamieMagee September 17, 2022 06:13
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this should be split into multiple PR.

  • datasource changes
  • worker changes
  • auto-replace changes
  • manager changes
  • versioning changes

@@ -19,7 +19,8 @@ export function mergeChildConfig<
if (
option.mergeable &&
childConfig[option.name] &&
parentConfig[option.name]
parentConfig[option.name] &&
parentConfig[option.name] !== childConfig[option.name]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this I had the problem that my newName, newValue and finally depName changed from one string to an array of single characters.

Comment on lines +436 to +437
const packageName =
config.replacementName ?? config.packageName ?? config.depName;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this "packageName" is used to look up digests. After this change it is able to replace images with digests, as now the correct digest for the replacement is used. Without this the depName would be replaced, but the old digest would be used as the old name would be used in lookUp

manager: 'html',
packageFile: 'test',
});
// TODO: fix types (#7154)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • You can't assign t-kulmburg to this TODO because he or she is not a member of your GitHub organisation and
    neither a collaborator of this repository.

@t-kulmburg
Copy link
Contributor Author

Created 3 new PRs:

should I close this PR now?

@t-kulmburg t-kulmburg marked this pull request as draft September 20, 2022 13:58
@t-kulmburg t-kulmburg closed this Sep 27, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants