dockercurlartifactoryartifactory-query-lang

How to get a key/value pair from the Docker Info section via the Artifactory API?


I know a similar question was raised here: How to get the dockerTag label via the Artifactory API? But unfortunately the provided and accepted answer doesn't seem to work in my case.

I am also trying to access the information which is located under the "Docker Info" tab in a key/value pair in the Artifactory UI. As mentioned I tried the approach in the accepted answer from the linked question, which does return the properties object. But for me there is no .label part included. Basically I think this is because the information I want to request is not in the manifest.json. It is located a level "higher".

To help visualize this, I have the following screenshot: enter image description here

Here you can see on the left my Artifactory with the selected Docker image. I want to request the information from the key "release". On the right side I opened the browser developer tools to check the request that gets executed when loading the Artifactory page. Under Network in the tab "Fetch/XHR" you can find an entry "dockerv2". When selecting this you can see under "Response" a "tagInfo" object which contains the desired information. So I guess it should be possible to request that information via an API call.

I tried the following:

curl -uadmin:pass https://artifactory.myUrl.io/ui/api/v1/ui/views/dockerv2/repo-name/path-to-image

But this returns 404 not found. In my opinion the URL is not right (because it contains UI parts), but the developer tools shows this as the Request URL.

So I am kinda stuck on how to figure out the correct request. I would say it is possible to retrieve the desired information, because it is available and it should be accessible. Anyone have an idea on how to approach this?


Solution

  • The API you are using is saved for UI purposes. That said, there are a few options to retrieve the data:

    Artifactory API

    Replace ui/api/v1/ui with /artifactory/api, and add the required payload, for example:

    curl --location 'https://artifactory.myUrl.io/artifactory/api/views/dockerv2' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Basic ****' \
    --data '{
      "repoKey": "repo-name",
      "path": "path-to-image",
      "view": "dockerv2"
    }'
    

    Skopeo inspect

    You can use the Skopeo client in order to retrieve the data,

    skopeo inspect docker://artifactory.myUrl.io/repo-name/path-to-image