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

fix(datasource): trim trailing slash in registry url #11392

Merged
merged 13 commits into from Aug 30, 2021
Merged

Conversation

viceice
Copy link
Member

@viceice viceice commented Aug 23, 2021

Changes:

  • Always trim trailing registry url trailing slash before passing to datasource
  • Proper url join for gitlab-tags datasource
  • Proper url join for repology datasource

Context:

closes #11254

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

JamieMagee
JamieMagee previously approved these changes Aug 23, 2021
@viceice
Copy link
Member Author

viceice commented Aug 23, 2021

Most datasources are already handling trailing slashes, so after this pr we should refactor them, so we know we don't have any trailing slash

@rarkins
Copy link
Collaborator

rarkins commented Aug 23, 2021

Questions, not suggestions:

Why strip trailing slash and not enforce?

Why manual URL construction using string templates instead of URL.join type of joining?

@viceice
Copy link
Member Author

viceice commented Aug 23, 2021

Why strip trailing slash and not enforce?

🤷‍♂️ Looks cleaner to me when joining via strings, but we can also enforce them if you prefer.

Why manual URL construction using string templates instead of URL.join type of joining?

Url.resolve is deprecated, so needs to be replaced and will do a wrong join at that place.
I don't see much value to have an additional joind method, but we can use url-join if you prefer.

@viceice
Copy link
Member Author

viceice commented Aug 23, 2021

Looks like url-join would do right things here too.

@rarkins
Copy link
Collaborator

rarkins commented Aug 24, 2021

I'm ok with trimming the slash. Less chance we have duped cache entries. Would prefer we didn't do raw URL concatenation ourselves, or at least centralised it

@viceice
Copy link
Member Author

viceice commented Aug 24, 2021

Ok, will Push the changes later

@viceice viceice marked this pull request as draft August 24, 2021 11:11
@viceice viceice marked this pull request as ready for review August 24, 2021 18:07
@viceice viceice requested a review from rarkins August 25, 2021 07:21
@aslafy-z
Copy link
Contributor

Any change this gets merged any-time soon? Thank you

@rarkins
Copy link
Collaborator

rarkins commented Aug 27, 2021

@aslafy-z have you been able to run and verify this branch locally?

@viceice
Copy link
Member Author

viceice commented Aug 27, 2021

DEBUG: packageFiles with updates (repository=aslafy-z/reproduce-renovate-bug-docker-hub)
       "config": {
         "regex": [
           {
             "packageFile": "components.yaml",
             "deps": [
               {
                 "depName": "jettech/kube-webhook-certgen",
                 "currentValue": "v1.5.0",
                 "datasource": "docker",
                 "versioning": "docker",
                 "replaceString": "ok_version: \"v1.5.0\" # renovate: datasource=docker depName=jettech/kube-webhook-certgen versioning=docker\n",
                 "depIndex": 0,
                 "updates": [
                   {
                     "bucket": "patch",
                     "newVersion": "v1.5.2",
                     "newValue": "v1.5.2",
                     "newMajor": 1,
                     "newMinor": 5,
                     "updateType": "patch",
                     "branchName": "renovate-test/jettech-kube-webhook-certgen-1.5.x"
                   }
                 ],
                 "warnings": [],
                 "currentVersion": "v1.5.0",
                 "isSingleVersion": true,
                 "fixedVersion": "v1.5.0"
               },
               {
                 "depName": "jettech/kube-webhook-certgen",
                 "currentValue": "v1.5.1",
                 "datasource": "docker",
                 "versioning": "docker",
                 "registryUrls": ["https://index.docker.io/"],
                 "replaceString": "not_ok_version: \"v1.5.1\" # renovate: datasource=docker depName=jettech/kube-webhook-certgen registryUrl=https://index.docker.io versioning=docker\n",
                 "depIndex": 1,
                 "updates": [
                   {
                     "bucket": "patch",
                     "newVersion": "v1.5.2",
                     "newValue": "v1.5.2",
                     "newMajor": 1,
                     "newMinor": 5,
                     "updateType": "patch",
                     "branchName": "renovate-test/jettech-kube-webhook-certgen-1.5.x"
                   }
                 ],
                 "warnings": [],
                 "currentVersion": "v1.5.1",
                 "isSingleVersion": true,
                 "fixedVersion": "v1.5.1"
               }
             ],
             "matchStrings": [
               "[^\\n]*_version: \"(?<currentValue>.*)\"\\s*#\\s*renovate:\\s*datasource=(?<datasource>.*?) depName=(?<depName>.*?)( registryUrl=(?<registryUrl>.*?))?( versioning=(?<versioning>.*?))?\\n"
             ]
           }
         ]
       }

@viceice
Copy link
Member Author

viceice commented Aug 30, 2021

@rarkins I've run this on some different repos and didn't found any issue. So i'm 95% sure it's save to merge

@rarkins rarkins enabled auto-merge (squash) August 30, 2021 15:19
rarkins
rarkins previously approved these changes Aug 30, 2021
@rarkins rarkins merged commit c8c8684 into main Aug 30, 2021
@rarkins rarkins deleted the fix/trailing-slash branch August 30, 2021 16:28
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 26.13.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2021
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.

bug: extra slash in docker registry other than index.docker.io
5 participants