diff --git a/cmd/tk/create_kustomization.go b/cmd/tk/create_kustomization.go index 87011d1a..54e6c5b2 100644 --- a/cmd/tk/create_kustomization.go +++ b/cmd/tk/create_kustomization.go @@ -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 diff --git a/cmd/tk/create_source_git.go b/cmd/tk/create_source_git.go index 3dc1acb1..245c4d99 100644 --- a/cmd/tk/create_source_git.go +++ b/cmd/tk/create_source_git.go @@ -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 diff --git a/cmd/tk/install.go b/cmd/tk/install.go index 256e264b..04a093b2 100644 --- a/cmd/tk/install.go +++ b/cmd/tk/install.go @@ -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()) diff --git a/cmd/tk/log.go b/cmd/tk/log.go new file mode 100644 index 00000000..c06f3b59 --- /dev/null +++ b/cmd/tk/log.go @@ -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...)) +} diff --git a/cmd/tk/main.go b/cmd/tk/main.go index 17660b77..b113fee9 100644 --- a/cmd/tk/main.go +++ b/cmd/tk/main.go @@ -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 }