Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Allow set container_image labels by json file #2211

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

Conversation

bozaro
Copy link

@bozaro bozaro commented Jan 12, 2023

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the new behavior?

Allow set docker labels by .json file.

Does this PR introduce a breaking change?

  • Yes
  • No

@uhthomas
Copy link
Collaborator

Is there an issue open where this feature has been discussed? Could you explain why this may be useful?

@bozaro
Copy link
Author

bozaro commented Jan 16, 2023

Is there an issue open where this feature has been discussed?
No.

Could you explain why this may be useful?
We use file for labels in two places:

  • set Docker labels for image garbage collector policy (we have differ policy for master and feature-branches. Branch type passed by stable stamping variables);
  • set marker for "upload if not uploaded yet" logic.

Little bit about "upload if not uploaded yet" workflow:

  • we check image in docker registry with upload marker (some uniuqe for build value) and return passed upload marker if image is not uploaded or image marker from uploaded image;
  • upload marker passed to labels;
  • rule makes push to registry.

As a result, we get the following effect:

  • initially image will be upload to registry;
  • if image already in registry, we got CACHE HIT (same image and upload marker) and push step will be skipped without downloading all layers to worker;
  • if image was remove from registry by GC, we got CACHE MISS (same image but new upload marker) and it will be upload.

@github-actions
Copy link

This Pull Request has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days.
Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!

@github-actions github-actions bot added the Can Close? Will close in 30 days unless there is a comment indicating why not label Jul 16, 2023
@bozaro
Copy link
Author

bozaro commented Jul 19, 2023

Changes:

  • rebased to master;
  • use labels_file attribute instead of reusing label_files attribute.

@github-actions github-actions bot removed the Can Close? Will close in 30 days unless there is a comment indicating why not label Jul 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants