Skip to content

Commit

Permalink
Merge pull request #5988 from medyagh/profile_status
Browse files Browse the repository at this point in the history
show status in profile list
  • Loading branch information
tstromberg authored Dec 9, 2019
2 parents 18e901a + 95717c4 commit 45c945f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
30 changes: 28 additions & 2 deletions cmd/minikube/cmd/config/profile_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ import (
"strconv"
"strings"

"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/machine"
"k8s.io/minikube/pkg/minikube/out"

"github.com/golang/glog"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -58,7 +61,7 @@ var printProfilesTable = func() {
var validData [][]string

table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Profile", "VM Driver", "NodeIP", "Node Port", "Kubernetes Version"})
table.SetHeader([]string{"Profile", "VM Driver", "NodeIP", "Node Port", "Kubernetes Version", "Status"})
table.SetAutoFormatHeaders(false)
table.SetBorders(tablewriter.Border{Left: true, Top: true, Right: true, Bottom: true})
table.SetCenterSeparator("|")
Expand All @@ -67,8 +70,18 @@ var printProfilesTable = func() {
if len(validProfiles) == 0 || err != nil {
exit.UsageT("No minikube profile was found. You can create one using `minikube start`.")
}
api, err := machine.NewAPIClient()
if err != nil {
glog.Infof("failed to get machine api client %v", err)
}
defer api.Close()

for _, p := range validProfiles {
validData = append(validData, []string{p.Name, p.Config[0].VMDriver, p.Config[0].KubernetesConfig.NodeIP, strconv.Itoa(p.Config[0].KubernetesConfig.NodePort), p.Config[0].KubernetesConfig.KubernetesVersion})
p.Status, err = cluster.GetHostStatus(api, p.Name)
if err != nil {
glog.Infof("error getting host status for %v", err)
}
validData = append(validData, []string{p.Name, p.Config[0].VMDriver, p.Config[0].KubernetesConfig.NodeIP, strconv.Itoa(p.Config[0].KubernetesConfig.NodePort), p.Config[0].KubernetesConfig.KubernetesVersion, p.Status})
}

table.AppendBulk(validData)
Expand All @@ -93,7 +106,20 @@ var printProfilesTable = func() {
}

var printProfilesJSON = func() {
api, err := machine.NewAPIClient()
if err != nil {
glog.Infof("failed to get machine api client %v", err)
}
defer api.Close()

validProfiles, invalidProfiles, err := config.ListProfiles()
for _, v := range validProfiles {
status, err := cluster.GetHostStatus(api, v.Name)
if err != nil {
glog.Infof("error getting host status for %v", err)
}
v.Status = status
}

var valid []*config.Profile
var invalid []*config.Profile
Expand Down
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ require (
github.com/docker/machine v0.7.1-0.20190718054102-a555e4f7a8f5 // version is 0.7.1 to pin to a555e4f7a8f5
github.com/elazarl/goproxy v0.0.0-20190421051319-9d40249d3c2f
github.com/elazarl/goproxy/ext v0.0.0-20190421051319-9d40249d3c2f // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/google/btree v1.0.0 // indirect
github.com/google/go-cmp v0.3.0
github.com/gorilla/mux v1.7.1 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.5.0 // indirect
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce // indirect
github.com/hashicorp/go-getter v1.4.0
github.com/hashicorp/go-multierror v0.0.0-20160811015721-8c5f0ad93604 // indirect
Expand Down
1 change: 1 addition & 0 deletions pkg/minikube/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
// Profile represents a minikube profile
type Profile struct {
Name string
Status string // running, stopped
Config []*MachineConfig
}

Expand Down

0 comments on commit 45c945f

Please sign in to comment.