Skip to content

Commit

Permalink
Updating minikube profile list cmd table representation
Browse files Browse the repository at this point in the history
Updated the command line output of minikube profile list -o table to have two columns, i.e. Active Profile and Active Kubecontext. This makes the output more intuitive. Formatting issues are fixed as well.
  • Loading branch information
Skalador committed Dec 23, 2023
1 parent d6d536c commit b4191e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions cmd/minikube/cmd/config/profile_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func profileStatus(p *config.Profile, api libmachine.API) string {

func renderProfilesTable(ps [][]string) {
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Profile", "VM Driver", "Runtime", "IP", "Port", "Version", "Status", "Nodes", "Active Kubecontext"})
table.SetHeader([]string{"Profile", "VM Driver", "Runtime", "IP", "Port", "Version", "Status", "Nodes", "Active Profile", "Active Kubecontext"})
table.SetAutoFormatHeaders(false)
table.SetBorders(tablewriter.Border{Left: true, Top: true, Right: true, Bottom: true})
table.SetCenterSeparator("|")
Expand All @@ -175,14 +175,14 @@ func profilesToTableData(profiles []*config.Profile) [][]string {
if k8sVersion == constants.NoKubernetesVersion { // for --no-kubernetes flag
k8sVersion = "N/A"
}
var c,k string
var c, k string
if p.Name == currentProfile {
c = "*"
}
if p.ActiveKubeContext {
k = "*"
}
data = append(data, []string{c+p.Name, p.Config.Driver, p.Config.KubernetesConfig.ContainerRuntime, cp.IP, strconv.Itoa(cp.Port), k8sVersion, p.Status, strconv.Itoa(len(p.Config.Nodes)), k})
data = append(data, []string{p.Name, p.Config.Driver, p.Config.KubernetesConfig.ContainerRuntime, cp.IP, strconv.Itoa(cp.Port), k8sVersion, p.Status, strconv.Itoa(len(p.Config.Nodes)), c, k})
}
return data
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/config/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/spf13/viper"
"k8s.io/klog/v2"
"k8s.io/minikube/pkg/drivers/kic/oci"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/minikube/kubeconfig"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/util/lock"
)

Expand Down
8 changes: 4 additions & 4 deletions pkg/minikube/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (

// Profile represents a minikube profile
type Profile struct {
Name string
Status string // running, stopped, paused, unknown
Config *ClusterConfig
Active bool
Name string
Status string // running, stopped, paused, unknown
Config *ClusterConfig
Active bool
ActiveKubeContext bool
}

Expand Down

0 comments on commit b4191e4

Please sign in to comment.