From 8b5583930e0cf594068dfbce771d2c9e243ccd60 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Wed, 7 Apr 2021 14:09:25 +0300 Subject: [PATCH 1/2] Fix create source git auth for non-HTTPS repos Signed-off-by: Stefan Prodan --- cmd/flux/create_source_git.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/flux/create_source_git.go b/cmd/flux/create_source_git.go index c4b2fb18..8de87e92 100644 --- a/cmd/flux/create_source_git.go +++ b/cmd/flux/create_source_git.go @@ -240,6 +240,9 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error { secretOpts.Username = sourceGitArgs.username secretOpts.Password = sourceGitArgs.password secretOpts.CAFilePath = sourceGitArgs.caFile + case "http": + secretOpts.Username = sourceGitArgs.username + secretOpts.Password = sourceGitArgs.password } secret, err := sourcesecret.Generate(secretOpts) if err != nil { From 74feda73af5fbc4f2486d49a7f17851a7715b729 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Thu, 8 Apr 2021 10:48:27 +0300 Subject: [PATCH 2/2] Add Warningf to logger interface amd impl Signed-off-by: Stefan Prodan --- cmd/flux/create_source_git.go | 1 + cmd/flux/log.go | 4 ++++ pkg/log/log.go | 2 ++ 3 files changed, 7 insertions(+) diff --git a/cmd/flux/create_source_git.go b/cmd/flux/create_source_git.go index 8de87e92..b864132f 100644 --- a/cmd/flux/create_source_git.go +++ b/cmd/flux/create_source_git.go @@ -241,6 +241,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error { secretOpts.Password = sourceGitArgs.password secretOpts.CAFilePath = sourceGitArgs.caFile case "http": + logger.Warningf("insecure configuration: credentials configured for an HTTP URL") secretOpts.Username = sourceGitArgs.username secretOpts.Password = sourceGitArgs.password } diff --git a/cmd/flux/log.go b/cmd/flux/log.go index d8b25b22..8343fce7 100644 --- a/cmd/flux/log.go +++ b/cmd/flux/log.go @@ -41,6 +41,10 @@ func (l stderrLogger) Successf(format string, a ...interface{}) { fmt.Fprintln(l.stderr, `✔`, fmt.Sprintf(format, a...)) } +func (l stderrLogger) Warningf(format string, a ...interface{}) { + fmt.Fprintln(l.stderr, `⚠️`, fmt.Sprintf(format, a...)) +} + func (l stderrLogger) Failuref(format string, a ...interface{}) { fmt.Fprintln(l.stderr, `✗`, fmt.Sprintf(format, a...)) } diff --git a/pkg/log/log.go b/pkg/log/log.go index 2833e077..63b99a49 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -24,6 +24,8 @@ type Logger interface { Waitingf(format string, a ...interface{}) // Successf logs a formatted success message. Successf(format string, a ...interface{}) + // Warningf logs a formatted warning message. + Warningf(format string, a ...interface{}) // Failuref logs a formatted failure message. Failuref(format string, a ...interface{}) }