diff --git a/cmd/create.go b/cmd/create.go index bcc8020a5..c985f67b6 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -165,7 +165,7 @@ to quickly create a Cobra application.`, httpClient := http.Client{Transport: customTransport} // retry to sync ArgoCD application until reaches the maximum attempts - argoCDIsReady, err := argocd.SyncRetry(&httpClient, 10, 6, "registry", token) + argoCDIsReady, err := argocd.SyncRetry(&httpClient, 60, 5, "registry", token) if err != nil { log.Printf("something went wrong during ArgoCD sync step, error is: %v", err) } @@ -368,7 +368,25 @@ to quickly create a Cobra application.`, informUser("Syncing the registry application") token := argocd.GetArgocdAuthToken(dryRun) - argocd.SyncArgocdApplication(dryRun, "registry", token) + + if dryRun { + log.Printf("[#99] Dry-run mode, Sync ArgoCD skipped") + } else { + // todo: create ArgoCD struct, and host dependencies (like http client) + customTransport := http.DefaultTransport.(*http.Transport).Clone() + customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + httpClient := http.Client{Transport: customTransport} + + // retry to sync ArgoCD application until reaches the maximum attempts + argoCDIsReady, err := argocd.SyncRetry(&httpClient, 60, 5, "registry", token) + if err != nil { + log.Printf("something went wrong during ArgoCD sync step, error is: %v", err) + } + + if !argoCDIsReady { + log.Println("unable to sync ArgoCD application, continuing...") + } + } viper.Set("gitlab.registered", true) viper.WriteConfig() diff --git a/internal/argocd/argocd.go b/internal/argocd/argocd.go index 6770b2075..4b0f38b27 100644 --- a/internal/argocd/argocd.go +++ b/internal/argocd/argocd.go @@ -55,7 +55,9 @@ func SyncRetry(httpClient pkg.HTTPDoer, attempts int, interval int, applicationN } log.Printf( - "sleeping %d seconds before trying to ArgoCD sync again, last Sync status is: %q", + "(%d/%d) sleeping %d seconds before trying to ArgoCD sync again, last Sync status is: %q", + i+1, + attempts, interval, syncStatus, )