From e16d8a9ac10536582222ee22fe3a2ca0a14ea600 Mon Sep 17 00:00:00 2001 From: Victor Date: Sat, 7 Jun 2025 20:16:31 +0100 Subject: [PATCH 1/2] Display OCI annotations in 'helm show chart' When showing chart information via `helm show chart`, the command now includes any OCI-specific annotations (prefixed with 'org.opencontainers.image.') that exist in the chart metadata. Fixes #30787 Signed-off-by: Victor --- pkg/action/show.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/action/show.go b/pkg/action/show.go index a3fbcfa9e..3806b6b0b 100644 --- a/pkg/action/show.go +++ b/pkg/action/show.go @@ -95,6 +95,17 @@ func (s *Show) Run(chartpath string) (string, error) { var out strings.Builder if s.OutputFormat == ShowChart || s.OutputFormat == ShowAll { fmt.Fprintf(&out, "%s\n", cf) + + // Display OCI annotations if they exist + if s.chart.Metadata != nil && len(s.chart.Metadata.Annotations) > 0 { + fmt.Fprintln(&out, "---") + fmt.Fprintln(&out, "Annotations:") + for k, v := range s.chart.Metadata.Annotations { + if strings.HasPrefix(k, "org.opencontainers.image.") { + fmt.Fprintf(&out, " %s: %s\n", k, v) + } + } + } } if (s.OutputFormat == ShowValues || s.OutputFormat == ShowAll) && s.chart.Values != nil { From c65e0683fd5b2ca26d02ec25d0b740921c64d27c Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 9 Jun 2025 11:04:17 +0100 Subject: [PATCH 2/2] ShowOCI is now optional via a flag and expected output commented in Signed-off-by: Victor --- pkg/action/show.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/action/show.go b/pkg/action/show.go index 3806b6b0b..95a61bc39 100644 --- a/pkg/action/show.go +++ b/pkg/action/show.go @@ -60,6 +60,7 @@ type Show struct { Devel bool OutputFormat ShowOutputFormat JSONPathTemplate string + ShowOCI bool // Controls whether to display OCI annotations chart *chart.Chart // for testing } @@ -67,6 +68,7 @@ type Show struct { func NewShow(output ShowOutputFormat, cfg *Configuration) *Show { sh := &Show{ OutputFormat: output, + ShowOCI: false, // Default to not showing OCI annotations } sh.registryClient = cfg.RegistryClient @@ -96,10 +98,15 @@ func (s *Show) Run(chartpath string) (string, error) { if s.OutputFormat == ShowChart || s.OutputFormat == ShowAll { fmt.Fprintf(&out, "%s\n", cf) - // Display OCI annotations if they exist - if s.chart.Metadata != nil && len(s.chart.Metadata.Annotations) > 0 { + // Display OCI annotations only if enabled + // Example output when enabled: + // --- + // OCI Annotations: + // org.opencontainers.image.created: 2023-01-01T00:00:00Z + // org.opencontainers.image.description: Sample chart + if s.ShowOCI && s.chart.Metadata != nil && len(s.chart.Metadata.Annotations) > 0 { fmt.Fprintln(&out, "---") - fmt.Fprintln(&out, "Annotations:") + fmt.Fprintln(&out, "OCI Annotations:") for k, v := range s.chart.Metadata.Annotations { if strings.HasPrefix(k, "org.opencontainers.image.") { fmt.Fprintf(&out, " %s: %s\n", k, v)