Skip to content

Commit

Permalink
Merge pull request #2098 from crazy-max/annotations-push
Browse files Browse the repository at this point in the history
build: make annotations work with push flag
  • Loading branch information
tonistiigi authored Oct 26, 2023
2 parents deb9dbe + f3871b1 commit 2f1b7a0
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 131 deletions.
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
}
}

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
}
}

opts.Exports = outputs

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

0 comments on commit 2f1b7a0

Please sign in to comment.