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: make annotations work with push flag #2098

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func (o *buildOptions) toControllerOptions() (*controllerapi.BuildOptions, error

opts := controllerapi.BuildOptions{
Allow: o.allow,
Annotations: o.annotations,
BuildArgs: buildArgs,
CgroupParent: o.cgroupParent,
ContextPath: o.contextPath,
Expand Down Expand Up @@ -172,16 +173,6 @@ func (o *buildOptions) toControllerOptions() (*controllerapi.BuildOptions, error
}
}

annotations, err := buildflags.ParseAnnotations(o.annotations)
if err != nil {
return nil, err
}
for _, e := range opts.Exports {
for k, v := range annotations {
e.Attrs[k.String()] = v
}
}

Comment on lines -179 to -184
Copy link
Collaborator

Choose a reason for hiding this comment

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

So here --push hasn't been translated to an export entry. Can you just link me the line where this happens for learning purposes?

opts.CacheFrom, err = buildflags.ParseCacheEntry(o.cacheFrom)
if err != nil {
return nil, err
Expand Down
11 changes: 11 additions & 0 deletions controller/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ func RunBuild(ctx context.Context, dockerCli command.Cli, in controllerapi.Build
}
}
}

annotations, err := buildflags.ParseAnnotations(in.Annotations)
if err != nil {
return nil, nil, err
}
for _, o := range outputs {
for k, v := range annotations {
o.Attrs[k.String()] = v
}
}
Comment on lines +140 to +144
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's delayed here (so --push is a true alias for --output=type=registry) and that's why this works.


opts.Exports = outputs

opts.CacheFrom = controllerapi.CreateCaches(in.CacheFrom)
Expand Down
Loading