Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add metadata.annotations to v1alpha1 schema #3044

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/api/v1alpha1/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ type ZarfMetadata struct {
Vendor string `json:"vendor,omitempty"`
// Checksum of a checksums.txt file that contains checksums all the layers within the package.
AggregateChecksum string `json:"aggregateChecksum,omitempty"`
// Annotations contains arbitrary metadata about the package.
// Users are encouraged to follow OCI image-spec [annotation rules](https://github.com/opencontainers/image-spec/blob/v1.1.0/annotations.md).
Annotations map[string]string `json:"annotations,omitempty"`
}

// ZarfBuildData is written during the packager.Create() operation to track details of the created package.
Expand Down
3 changes: 2 additions & 1 deletion src/api/v1beta1/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ type ZarfMetadata struct {
Architecture string `json:"architecture,omitempty" jsonschema:"example=arm64,example=amd64"`
// Default to true, when false components cannot have images or git repos as they will be pulled from the internet
Airgap *bool `json:"airgap,omitempty"`
// Annotations are key-value pairs that can be used to store metadata about the package.
// Annotations contains arbitrary metadata about the package.
// Users are encouraged to follow OCI image-spec [annotation rules](https://github.com/opencontainers/image-spec/blob/v1.1.0/annotations.md).
Annotations map[string]string `json:"annotations,omitempty"`
}

Expand Down
4 changes: 4 additions & 0 deletions src/pkg/zoci/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package zoci
import (
"context"
"fmt"
"maps"

"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/pkg/oci"
Expand Down Expand Up @@ -110,5 +111,8 @@ func annotationsFromMetadata(metadata *v1alpha1.ZarfMetadata) map[string]string
annotations[ocispec.AnnotationVendor] = vendor
}

// annotations explicitly defined in `metadata.annotations` take precedence over legacy fields
maps.Copy(annotations, metadata.Annotations)

Comment on lines +114 to +116
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not find any existing tests for populating annotations on the OCI manifest and config. Happy to add some if there is an obvious place to do that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah there aren't currently any tests that verify that annotations end up on the manifest or manifest config

return annotations
}
7 changes: 7 additions & 0 deletions zarf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,13 @@
"aggregateChecksum": {
"type": "string",
"description": "Checksum of a checksums.txt file that contains checksums all the layers within the package."
},
"annotations": {
"additionalProperties": {
"type": "string"
},
"type": "object",
"description": "Annotations contains arbitrary metadata about the package.\nUsers are encouraged to follow OCI image-spec [annotation rules](https://github.com/opencontainers/image-spec/blob/v1.1.0/annotations.md)."
}
},
"additionalProperties": false,
Expand Down
Loading