From e3c98d6ab916ee96cc3b7ed27dba355a92b4b4c5 Mon Sep 17 00:00:00 2001 From: Carlos Nunez <13461447+carlosonunez@users.noreply.github.com> Date: Tue, 16 Dec 2025 13:02:46 -0600 Subject: [PATCH 1/2] fix(cli): clarify tty err on non-tty git bootstrap Fixes #5660 Signed-off-by: Carlos Nunez <13461447+carlosonunez@users.noreply.github.com> --- cmd/flux/bootstrap_git.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/flux/bootstrap_git.go b/cmd/flux/bootstrap_git.go index 494e1fd3..c71338ac 100644 --- a/cmd/flux/bootstrap_git.go +++ b/cmd/flux/bootstrap_git.go @@ -18,6 +18,7 @@ package main import ( "context" + "errors" "fmt" "net/url" "os" @@ -38,6 +39,7 @@ import ( "github.com/fluxcd/flux2/v2/pkg/manifestgen/install" "github.com/fluxcd/flux2/v2/pkg/manifestgen/sourcesecret" "github.com/fluxcd/flux2/v2/pkg/manifestgen/sync" + "github.com/mattn/go-isatty" ) var bootstrapGitCmd = &cobra.Command{ @@ -382,6 +384,7 @@ func getAuthOpts(u *url.URL, caBundle []byte) (*git.AuthOptions, error) { } func promptPublicKey(ctx context.Context, secret corev1.Secret, _ sourcesecret.Options) error { + logger.Actionf("requesting to grant key access to repository") ppk, ok := secret.StringData[sourcesecret.PublicKeySecretKey] if !ok { return nil @@ -390,6 +393,9 @@ func promptPublicKey(ctx context.Context, secret corev1.Secret, _ sourcesecret.O logger.Successf("public key: %s", strings.TrimSpace(ppk)) if !gitArgs.silent { + if !isatty.IsTerminal(os.Stdout.Fd()) { + return errors.New("aborting; not a terminal (use --silent)") + } prompt := promptui.Prompt{ Label: "Please give the key access to your repository", IsConfirm: true, From 3e8ae9236f14423921c5ed7fb959fecc2207e3ab Mon Sep 17 00:00:00 2001 From: Carlos Nunez <13461447+carlosonunez@users.noreply.github.com> Date: Tue, 16 Dec 2025 16:42:44 -0600 Subject: [PATCH 2/2] fixup! fix(cli): clarify tty err on non-tty git bootstrap --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3710f080..aa8e2e65 100644 --- a/go.mod +++ b/go.mod @@ -44,6 +44,7 @@ require ( github.com/homeport/dyff v1.10.2 github.com/lucasb-eyer/go-colorful v1.2.0 github.com/manifoldco/promptui v0.9.0 + github.com/mattn/go-isatty v0.0.20 github.com/mattn/go-shellwords v1.0.12 github.com/notaryproject/notation-go v1.3.2 github.com/olekukonko/tablewriter v0.0.5 @@ -179,7 +180,6 @@ require ( github.com/mailru/easyjson v0.9.0 // indirect github.com/mattn/go-ciede2000 v0.0.0-20170301095244-782e8c62fec3 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect