mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-24 16:41:47 +00:00
fix(cli): clarify tty err on non-tty git bootstrap
Fixes #5660 Signed-off-by: Carlos Nunez <13461447+carlosonunez@users.noreply.github.com>
This commit is contained in:
parent
6c58ea576e
commit
e3c98d6ab9
1 changed files with 6 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -38,6 +39,7 @@ import (
|
||||||
"github.com/fluxcd/flux2/v2/pkg/manifestgen/install"
|
"github.com/fluxcd/flux2/v2/pkg/manifestgen/install"
|
||||||
"github.com/fluxcd/flux2/v2/pkg/manifestgen/sourcesecret"
|
"github.com/fluxcd/flux2/v2/pkg/manifestgen/sourcesecret"
|
||||||
"github.com/fluxcd/flux2/v2/pkg/manifestgen/sync"
|
"github.com/fluxcd/flux2/v2/pkg/manifestgen/sync"
|
||||||
|
"github.com/mattn/go-isatty"
|
||||||
)
|
)
|
||||||
|
|
||||||
var bootstrapGitCmd = &cobra.Command{
|
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 {
|
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]
|
ppk, ok := secret.StringData[sourcesecret.PublicKeySecretKey]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -390,6 +393,9 @@ func promptPublicKey(ctx context.Context, secret corev1.Secret, _ sourcesecret.O
|
||||||
logger.Successf("public key: %s", strings.TrimSpace(ppk))
|
logger.Successf("public key: %s", strings.TrimSpace(ppk))
|
||||||
|
|
||||||
if !gitArgs.silent {
|
if !gitArgs.silent {
|
||||||
|
if !isatty.IsTerminal(os.Stdout.Fd()) {
|
||||||
|
return errors.New("aborting; not a terminal (use --silent)")
|
||||||
|
}
|
||||||
prompt := promptui.Prompt{
|
prompt := promptui.Prompt{
|
||||||
Label: "Please give the key access to your repository",
|
Label: "Please give the key access to your repository",
|
||||||
IsConfirm: true,
|
IsConfirm: true,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue