refactor: move color package to internal/cli/output

Signed-off-by: Mohammadreza Asadollahifard <mazafard@gmail.com>
pull/31034/head
Mohammadreza Asadollahifard 2 months ago
parent b72db06c49
commit ba8f70ae0b
No known key found for this signature in database
GPG Key ID: 89C260092433E3CC

@ -28,6 +28,7 @@ import (
"helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/action"
"helm.sh/helm/v4/pkg/cli/output" "helm.sh/helm/v4/pkg/cli/output"
coloroutput "helm.sh/helm/v4/internal/cli/output"
"helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/cmd/require"
release "helm.sh/helm/v4/pkg/release/v1" release "helm.sh/helm/v4/pkg/release/v1"
) )
@ -181,13 +182,13 @@ func (w *releaseListWriter) WriteTable(out io.Writer) error {
table := uitable.New() table := uitable.New()
if !w.noHeaders { if !w.noHeaders {
table.AddRow( table.AddRow(
output.ColorizeHeader("NAME", w.noColor), coloroutput.ColorizeHeader("NAME", w.noColor),
output.ColorizeHeader("NAMESPACE", w.noColor), coloroutput.ColorizeHeader("NAMESPACE", w.noColor),
output.ColorizeHeader("REVISION", w.noColor), coloroutput.ColorizeHeader("REVISION", w.noColor),
output.ColorizeHeader("UPDATED", w.noColor), coloroutput.ColorizeHeader("UPDATED", w.noColor),
output.ColorizeHeader("STATUS", w.noColor), coloroutput.ColorizeHeader("STATUS", w.noColor),
output.ColorizeHeader("CHART", w.noColor), coloroutput.ColorizeHeader("CHART", w.noColor),
output.ColorizeHeader("APP VERSION", w.noColor), coloroutput.ColorizeHeader("APP VERSION", w.noColor),
) )
} }
for _, r := range w.releases { for _, r := range w.releases {
@ -215,7 +216,7 @@ func (w *releaseListWriter) WriteTable(out io.Writer) error {
default: default:
status = release.Status(r.Status) status = release.Status(r.Status)
} }
table.AddRow(r.Name, output.ColorizeNamespace(r.Namespace, w.noColor), r.Revision, r.Updated, output.ColorizeStatus(status, w.noColor), r.Chart, r.AppVersion) table.AddRow(r.Name, coloroutput.ColorizeNamespace(r.Namespace, w.noColor), r.Revision, r.Updated, coloroutput.ColorizeStatus(status, w.noColor), r.Chart, r.AppVersion)
} }
return output.EncodeTable(out, table) return output.EncodeTable(out, table)
} }

@ -31,6 +31,7 @@ import (
"helm.sh/helm/v4/pkg/action" "helm.sh/helm/v4/pkg/action"
chartutil "helm.sh/helm/v4/pkg/chart/v2/util" chartutil "helm.sh/helm/v4/pkg/chart/v2/util"
"helm.sh/helm/v4/pkg/cli/output" "helm.sh/helm/v4/pkg/cli/output"
coloroutput "helm.sh/helm/v4/internal/cli/output"
"helm.sh/helm/v4/pkg/cmd/require" "helm.sh/helm/v4/pkg/cmd/require"
release "helm.sh/helm/v4/pkg/release/v1" release "helm.sh/helm/v4/pkg/release/v1"
) )
@ -132,8 +133,8 @@ func (s statusPrinter) WriteTable(out io.Writer) error {
if !s.release.Info.LastDeployed.IsZero() { if !s.release.Info.LastDeployed.IsZero() {
_, _ = fmt.Fprintf(out, "LAST DEPLOYED: %s\n", s.release.Info.LastDeployed.Format(time.ANSIC)) _, _ = fmt.Fprintf(out, "LAST DEPLOYED: %s\n", s.release.Info.LastDeployed.Format(time.ANSIC))
} }
_, _ = fmt.Fprintf(out, "NAMESPACE: %s\n", output.ColorizeNamespace(s.release.Namespace, s.noColor)) _, _ = fmt.Fprintf(out, "NAMESPACE: %s\n", coloroutput.ColorizeNamespace(s.release.Namespace, s.noColor))
_, _ = fmt.Fprintf(out, "STATUS: %s\n", output.ColorizeStatus(s.release.Info.Status, s.noColor)) _, _ = fmt.Fprintf(out, "STATUS: %s\n", coloroutput.ColorizeStatus(s.release.Info.Status, s.noColor))
_, _ = fmt.Fprintf(out, "REVISION: %d\n", s.release.Version) _, _ = fmt.Fprintf(out, "REVISION: %d\n", s.release.Version)
if s.showMetadata { if s.showMetadata {
_, _ = fmt.Fprintf(out, "CHART: %s\n", s.release.Chart.Metadata.Name) _, _ = fmt.Fprintf(out, "CHART: %s\n", s.release.Chart.Metadata.Name)

Loading…
Cancel
Save