Add wait log
This commit is contained in:
@@ -158,7 +158,7 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
logAction("waiting for kustomization sync")
|
||||
logWaiting("waiting for kustomization sync")
|
||||
if err := wait.PollImmediate(2*time.Second, timeout,
|
||||
isKustomizationReady(ctx, kubeClient, name, namespace)); err != nil {
|
||||
return err
|
||||
|
||||
@@ -152,7 +152,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
logAction("waiting for git sync")
|
||||
logWaiting("waiting for git sync")
|
||||
if err := wait.PollImmediate(2*time.Second, timeout,
|
||||
isGitRepositoryReady(ctx, kubeClient, name, namespace)); err != nil {
|
||||
return err
|
||||
|
||||
@@ -88,7 +88,7 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
logSuccess("build completed")
|
||||
|
||||
logAction("installing components in %s namespace", namespace)
|
||||
logWaiting("installing components in %s namespace", namespace)
|
||||
applyOutput := ModeStderrOS
|
||||
if verbose {
|
||||
applyOutput = ModeOS
|
||||
@@ -110,7 +110,7 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
||||
logSuccess("install completed")
|
||||
}
|
||||
|
||||
logAction("verifying installation")
|
||||
logWaiting("verifying installation")
|
||||
for _, deployment := range components {
|
||||
command = fmt.Sprintf("kubectl -n %s rollout status deployment %s --timeout=%s",
|
||||
namespace, deployment, timeout.String())
|
||||
|
||||
19
cmd/tk/log.go
Normal file
19
cmd/tk/log.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func logAction(format string, a ...interface{}) {
|
||||
fmt.Println(`✚`, fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
func logWaiting(format string, a ...interface{}) {
|
||||
fmt.Println(`◎`, fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
func logSuccess(format string, a ...interface{}) {
|
||||
fmt.Println(`✔`, fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
func logFailure(format string, a ...interface{}) {
|
||||
fmt.Println(`✗`, fmt.Sprintf(format, a...))
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -78,23 +77,14 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
func homeDir() string {
|
||||
if h := os.Getenv("HOME"); h != "" {
|
||||
return h
|
||||
func kubeconfigFlag() {
|
||||
if home := homeDir(); home != "" {
|
||||
rootCmd.PersistentFlags().StringVarP(&kubeconfig, "kubeconfig", "", filepath.Join(home, ".kube", "config"),
|
||||
"path to the kubeconfig file")
|
||||
} else {
|
||||
rootCmd.PersistentFlags().StringVarP(&kubeconfig, "kubeconfig", "", "",
|
||||
"absolute path to the kubeconfig file")
|
||||
}
|
||||
return os.Getenv("USERPROFILE") // windows
|
||||
}
|
||||
|
||||
func logAction(format string, a ...interface{}) {
|
||||
fmt.Println(`✚`, fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
func logSuccess(format string, a ...interface{}) {
|
||||
fmt.Println(`✔`, fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
func logFailure(format string, a ...interface{}) {
|
||||
fmt.Println(`✗`, fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
func generateDocs() {
|
||||
@@ -110,12 +100,9 @@ func generateDocs() {
|
||||
}
|
||||
}
|
||||
|
||||
func kubeconfigFlag() {
|
||||
if home := homeDir(); home != "" {
|
||||
rootCmd.PersistentFlags().StringVarP(&kubeconfig, "kubeconfig", "", filepath.Join(home, ".kube", "config"),
|
||||
"path to the kubeconfig file")
|
||||
} else {
|
||||
rootCmd.PersistentFlags().StringVarP(&kubeconfig, "kubeconfig", "", "",
|
||||
"absolute path to the kubeconfig file")
|
||||
func homeDir() string {
|
||||
if h := os.Getenv("HOME"); h != "" {
|
||||
return h
|
||||
}
|
||||
return os.Getenv("USERPROFILE") // windows
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user