Skip to content

Commit

Permalink
Fix ready command
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Oct 3, 2022
1 parent 0aaae97 commit 3c61b1f
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions cmd/ready.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,31 @@ func MakeReady() *cobra.Command {
},
StreamStdio: false,
}

res, err := task.Execute()
if err != nil {
return err
}
// fmt.Println(res.Stdout, res.Stderr, res.ExitCode)

if res.ExitCode == 0 {
fmt.Printf("Cluster is ready\n")
return nil
}

if strings.Contains(res.Stderr, "context was not found") {
return fmt.Errorf("context %s not found in %s", contextName, kubeconfig)
}

parts := strings.Split(res.Stdout, " ")
ready := true
for _, part := range parts {
trimmed := strings.TrimSpace(part)
if len(trimmed) > 0 && trimmed != "True" {
ready = false
if res.ExitCode == 0 {
parts := strings.Split(res.Stdout, " ")
ready := true
for _, part := range parts {
trimmed := strings.TrimSpace(part)
if len(trimmed) > 0 && trimmed != "True" {
ready = false
}
}
}

if ready {
break
if ready {
fmt.Printf("Cluster is ready\n")
break
}
}
time.Sleep(pause)
}
Expand Down

0 comments on commit 3c61b1f

Please sign in to comment.