File tree 5 files changed +22
-2
lines changed
internal/packager2/layout
5 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,9 @@ type ZarfMetadata struct {
170
170
Vendor string `json:"vendor,omitempty"`
171
171
// Checksum of a checksums.txt file that contains checksums all the layers within the package.
172
172
AggregateChecksum string `json:"aggregateChecksum,omitempty"`
173
+ // Annotations contains arbitrary metadata about the package.
174
+ // Users are encouraged to follow OCI image-spec https://github.com/opencontainers/image-spec/blob/main/annotations.md
175
+ Annotations map [string ]string `json:"annotations,omitempty"`
173
176
}
174
177
175
178
// ZarfBuildData is written during the packager.Create() operation to track details of the created package.
Original file line number Diff line number Diff line change 8
8
"errors"
9
9
"fmt"
10
10
"log/slog"
11
+ "maps"
11
12
"strings"
12
13
13
14
"github.com/defenseunicorns/pkg/helpers/v2"
@@ -144,5 +145,7 @@ func annotationsFromMetadata(metadata v1alpha1.ZarfMetadata) map[string]string {
144
145
if vendor := metadata .Vendor ; vendor != "" {
145
146
annotations [ocispec .AnnotationVendor ] = vendor
146
147
}
148
+ // annotations explicitly defined in `metadata.annotations` take precedence over legacy fields
149
+ maps .Copy (annotations , metadata .Annotations )
147
150
return annotations
148
151
}
Original file line number Diff line number Diff line change @@ -21,16 +21,21 @@ func TestAnnotationsFromMetadata(t *testing.T) {
21
21
Documentation : "documentation" ,
22
22
Source : "source" ,
23
23
Vendor : "vendor" ,
24
+ Annotations : map [string ]string {
25
+ "org.opencontainers.image.title" : "overridden" ,
26
+ "org.opencontainers.image.new" : "new-field" ,
27
+ },
24
28
}
25
29
annotations := annotationsFromMetadata (metadata )
26
30
expectedAnnotations := map [string ]string {
27
- "org.opencontainers.image.title" : "foo " ,
31
+ "org.opencontainers.image.title" : "overridden " ,
28
32
"org.opencontainers.image.description" : "bar" ,
29
33
"org.opencontainers.image.url" : "https://example.com" ,
30
34
"org.opencontainers.image.authors" : "Zarf" ,
31
35
"org.opencontainers.image.documentation" : "documentation" ,
32
36
"org.opencontainers.image.source" : "source" ,
33
37
"org.opencontainers.image.vendor" : "vendor" ,
38
+ "org.opencontainers.image.new" : "new-field" ,
34
39
}
35
40
require .Equal (t , expectedAnnotations , annotations )
36
41
}
Original file line number Diff line number Diff line change 8
8
"context"
9
9
"errors"
10
10
"fmt"
11
+ "maps"
11
12
12
13
"github.com/defenseunicorns/pkg/helpers/v2"
13
14
"github.com/defenseunicorns/pkg/oci"
@@ -116,6 +117,7 @@ func annotationsFromMetadata(metadata *v1alpha1.ZarfMetadata) map[string]string
116
117
if vendor := metadata .Vendor ; vendor != "" {
117
118
annotations [ocispec .AnnotationVendor ] = vendor
118
119
}
119
-
120
+ // annotations explicitly defined in `metadata.annotations` take precedence over legacy fields
121
+ maps .Copy (annotations , metadata .Annotations )
120
122
return annotations
121
123
}
Original file line number Diff line number Diff line change 1076
1076
"aggregateChecksum" : {
1077
1077
"type" : " string" ,
1078
1078
"description" : " Checksum of a checksums.txt file that contains checksums all the layers within the package."
1079
+ },
1080
+ "annotations" : {
1081
+ "additionalProperties" : {
1082
+ "type" : " string"
1083
+ },
1084
+ "type" : " object" ,
1085
+ "description" : " Annotations contains arbitrary metadata about the package.\n Users are encouraged to follow OCI image-spec https://github.com/opencontainers/image-spec/blob/main/annotations.md"
1079
1086
}
1080
1087
},
1081
1088
"additionalProperties" : false ,
You can’t perform that action at this time.
0 commit comments