Log to stderr
This commit refactors the `printLogger` into a `stderrLogger` that properly logs to `os.stderr` instead of `os.stdout`. Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit is contained in:
@@ -187,13 +187,13 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
if sourceGitSecretRef != "" {
|
if sourceGitSecretRef != "" {
|
||||||
withAuth = true
|
withAuth = true
|
||||||
} else if u.Scheme == "ssh" {
|
} else if u.Scheme == "ssh" {
|
||||||
logger.Actionf("generating deploy key pair")
|
logger.Generatef("generating deploy key pair")
|
||||||
pair, err := generateKeyPair(ctx)
|
pair, err := generateKeyPair(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("%s", pair.PublicKey)
|
logger.Successf("deploy key: %s", pair.PublicKey)
|
||||||
prompt := promptui.Prompt{
|
prompt := promptui.Prompt{
|
||||||
Label: "Have you added the deploy key to your repository",
|
Label: "Have you added the deploy key to your repository",
|
||||||
IsConfirm: true,
|
IsConfirm: true,
|
||||||
@@ -207,8 +207,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logger.Successf("collected public key from SSH server:")
|
logger.Successf("collected public key from SSH server:\n%s", hostKey)
|
||||||
fmt.Printf("%s", hostKey)
|
|
||||||
|
|
||||||
logger.Actionf("applying secret with keys")
|
logger.Actionf("applying secret with keys")
|
||||||
secret := corev1.Secret{
|
secret := corev1.Secret{
|
||||||
|
|||||||
@@ -16,26 +16,31 @@ limitations under the License.
|
|||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
type printLogger struct{}
|
type stderrLogger struct {
|
||||||
|
stderr io.Writer
|
||||||
func (l printLogger) Actionf(format string, a ...interface{}) {
|
|
||||||
fmt.Println(`►`, fmt.Sprintf(format, a...))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l printLogger) Generatef(format string, a ...interface{}) {
|
func (l stderrLogger) Actionf(format string, a ...interface{}) {
|
||||||
fmt.Println(`✚`, fmt.Sprintf(format, a...))
|
fmt.Fprintln(l.stderr, `►`, fmt.Sprintf(format, a...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l printLogger) Waitingf(format string, a ...interface{}) {
|
func (l stderrLogger) Generatef(format string, a ...interface{}) {
|
||||||
fmt.Println(`◎`, fmt.Sprintf(format, a...))
|
fmt.Fprintln(l.stderr, `✚`, fmt.Sprintf(format, a...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l printLogger) Successf(format string, a ...interface{}) {
|
func (l stderrLogger) Waitingf(format string, a ...interface{}) {
|
||||||
fmt.Println(`✔`, fmt.Sprintf(format, a...))
|
fmt.Fprintln(l.stderr, `◎`, fmt.Sprintf(format, a...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l printLogger) Failuref(format string, a ...interface{}) {
|
func (l stderrLogger) Successf(format string, a ...interface{}) {
|
||||||
fmt.Println(`✗`, fmt.Sprintf(format, a...))
|
fmt.Fprintln(l.stderr, `✔`, fmt.Sprintf(format, a...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l stderrLogger) Failuref(format string, a ...interface{}) {
|
||||||
|
fmt.Fprintln(l.stderr, `✗`, fmt.Sprintf(format, a...))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ var (
|
|||||||
timeout time.Duration
|
timeout time.Duration
|
||||||
verbose bool
|
verbose bool
|
||||||
pollInterval = 2 * time.Second
|
pollInterval = 2 * time.Second
|
||||||
logger fluxlog.Logger = printLogger{}
|
logger fluxlog.Logger = stderrLogger{stderr: os.Stderr}
|
||||||
defaults = install.MakeDefaultOptions()
|
defaults = install.MakeDefaultOptions()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user