mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-16 12:41:49 +00:00
Add wait log
This commit is contained in:
parent
c6793f6eaf
commit
8d15970dbe
5 changed files with 34 additions and 28 deletions
|
|
@ -158,7 +158,7 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logAction("waiting for kustomization sync")
|
logWaiting("waiting for kustomization sync")
|
||||||
if err := wait.PollImmediate(2*time.Second, timeout,
|
if err := wait.PollImmediate(2*time.Second, timeout,
|
||||||
isKustomizationReady(ctx, kubeClient, name, namespace)); err != nil {
|
isKustomizationReady(ctx, kubeClient, name, namespace)); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logAction("waiting for git sync")
|
logWaiting("waiting for git sync")
|
||||||
if err := wait.PollImmediate(2*time.Second, timeout,
|
if err := wait.PollImmediate(2*time.Second, timeout,
|
||||||
isGitRepositoryReady(ctx, kubeClient, name, namespace)); err != nil {
|
isGitRepositoryReady(ctx, kubeClient, name, namespace)); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
logSuccess("build completed")
|
logSuccess("build completed")
|
||||||
|
|
||||||
logAction("installing components in %s namespace", namespace)
|
logWaiting("installing components in %s namespace", namespace)
|
||||||
applyOutput := ModeStderrOS
|
applyOutput := ModeStderrOS
|
||||||
if verbose {
|
if verbose {
|
||||||
applyOutput = ModeOS
|
applyOutput = ModeOS
|
||||||
|
|
@ -110,7 +110,7 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
logSuccess("install completed")
|
logSuccess("install completed")
|
||||||
}
|
}
|
||||||
|
|
||||||
logAction("verifying installation")
|
logWaiting("verifying installation")
|
||||||
for _, deployment := range components {
|
for _, deployment := range components {
|
||||||
command = fmt.Sprintf("kubectl -n %s rollout status deployment %s --timeout=%s",
|
command = fmt.Sprintf("kubectl -n %s rollout status deployment %s --timeout=%s",
|
||||||
namespace, deployment, timeout.String())
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -78,23 +77,14 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func homeDir() string {
|
func kubeconfigFlag() {
|
||||||
if h := os.Getenv("HOME"); h != "" {
|
if home := homeDir(); home != "" {
|
||||||
return h
|
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() {
|
func generateDocs() {
|
||||||
|
|
@ -110,12 +100,9 @@ func generateDocs() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func kubeconfigFlag() {
|
func homeDir() string {
|
||||||
if home := homeDir(); home != "" {
|
if h := os.Getenv("HOME"); h != "" {
|
||||||
rootCmd.PersistentFlags().StringVarP(&kubeconfig, "kubeconfig", "", filepath.Join(home, ".kube", "config"),
|
return h
|
||||||
"path to the kubeconfig file")
|
|
||||||
} else {
|
|
||||||
rootCmd.PersistentFlags().StringVarP(&kubeconfig, "kubeconfig", "", "",
|
|
||||||
"absolute path to the kubeconfig file")
|
|
||||||
}
|
}
|
||||||
|
return os.Getenv("USERPROFILE") // windows
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue