mirror of https://github.com/docker/buildx.git
Get annotations from exports
Signed-off-by: Eli Treuherz <et@arenko.group>
This commit is contained in:
parent
3971361ed2
commit
6f45b0ea06
|
@ -61,7 +61,6 @@ type Options struct {
|
|||
|
||||
Ref string
|
||||
Allow []entitlements.Entitlement
|
||||
Annotations map[exptypes.AnnotationKey]string
|
||||
Attests map[string]*string
|
||||
BuildArgs map[string]string
|
||||
CacheFrom []client.CacheOptionsEntry
|
||||
|
@ -608,8 +607,12 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
|
|||
}
|
||||
}
|
||||
|
||||
filteredAnnotations := filterIndexAnnotations(opt.Annotations)
|
||||
dt, desc, err := itpull.Combine(ctx, srcs, filteredAnnotations, false)
|
||||
indexAnnotations, err := extractIndexAnnotations(opt.Exports)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dt, desc, err := itpull.Combine(ctx, srcs, indexAnnotations, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -657,15 +660,25 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
func filterIndexAnnotations(annotations map[exptypes.AnnotationKey]string) map[exptypes.AnnotationKey]string {
|
||||
filteredAnnotations := map[exptypes.AnnotationKey]string{}
|
||||
for k, v := range annotations {
|
||||
switch k.Type {
|
||||
case exptypes.AnnotationIndex, exptypes.AnnotationManifestDescriptor:
|
||||
filteredAnnotations[k] = v
|
||||
func extractIndexAnnotations(exports []client.ExportEntry) (map[exptypes.AnnotationKey]string, error) {
|
||||
annotations := map[exptypes.AnnotationKey]string{}
|
||||
for _, exp := range exports {
|
||||
for k, v := range exp.Attrs {
|
||||
ak, ok, err := exptypes.ParseAnnotationKey(k)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch ak.Type {
|
||||
case exptypes.AnnotationIndex, exptypes.AnnotationManifestDescriptor:
|
||||
annotations[ak] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
return filteredAnnotations
|
||||
return annotations, nil
|
||||
}
|
||||
|
||||
func pushWithMoby(ctx context.Context, d *driver.DriverHandle, name string, l progress.SubLogger) error {
|
||||
|
|
|
@ -147,8 +147,6 @@ func RunBuild(ctx context.Context, dockerCli command.Cli, in controllerapi.Build
|
|||
|
||||
opts.Exports = outputs
|
||||
|
||||
opts.Annotations = annotations
|
||||
|
||||
opts.CacheFrom = controllerapi.CreateCaches(in.CacheFrom)
|
||||
opts.CacheTo = controllerapi.CreateCaches(in.CacheTo)
|
||||
|
||||
|
|
Loading…
Reference in New Issue