diff --git a/cmd/tk/create_kustomization.go b/cmd/tk/create_kustomization.go index a15166dab56b050266ed2f61a6c1098576396947..34ecd526c30763661e302952310679b45dde7dc1 100644 --- a/cmd/tk/create_kustomization.go +++ b/cmd/tk/create_kustomization.go @@ -161,7 +161,7 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error { } logWaiting("waiting for kustomization sync") - if err := wait.PollImmediate(2*time.Second, timeout, + if err := wait.PollImmediate(pollInterval, 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 6c0a409b48bd248a4ae92c8f0ae79de58f2d5597..b5953b2798d31679d570f4f32e6fbc8526f0ecd1 100644 --- a/cmd/tk/create_source_git.go +++ b/cmd/tk/create_source_git.go @@ -3,21 +3,19 @@ package main import ( "context" "fmt" - "io/ioutil" - "net/url" - "os" - "strings" - "time" - sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1" "github.com/manifoldco/promptui" "github.com/spf13/cobra" + "io/ioutil" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" + "net/url" + "os" "sigs.k8s.io/controller-runtime/pkg/client" + "strings" ) var createSourceGitCmd = &cobra.Command{ @@ -158,7 +156,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error { } logWaiting("waiting for git sync") - if err := wait.PollImmediate(2*time.Second, timeout, + if err := wait.PollImmediate(pollInterval, timeout, isGitRepositoryReady(ctx, kubeClient, name, namespace)); err != nil { return err } diff --git a/cmd/tk/main.go b/cmd/tk/main.go index 6fbee8029958729b2965c6dc07da80cb3db3c93e..afd97f655be91392bc1737588b34d623b425a504 100644 --- a/cmd/tk/main.go +++ b/cmd/tk/main.go @@ -50,12 +50,13 @@ var rootCmd = &cobra.Command{ } var ( - kubeconfig string - namespace string - timeout time.Duration - verbose bool - components []string - utils Utils + kubeconfig string + namespace string + timeout time.Duration + verbose bool + components []string + utils Utils + pollInterval = 2 * time.Second ) func init() { diff --git a/cmd/tk/sync_kustomization.go b/cmd/tk/sync_kustomization.go index 20ab29b16ab4e06fd7e35f3624ff0419efc008db..e1def0fa044dde9bebb25919dd8668cb14be3a96 100644 --- a/cmd/tk/sync_kustomization.go +++ b/cmd/tk/sync_kustomization.go @@ -82,7 +82,7 @@ func syncKsCmdRun(cmd *cobra.Command, args []string) error { } logWaiting("waiting for kustomization sync") - if err := wait.PollImmediate(2*time.Second, timeout, + if err := wait.PollImmediate(pollInterval, timeout, isKustomizationReady(ctx, kubeClient, name, namespace)); err != nil { return err } diff --git a/cmd/tk/sync_source_git.go b/cmd/tk/sync_source_git.go index b714f2bb217c85af8063447a3fcdb11d835c02ae..d9c7ffa0394913e5d57d23379a2fb21100fd8c33 100644 --- a/cmd/tk/sync_source_git.go +++ b/cmd/tk/sync_source_git.go @@ -64,7 +64,7 @@ func syncSourceGitCmdRun(cmd *cobra.Command, args []string) error { logSuccess("source annotated") logWaiting("waiting for git sync") - if err := wait.PollImmediate(2*time.Second, timeout, + if err := wait.PollImmediate(pollInterval, timeout, isGitRepositoryReady(ctx, kubeClient, name, namespace)); err != nil { return err }