Add custom tags to deployment records through annotations#41
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for custom tags in deployment records through Kubernetes annotations and updates the runtime-risk annotation key to use a new namespace. The changes enable users to attach up to 5 custom key-value tags to deployment records by using annotations with the metadata.github.com/ prefix, with a maximum of 100 characters per key or value. When duplicate tag keys exist in the ownership hierarchy (pod → ReplicaSet → Deployment), values from objects lower in the hierarchy take precedence.
Changes:
- Updated runtime-risk annotation key from
github.com/runtime-riskstometadata.github.com/runtime-risks - Added support for custom tags via
metadata.github.com/<key>annotations with validation and limits - Enhanced metadata aggregation to collect and prioritize tags from pod ownership hierarchy
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkg/deploymentrecord/record.go | Added Tags field to DeploymentRecord struct and updated NewDeploymentRecord signature to accept tags parameter |
| pkg/deploymentrecord/client.go | Updated error handling to explicitly ignore resp.Body.Close() error for linter compliance |
| internal/controller/controller.go | Added constants for custom tag limits, updated AggregatePodMetadata to include tags, modified extractMetadataFromObject to extract and validate tags with precedence handling, and updated recordContainer to process tags |
| README.md | Updated documentation to reflect new annotation namespace and added comprehensive custom tags documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ajbeattie
left a comment
There was a problem hiding this comment.
LGTM. Definitely think a followup with tests for the tag and general metadata logic should be next!
This PR implements the following:
metadata.github.com/runtime-risksmetadata.github.com/<tag key>