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

build: add --annotation shortcut flag #2020

Merged
merged 4 commits into from
Sep 11, 2023

Conversation

jedevc
Copy link
Collaborator

@jedevc jedevc commented Aug 24, 2023

Fixes #1171.

This extracts the same logic for parsing annotations from the imagetools create command (see #1965), and allows the same flags to be attached to the build command. Additionally, we also allow these to be specified in bake's target.annotations field - happy to bikeshed exact syntax, I've just thrown something together (or to pull it out to a separate PR if we're not 100% sure).

These annotations are then merged into all provided exporters.

@jedevc jedevc force-pushed the build-annotation-flags branch 2 times, most recently from 1652e3b to e51a785 Compare August 24, 2023 13:38

func ParseAnnotations(inp []string) (map[exptypes.AnnotationKey]string, error) {
// TODO: use buildkit's annotation parser once it supports setting custom prefix and ":" separator
annotationRegexp := regexp.MustCompile(`^(?:([a-z-]+)(?:\[([A-Za-z0-9_/-]+)\])?:)?(\S+)$`)
Copy link
Member

Choose a reason for hiding this comment

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

follow up: is it really worth using this crazy regexp instead of simple splits?

This extracts the same logic for parsing annotations from the imagetools
create command, and allows the same flags to be attached to the build
command.

These annotations are then merged into all provided exporters.

Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
@jedevc
Copy link
Collaborator Author

jedevc commented Sep 11, 2023

Rebased.

@jedevc jedevc merged commit 66e6dab into docker:master Sep 11, 2023
59 checks passed
@jedevc jedevc deleted the build-annotation-flags branch September 11, 2023 14:55
@crazy-max crazy-max added this to the v0.12.0 milestone Sep 11, 2023
nijel added a commit to nijel/docker that referenced this pull request Nov 1, 2023
This needs --annotations support in buildx which was introduced in
docker/buildx#2020 and will be released in
0.12.0.
nijel added a commit to nijel/docker that referenced this pull request Nov 1, 2023
This needs --annotations support in buildx which was introduced in
docker/buildx#2020 and will be released in
0.12.0.
nijel added a commit to nijel/docker that referenced this pull request Nov 17, 2023
This needs --annotations support in buildx which was introduced in
docker/buildx#2020 and will be released in
0.12.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: annotations helpers
3 participants