jetstack / version-checker

Kubernetes utility for exposing image versions in use, compared to latest available upstream, as metrics.
https://jetstack.io
Apache License 2.0
661 stars 76 forks source link

Support multiple Subfolders in Registry #176

Closed rehabyte closed 2 weeks ago

rehabyte commented 2 months ago

Is there a Possibility to support Imagereferences like the following:

artifactory.test.de/repo/subfolder/image:tag

In your path_test.go i have seen that only the last two substrings in URL will considered.

In selfhosted.go the tags path is defined as "// {host}/v2/{repo/image}/tags/list?n=500". "repo" and "image" will be replaced with the two substrings from "path.go".

In my example the "repo"-variable have to be set with "repo/subfolder". If I understand the code on the right way, the "repo"-variable based on my example will be set with "subfolder".

Thanks in advance

davidcollom commented 2 weeks ago

This is already covered as a test under https://github.com/jetstack/version-checker/blob/main/pkg/client/selfhosted/path_test.go#L98-L107

I have also (local) extended this to artifactory.dev/folder1/subfolder/subsubfolder/subsubsubfolder/image and still passed with no code changes.

Here's the test cases I added after line 107:

        "multiple nested segments to path should return last two": {
            path:     "folder1/subfolder/subsubfolder/image",
            expRepo:  "folder1/subfolder/subsubfolder",
            expImage: "image",
        },
        "multiple nested segments to paths should return last two": {
            path:     "folder1/subfolder/subsubfolder/subsubsubfolder/image",
            expRepo:  "folder1/subfolder/subsubfolder/subsubsubfolder",
            expImage: "image",
        },