addons list corrections
parent
b3a9d84d38
commit
81cf4096e6
|
|
@ -30,6 +30,7 @@ import (
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/minikube/pkg/minikube/assets"
|
"k8s.io/minikube/pkg/minikube/assets"
|
||||||
|
pkgcolor "k8s.io/minikube/pkg/minikube/color"
|
||||||
"k8s.io/minikube/pkg/minikube/config"
|
"k8s.io/minikube/pkg/minikube/config"
|
||||||
"k8s.io/minikube/pkg/minikube/exit"
|
"k8s.io/minikube/pkg/minikube/exit"
|
||||||
"k8s.io/minikube/pkg/minikube/mustload"
|
"k8s.io/minikube/pkg/minikube/mustload"
|
||||||
|
|
@ -94,28 +95,28 @@ var stringFromStatus = func(addonStatus bool) string {
|
||||||
var printAddonsList = func(cc *config.ClusterConfig, printDocs bool) {
|
var printAddonsList = func(cc *config.ClusterConfig, printDocs bool) {
|
||||||
addonNames := slices.Sorted(maps.Keys(assets.Addons))
|
addonNames := slices.Sorted(maps.Keys(assets.Addons))
|
||||||
table := tablewriter.NewWriter(os.Stdout)
|
table := tablewriter.NewWriter(os.Stdout)
|
||||||
table.Options(tablewriter.WithHeaderAutoFormat(tw.On))
|
table.Options(
|
||||||
|
tablewriter.WithHeaderAutoFormat(tw.On),
|
||||||
|
)
|
||||||
|
|
||||||
// Table header
|
// Table header
|
||||||
header := []string{"Addon Name", "Maintainer"}
|
theader := []string{"Addon Name", "Maintainer"}
|
||||||
if cc != nil {
|
if cc != nil {
|
||||||
header = []string{"Addon Name", "Enabled", "Maintainer"}
|
theader = []string{"Addon Name", "Enabled", "Maintainer"}
|
||||||
}
|
}
|
||||||
if printDocs {
|
if printDocs {
|
||||||
header = append(header, "Docs")
|
theader = append(theader, "Docs")
|
||||||
}
|
}
|
||||||
table.Header(header)
|
table.Header(theader)
|
||||||
|
|
||||||
var rows [][]string
|
var rows [][]string
|
||||||
|
|
||||||
for _, addonName := range addonNames {
|
for _, addonName := range addonNames {
|
||||||
addonBundle := assets.Addons[addonName]
|
addonBundle := assets.Addons[addonName]
|
||||||
|
|
||||||
maintainer := addonBundle.Maintainer
|
maintainer := addonBundle.Maintainer
|
||||||
if maintainer == "" {
|
if maintainer == "" {
|
||||||
maintainer = "3rd party (unknown)"
|
maintainer = "3rd party (unknown)"
|
||||||
}
|
}
|
||||||
|
|
||||||
docs := addonBundle.Docs
|
docs := addonBundle.Docs
|
||||||
if docs == "" {
|
if docs == "" {
|
||||||
docs = "n/a"
|
docs = "n/a"
|
||||||
|
|
@ -136,9 +137,9 @@ var printAddonsList = func(cc *config.ClusterConfig, printDocs bool) {
|
||||||
// Step 2: apply coloring
|
// Step 2: apply coloring
|
||||||
switch {
|
switch {
|
||||||
case enabled:
|
case enabled:
|
||||||
ColorRow(row, color.GreenString)
|
pkgcolor.ColorRow(row, color.GreenString)
|
||||||
default:
|
default:
|
||||||
ColorRow(row, color.WhiteString)
|
pkgcolor.ColorRow(row, color.WhiteString)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,26 +163,6 @@ var printAddonsList = func(cc *config.ClusterConfig, printDocs bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------
|
|
||||||
// Helpers
|
|
||||||
// ----------------
|
|
||||||
|
|
||||||
// colorFunc allows generic coloring
|
|
||||||
type colorFunc func(string, ...interface{}) string
|
|
||||||
|
|
||||||
func isEmoji(s string) bool {
|
|
||||||
return strings.Contains(s, "✅")
|
|
||||||
}
|
|
||||||
|
|
||||||
func ColorRow(row []string, colored colorFunc) {
|
|
||||||
for i := range row {
|
|
||||||
if row[i] == "" || isEmoji(row[i]) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
row[i] = colored("%s", row[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var printAddonsJSON = func(cc *config.ClusterConfig) {
|
var printAddonsJSON = func(cc *config.ClusterConfig) {
|
||||||
addonNames := slices.Sorted(maps.Keys(assets.Addons))
|
addonNames := slices.Sorted(maps.Keys(assets.Addons))
|
||||||
addonsMap := map[string]map[string]interface{}{}
|
addonsMap := map[string]map[string]interface{}{}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import (
|
||||||
"k8s.io/minikube/pkg/minikube/out"
|
"k8s.io/minikube/pkg/minikube/out"
|
||||||
"k8s.io/minikube/pkg/minikube/reason"
|
"k8s.io/minikube/pkg/minikube/reason"
|
||||||
"k8s.io/minikube/pkg/minikube/style"
|
"k8s.io/minikube/pkg/minikube/style"
|
||||||
|
pkgcolor "k8s.io/minikube/pkg/minikube/color"
|
||||||
|
|
||||||
"github.com/docker/machine/libmachine"
|
"github.com/docker/machine/libmachine"
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
|
|
@ -191,11 +192,11 @@ func profilesToTableData(profiles []*config.Profile) [][]string {
|
||||||
// Apply coloring based on status
|
// Apply coloring based on status
|
||||||
switch p.Status {
|
switch p.Status {
|
||||||
case "OK":
|
case "OK":
|
||||||
ColorRow(row, color.GreenString)
|
pkgcolor.ColorRow(row, color.GreenString)
|
||||||
case "Stopped", "Paused":
|
case "Stopped", "Paused":
|
||||||
ColorRow(row, color.YellowString)
|
pkgcolor.ColorRow(row, color.YellowString)
|
||||||
default:
|
default:
|
||||||
ColorRow(row, color.WhiteString)
|
pkgcolor.ColorRow(row, color.WhiteString)
|
||||||
}
|
}
|
||||||
|
|
||||||
data = append(data, row)
|
data = append(data, row)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package color
|
||||||
|
|
||||||
|
// colorFunc allows generic coloring
|
||||||
|
type colorFunc func(string, ...interface{}) string
|
||||||
|
|
||||||
|
func isEmoji(s string) bool {
|
||||||
|
if s == "✅" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func ColorRow(row []string, colored colorFunc) {
|
||||||
|
for i := range row {
|
||||||
|
if row[i] == "" || isEmoji(row[i]) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
row[i] = colored("%s", row[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue