1
0
mirror of synced 2026-02-06 19:05:55 +00:00

Add wait log

This commit is contained in:
stefanprodan
2020-04-29 08:25:12 +03:00
parent c6793f6eaf
commit 8d15970dbe
5 changed files with 34 additions and 28 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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
View 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...))
}

View File

@@ -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
}