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 image labels to metadata #338

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

martinxsliu
Copy link

This PR adds the image's labels as a comma separated string to the version's metadata. Labels contain valuable metadata and in our case we encode information about the git commit that produced the image. This is useful information to display in the UI when viewing the build logs as well as the version list page when users they can use the labels to enable/disable/pin versions.

I have tested that the $labels variable contains the correct comma separated string when there are labels (see screenshot) and is an empty string when there are not.

image

@@ -76,6 +76,7 @@ if [ "$skip_download" = "false" ]; then

echo "$image_id" > ${destination}/image-id
docker inspect $image_id > ${destination}/docker_inspect.json
labels="$(cat ${destination}/docker_inspect.json | jq -r '.[0].Config.Labels // {} | to_entries | map("\(.key)=\(.value)") | join(", ")')"
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens if the jq parsing encounters problem ? would it be always make labels empty only?

Could you add a test to make sure all cases are considered so it wont errored out?

Copy link
Contributor

@xtremerui xtremerui left a comment

Choose a reason for hiding this comment

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

Hi thx for the PR. This resource is depracated in favor of registry-image-resource. Ideally we don't want to pull in new feature here. Have you tried using registry-image-resource to archieve the same thing?

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