Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dklimpel
Copy link
Contributor

Checklist
  • make test-all (UNIX) passes. CI will also test this
  • unit and/or integration tests are included (if applicable)
  • documentation is changed or added (if applicable)

Description of change

Add m5 checksums to a an image label.
This can be directly compared later and is also available in the image in the long term.

@dklimpel dklimpel requested a review from aelsabbahy as a code owner August 15, 2024 21:23
Copy link
Member

@aelsabbahy aelsabbahy left a comment

Choose a reason for hiding this comment

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

Awesome, curious on the commands to use this for comparison.

@aelsabbahy aelsabbahy merged commit 2d8846d into goss-org:master Aug 15, 2024
@dklimpel dklimpel deleted the add_checksum branch August 16, 2024 05:26
@dklimpel
Copy link
Contributor Author

Awesome, curious on the commands to use this for comparison.

I know two options.

curl:

$ repo=stavalfi/k8test-monitoring                                                                                                                                                                                 

$ token=$(curl -s "https://auth.docker.io/token?service=registry.docker.io&scope=repository:${repo}:pull" \
        | jq -r '.token')

$ digest=$(curl -s -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -H "Authorization: Bearer $token" "https://registry-1.docker.io/v2/${repo}/manifests/latest" \
  | jq .config.digest -r)

$ curl -s -L -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -H "Authorization: Bearer $token" "https://registry-1.docker.io/v2/${repo}/blobs/$digest" \
  | jq .config.Labels
{
  "latest-hash": "dc971f310bd0b172fd0379cc9a1810f209c9a9604a28da14cef36457",
  "latest-tag": "1.3.4"
}

or docker pull:

if [ "${INPUT_REGISTRY_PASSWORD}" != "" ]; then
    echo "${INPUT_REGISTRY_PASSWORD}" | docker login -u "${INPUT_REGISTRY_USERNAME}" --password-stdin "${INPUT_REGISTRY_ENDPOINT}"
fi

docker pull "${INPUT_IMAGE}"
value=$(docker inspect "${INPUT_IMAGE}" | jq -r ".[0].Config.Labels[\"${INPUT_LABEL}\"]")

I prefer the way with curl, as the image does not have to be downloaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants