Skip to content

Commit e39e84c

Browse files
Update pkg/minikube/cluster/status.go
Co-authored-by: Steven Powell <[email protected]>
1 parent 06b019f commit e39e84c

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

Diff for: cmd/minikube/cmd/config/profile_list.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func profileStatus(p *config.Profile, api libmachine.API) string {
118118
klog.Errorf("error getting statuses: %v", err)
119119
return "Unknown"
120120
}
121-
clusterStatus := cluster.GetClusterState(statuses, ClusterFlagValue(), p.Config)
121+
clusterStatus := cluster.GetState(statuses, ClusterFlagValue(), p.Config)
122122

123123
return clusterStatus.StatusName
124124
}

Diff for: cmd/minikube/cmd/status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func statusJSON(st []*cluster.Status, w io.Writer) error {
233233
}
234234

235235
func clusterStatusJSON(statuses []*cluster.Status, w io.Writer, cc *config.ClusterConfig) error {
236-
cs := cluster.GetClusterState(statuses, ClusterFlagValue(), cc)
236+
cs := cluster.GetState(statuses, ClusterFlagValue(), cc)
237237

238238
bs, err := json.Marshal(cs)
239239
if err != nil {

Diff for: pkg/minikube/cluster/status.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ type Status struct {
130130
PodManEnv string `json:",omitempty"`
131131
}
132132

133-
// ClusterState holds a cluster state representation
133+
// State holds a cluster state representation
134134
//
135135
//nolint:revive
136-
type ClusterState struct {
136+
type State struct {
137137
BaseState
138138

139139
BinaryVersion string
@@ -166,6 +166,7 @@ type BaseState struct {
166166
StepDetail string `json:",omitempty"`
167167
}
168168

169+
// GetStatus returns the statuses of each node
169170
func GetStatus(api libmachine.API, cc *config.ClusterConfig) ([]*Status, error) {
170171
var statuses []*Status
171172
for _, n := range cc.Nodes {
@@ -188,17 +189,20 @@ func GetStatus(api libmachine.API, cc *config.ClusterConfig) ([]*Status, error)
188189
return statuses, nil
189190
}
190191

191-
// clusterState converts Status structs into a ClusterState struct
192+
// GetState converts Status structs into a State struct
192193
//
193194
//nolint:gocyclo
194-
func GetClusterState(sts []*Status, profile string, cc *config.ClusterConfig) ClusterState {
195-
statusName := sts[0].APIServer
196-
if sts[0].Host == codeNames[InsufficientStorage] {
197-
statusName = sts[0].Host
195+
func GetState(sts []*Status, profile string, cc *config.ClusterConfig) State {
196+
statusName := ""
197+
if len(sts) > 0 {
198+
statusName = sts[0].APIServer
199+
if sts[0].Host == codeNames[InsufficientStorage] {
200+
statusName = sts[0].Host
201+
}
198202
}
199203
sc := statusCode(statusName)
200204

201-
cs := ClusterState{
205+
cs := State{
202206
BinaryVersion: version.GetVersion(),
203207

204208
BaseState: BaseState{
@@ -344,7 +348,7 @@ func GetClusterState(sts []*Status, profile string, cc *config.ClusterConfig) Cl
344348
return cs
345349
}
346350

347-
// nodeStatus looks up the status of a node
351+
// NodeStatus looks up the status of a node
348352
func NodeStatus(api libmachine.API, cc config.ClusterConfig, n config.Node) (*Status, error) {
349353
controlPlane := n.ControlPlane
350354
name := config.MachineName(cc, n)

Diff for: test/integration/pause_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func validateStatus(ctx context.Context, t *testing.T, profile string) {
191191
defer PostMortemLogs(t, profile)
192192

193193
statusOutput := runStatusCmd(ctx, t, profile, false)
194-
var cs cluster.ClusterState
194+
var cs cluster.State
195195
if err := json.Unmarshal(statusOutput, &cs); err != nil {
196196
t.Fatalf("unmarshalling: %v", err)
197197
}

Diff for: test/integration/status_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func runStatusCmd(ctx context.Context, t *testing.T, profile string, increaseEnv
8282
}
8383

8484
func verifyClusterState(t *testing.T, contents []byte) {
85-
var cs cluster.ClusterState
85+
var cs cluster.State
8686
if err := json.Unmarshal(contents, &cs); err != nil {
8787
t.Fatalf("unmarshalling: %v", err)
8888
}

0 commit comments

Comments
 (0)