mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
Get annotations from exports
Signed-off-by: Eli Treuherz <et@arenko.group>
This commit is contained in:
@ -61,7 +61,6 @@ type Options struct {
|
|||||||
|
|
||||||
Ref string
|
Ref string
|
||||||
Allow []entitlements.Entitlement
|
Allow []entitlements.Entitlement
|
||||||
Annotations map[exptypes.AnnotationKey]string
|
|
||||||
Attests map[string]*string
|
Attests map[string]*string
|
||||||
BuildArgs map[string]string
|
BuildArgs map[string]string
|
||||||
CacheFrom []client.CacheOptionsEntry
|
CacheFrom []client.CacheOptionsEntry
|
||||||
@ -608,8 +607,12 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredAnnotations := filterIndexAnnotations(opt.Annotations)
|
indexAnnotations, err := extractIndexAnnotations(opt.Exports)
|
||||||
dt, desc, err := itpull.Combine(ctx, srcs, filteredAnnotations, false)
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
dt, desc, err := itpull.Combine(ctx, srcs, indexAnnotations, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -657,15 +660,25 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func filterIndexAnnotations(annotations map[exptypes.AnnotationKey]string) map[exptypes.AnnotationKey]string {
|
func extractIndexAnnotations(exports []client.ExportEntry) (map[exptypes.AnnotationKey]string, error) {
|
||||||
filteredAnnotations := map[exptypes.AnnotationKey]string{}
|
annotations := map[exptypes.AnnotationKey]string{}
|
||||||
for k, v := range annotations {
|
for _, exp := range exports {
|
||||||
switch k.Type {
|
for k, v := range exp.Attrs {
|
||||||
case exptypes.AnnotationIndex, exptypes.AnnotationManifestDescriptor:
|
ak, ok, err := exptypes.ParseAnnotationKey(k)
|
||||||
filteredAnnotations[k] = v
|
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 {
|
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.Exports = outputs
|
||||||
|
|
||||||
opts.Annotations = annotations
|
|
||||||
|
|
||||||
opts.CacheFrom = controllerapi.CreateCaches(in.CacheFrom)
|
opts.CacheFrom = controllerapi.CreateCaches(in.CacheFrom)
|
||||||
opts.CacheTo = controllerapi.CreateCaches(in.CacheTo)
|
opts.CacheTo = controllerapi.CreateCaches(in.CacheTo)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user