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

add md5 checksum of dockerfiles to image labels #967

Merged
merged 1 commit into from
Aug 15, 2024

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.

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
7 checks passed
@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