Skip to content

Commit

Permalink
feat(cli): display status message in table when running glasskube list
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshal101 authored and hanshal101 committed Jul 1, 2024
1 parent ba51ff1 commit b98fd11
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cmd/glasskube/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,22 @@ func handleEmptyList(resource string) {
}

func printClusterPackageTable(packages []*list.PackageWithStatus) {
header := []string{"NAME", "STATUS", "VERSION", "AUTO-UPDATE", "MESSAGE"}
header := []string{"NAME", "STATUS", "VERSION", "AUTO-UPDATE"}
if listCmdOptions.ShowLatestVersion {
header = append(header, "LATEST VERSION")
}
header = append(header, "REPOSITORY")
if listCmdOptions.ShowDescription {
header = append(header, "DESCRIPTION")
}
header = append(header, "MESSAGE")

err := cliutils.PrintTable(os.Stdout,
packages,
header,
func(pkg *list.PackageWithStatus) []string {
row := []string{pkg.Name, statusString(*pkg), versionString(*pkg),
clientutils.AutoUpdateString(pkg.ClusterPackage, ""), messageString(*pkg)}
clientutils.AutoUpdateString(pkg.ClusterPackage, "")}
if listCmdOptions.ShowLatestVersion {
row = append(row, pkg.LatestVersion)
}
Expand All @@ -163,6 +164,7 @@ func printClusterPackageTable(packages []*list.PackageWithStatus) {
if listCmdOptions.ShowDescription {
row = append(row, pkg.ShortDescription)
}
row = append(row, messageString(*pkg))
return row
})
if err != nil {
Expand All @@ -172,14 +174,15 @@ func printClusterPackageTable(packages []*list.PackageWithStatus) {
}

func printPackageTable(packages []*list.PackagesWithStatus) {
header := []string{"PACKAGENAME", "NAMESPACE", "NAME", "STATUS", "VERSION", "AUTO-UPDATE", "MESSAGE"}
header := []string{"PACKAGENAME", "NAMESPACE", "NAME", "STATUS", "VERSION", "AUTO-UPDATE"}
if listCmdOptions.ShowLatestVersion {
header = append(header, "LATEST VERSION")
}
header = append(header, "REPOSITORY")
if listCmdOptions.ShowDescription {
header = append(header, "DESCRIPTION")
}
header = append(header, "MESSAGE")

var flattenedPkgs []*list.PackageWithStatus
for _, pkgs := range packages {
Expand All @@ -197,7 +200,7 @@ func printPackageTable(packages []*list.PackagesWithStatus) {
header,
func(pkg *list.PackageWithStatus) []string {
row := []string{pkg.Name, pkgNamespaceString(*pkg), pkgNameString(*pkg), statusString(*pkg), versionString(*pkg),
clientutils.AutoUpdateString(pkg.Package, ""), messageString(*pkg)}
clientutils.AutoUpdateString(pkg.Package, "")}
if listCmdOptions.ShowLatestVersion {
row = append(row, pkg.LatestVersion)
}
Expand All @@ -217,6 +220,7 @@ func printPackageTable(packages []*list.PackagesWithStatus) {
if listCmdOptions.ShowDescription {
row = append(row, pkg.ShortDescription)
}
row = append(row, messageString(*pkg))
return row
})
if err != nil {
Expand Down

0 comments on commit b98fd11

Please sign in to comment.