From 371e222928b2cbb8d60165f25a823931daf1b879 Mon Sep 17 00:00:00 2001 From: Premkumar Bhaskal Date: Tue, 6 Feb 2024 13:58:22 +0530 Subject: [PATCH] adding new column message in kctrl pkg installed list command Signed-off-by: Premkumar Bhaskal --- cli/pkg/kctrl/cmd/package/installed/list.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cli/pkg/kctrl/cmd/package/installed/list.go b/cli/pkg/kctrl/cmd/package/installed/list.go index b04727d7bb..a16768d9bc 100644 --- a/cli/pkg/kctrl/cmd/package/installed/list.go +++ b/cli/pkg/kctrl/cmd/package/installed/list.go @@ -12,6 +12,7 @@ import ( "github.com/spf13/cobra" cmdcore "github.com/vmware-tanzu/carvel-kapp-controller/cli/pkg/kctrl/cmd/core" "github.com/vmware-tanzu/carvel-kapp-controller/cli/pkg/kctrl/logger" + kcpkgv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/packaging/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -83,6 +84,7 @@ func (o *ListOptions) Run() error { uitable.NewHeader("Package Name"), uitable.NewHeader("Package Version"), uitable.NewHeader("Status"), + uitable.NewHeader("Message"), }, SortBy: []uitable.ColumnSort{ @@ -99,6 +101,7 @@ func (o *ListOptions) Run() error { uitable.NewValueString(pkgi.Spec.PackageRef.RefName), uitable.NewValueString(pkgi.Status.Version), uitable.ValueFmt{V: uitable.NewValueString(status), Error: isFailing}, + uitable.NewValueString(o.getPkgiStatusMessage(&pkgi)), }) } @@ -106,3 +109,12 @@ func (o *ListOptions) Run() error { return nil } + +func (o *ListOptions) getPkgiStatusMessage(pkgi *kcpkgv1alpha1.PackageInstall) string { + conditionsLen := len(pkgi.Status.Conditions) + if conditionsLen == 0 { + return "" + } + lastCondition := pkgi.Status.Conditions[conditionsLen-1] + return lastCondition.Message +}