diff --git a/cmd/flux/bootstrap.go b/cmd/flux/bootstrap.go index fd53ddc05d02762ebdd9e32872ecac8a500db37a..ddfc2ff289ee65c8777f9d92a39dff5d0ec65545 100644 --- a/cmd/flux/bootstrap.go +++ b/cmd/flux/bootstrap.go @@ -267,7 +267,7 @@ func generateDeployKey(ctx context.Context, kubeClient client.Client, url *url.U return string(pair.PublicKey), nil } -func checkIfBootstrapPathDiffers(ctx context.Context, kubeClient client.Client, namespace string, path string) bool { +func checkIfBootstrapPathDiffers(ctx context.Context, kubeClient client.Client, namespace string, path string) (string, bool) { namespacedName := types.NamespacedName{ Name: namespace, Namespace: namespace, @@ -275,11 +275,11 @@ func checkIfBootstrapPathDiffers(ctx context.Context, kubeClient client.Client, var fluxSystemKustomization kustomizev1.Kustomization err := kubeClient.Get(ctx, namespacedName, &fluxSystemKustomization) if err != nil { - return false + return "", false } if fluxSystemKustomization.Spec.Path == path { - return false + return "", false } - return true + return fluxSystemKustomization.Spec.Path, true } diff --git a/cmd/flux/bootstrap_github.go b/cmd/flux/bootstrap_github.go index 2a12991dfa2045bfe41a0c404ce727ac98165cee..5c4158c2aa817260aadbef12606c95c294086d5b 100644 --- a/cmd/flux/bootstrap_github.go +++ b/cmd/flux/bootstrap_github.go @@ -123,10 +123,10 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error { return err } - bootstrapPathDiffers := checkIfBootstrapPathDiffers(ctx, kubeClient, namespace, filepath.ToSlash(ghPath.String())) + usedPath, bootstrapPathDiffers := checkIfBootstrapPathDiffers(ctx, kubeClient, namespace, filepath.ToSlash(ghPath.String())) if bootstrapPathDiffers { - return fmt.Errorf("cluster already bootstrapped to a different path") + return fmt.Errorf("cluster already bootstrapped to a %v path", usedPath) } repository, err := git.NewRepository(ghRepository, ghOwner, ghHostname, ghToken, "flux", ghOwner+"@users.noreply.github.com") diff --git a/cmd/flux/bootstrap_gitlab.go b/cmd/flux/bootstrap_gitlab.go index 6367746603f1a9a7387715cffac922f4558ce382..9bffa71aba7d250fe7da7ce66141ba434f2724cc 100644 --- a/cmd/flux/bootstrap_gitlab.go +++ b/cmd/flux/bootstrap_gitlab.go @@ -123,10 +123,10 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error { return err } - bootstrapPathDiffers := checkIfBootstrapPathDiffers(ctx, kubeClient, namespace, filepath.ToSlash(glPath.String())) + usedPath, bootstrapPathDiffers := checkIfBootstrapPathDiffers(ctx, kubeClient, namespace, filepath.ToSlash(glPath.String())) if bootstrapPathDiffers { - return fmt.Errorf("cluster already bootstrapped to a different path") + return fmt.Errorf("cluster already bootstrapped to a %v path", usedPath) } repository, err := git.NewRepository(glRepository, glOwner, glHostname, glToken, "flux", glOwner+"@users.noreply.gitlab.com")