@@ -25,7 +25,6 @@ import (
2525 "os"
2626 "path"
2727 "slices"
28- "strings"
2928
3029 "chainguard.dev/apko/pkg/apk/apk"
3130 apkfs "chainguard.dev/apko/pkg/apk/fs"
@@ -34,21 +33,21 @@ import (
3433 v1 "github.com/google/go-containerregistry/pkg/v1"
3534)
3635
37- func (bc * Context ) buildLayers (ctx context.Context ) ([]v1.Layer , [] map [ string ] string , error ) {
36+ func (bc * Context ) buildLayers (ctx context.Context ) ([]v1.Layer , error ) {
3837 log := clog .FromContext (ctx )
3938
4039 if strategy := bc .ic .Layering .Strategy ; strategy != "origin" {
41- return nil , nil , fmt .Errorf ("unrecognized layering strategy %q" , strategy )
40+ return nil , fmt .Errorf ("unrecognized layering strategy %q" , strategy )
4241 }
4342
4443 if bc .ic .Contents .BaseImage != nil {
45- return nil , nil , fmt .Errorf ("layering with %q is unsupported" , "baseimage" )
44+ return nil , fmt .Errorf ("layering with %q is unsupported" , "baseimage" )
4645 }
4746
4847 // Build a single fs.FS, the normal way (this writes to bc.fs).
4948 diffs , err := bc .buildImage (ctx )
5049 if err != nil {
51- return nil , nil , fmt .Errorf ("building filesystem: %w" , err )
50+ return nil , fmt .Errorf ("building filesystem: %w" , err )
5251 }
5352
5453 pkgs := make ([]* apk.Package , 0 , len (diffs ))
@@ -67,13 +66,13 @@ func (bc *Context) buildLayers(ctx context.Context) ([]v1.Layer, []map[string]st
6766 //
6867 // TODO: Clean this up when time permits.
6968 if err := bc .postBuildSetApk (ctx ); err != nil {
70- return nil , nil , err
69+ return nil , err
7170 }
7271
7372 // Use our layering strategy to partition packages into a set of Budget groups.
7473 groups , err := groupByOriginAndSize (pkgs , bc .ic .Layering .Budget )
7574 if err != nil {
76- return nil , nil , fmt .Errorf ("grouping packages: %w" , err )
75+ return nil , fmt .Errorf ("grouping packages: %w" , err )
7776 }
7877 log .Infof ("Building %d layers with budget %d" , len (groups ), bc .ic .Layering .Budget )
7978
@@ -88,34 +87,10 @@ func (bc *Context) buildLayers(ctx context.Context) ([]v1.Layer, []map[string]st
8887 // Then partition that single fs.FS into multiple layers based on our layering strategy.
8988 layers , err := splitLayers (ctx , bc .fs , groups , pkgToDiff , bc .o .TempDir ())
9089 if err != nil {
91- return nil , nil , err
92- }
93-
94- // Generate per-layer annotations when auto-annotate is enabled.
95- var perLayerAnnotations []map [string ]string
96- if bc .ic .Layering .AutoAnnotate {
97- perLayerAnnotations = autoAnnotateLayers (groups )
90+ return nil , err
9891 }
9992
100- return layers , perLayerAnnotations , nil
101- }
102-
103- // autoAnnotateLayers generates per-layer annotation maps from package groups.
104- // The returned slice has one entry per group (package layer); the top layer
105- // (appended by splitLayers) is not included and gets no auto-annotations.
106- func autoAnnotateLayers (groups []* group ) []map [string ]string {
107- annotations := make ([]map [string ]string , len (groups ))
108- for i , g := range groups {
109- names := make ([]string , 0 , len (g .pkgs ))
110- for _ , pkg := range g .pkgs {
111- names = append (names , pkg .Name + "=" + pkg .Version )
112- }
113- slices .Sort (names )
114- annotations [i ] = map [string ]string {
115- "dev.chainguard.layer.packages" : strings .Join (names , "," ),
116- }
117- }
118- return annotations
93+ return layers , nil
11994}
12095
12196func replacesGroup (rep string , g * group ) (bool , error ) {
0 commit comments