diff --git a/flagd-proxy/cmd/root.go b/flagd-proxy/cmd/root.go index b39b1b66..f1824155 100644 --- a/flagd-proxy/cmd/root.go +++ b/flagd-proxy/cmd/root.go @@ -5,6 +5,8 @@ import ( "log" "os" + "github.com/dimiro1/banner" + "github.com/mattn/go-colorable" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -22,6 +24,21 @@ var rootCmd = &cobra.Command{ Short: "flagd-proxy allows flagd to subscribe to CRD changes without the required permissions.", Long: ``, DisableAutoGenTag: true, + PersistentPreRun: func(cmd *cobra.Command, args []string) { + if viper.GetString(logFormatFlagName) == "console" { + banner.InitString(colorable.NewColorableStdout(), true, true, ` + {{ .AnsiColor.BrightRed }} ______ __ ________ _______ ______ + {{ .AnsiColor.BrightRed }} /_____/\ /_/\ /_______/\ /______/\ /_____/\ + {{ .AnsiColor.BrightRed }} \::::_\/_\:\ \ \::: _ \ \\::::__\/__\:::_ \ \ + {{ .AnsiColor.BrightRed }} \:\/___/\\:\ \ \::(_) \ \\:\ /____/\\:\ \ \ \ + {{ .AnsiColor.BrightRed }} \:::._\/ \:\ \____\:: __ \ \\:\\_ _\/ \:\ \ \ \ + {{ .AnsiColor.BrightRed }} \:\ \ \:\/___/\\:.\ \ \ \\:\_\ \ \ \:\/.:| | + {{ .AnsiColor.BrightRed }} \_\/ \_____\/ \__\/\__\/ \_____\/ \____/_/ + {{ .AnsiColor.BrightRed }} Kubernetes Proxy +{{ .AnsiColor.Default }} +`) + } + }, } // Execute adds all child commands to the root command and sets flags appropriately. diff --git a/flagd-proxy/main.go b/flagd-proxy/main.go index 7f7e8c73..0605273c 100644 --- a/flagd-proxy/main.go +++ b/flagd-proxy/main.go @@ -1,32 +1,13 @@ package main -import ( - "bytes" - - "github.com/dimiro1/banner" - "github.com/mattn/go-colorable" - "github.com/open-feature/flagd/flagd-proxy/cmd" -) +import "github.com/open-feature/flagd/flagd-proxy/cmd" var ( - version = "dev" - commit = "HEAD" - date = "unknown" - bannerText = ` - {{ .AnsiColor.BrightRed }} ______ __ ________ _______ ______ - {{ .AnsiColor.BrightRed }} /_____/\ /_/\ /_______/\ /______/\ /_____/\ - {{ .AnsiColor.BrightRed }} \::::_\/_\:\ \ \::: _ \ \\::::__\/__\:::_ \ \ - {{ .AnsiColor.BrightRed }} \:\/___/\\:\ \ \::(_) \ \\:\ /____/\\:\ \ \ \ - {{ .AnsiColor.BrightRed }} \:::._\/ \:\ \____\:: __ \ \\:\\_ _\/ \:\ \ \ \ - {{ .AnsiColor.BrightRed }} \:\ \ \:\/___/\\:.\ \ \ \\:\_\ \ \ \:\/.:| | - {{ .AnsiColor.BrightRed }} \_\/ \_____\/ \__\/\__\/ \_____\/ \____/_/ - {{ .AnsiColor.BrightRed }} Kubernetes Proxy -{{ .AnsiColor.Default }} -` + version = "dev" + commit = "HEAD" + date = "unknown" ) func main() { - banner.Init(colorable.NewColorableStdout(), true, true, - bytes.NewBufferString(bannerText)) cmd.Execute(version, commit, date) } diff --git a/flagd/cmd/root.go b/flagd/cmd/root.go index a9128601..54464824 100644 --- a/flagd/cmd/root.go +++ b/flagd/cmd/root.go @@ -5,6 +5,8 @@ import ( "log" "os" + "github.com/dimiro1/banner" + "github.com/mattn/go-colorable" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -23,6 +25,20 @@ var rootCmd = &cobra.Command{ "It is designed to conform to Open Feature schema for flag definitions.", Long: ``, DisableAutoGenTag: true, + PersistentPreRun: func(cmd *cobra.Command, args []string) { + if viper.GetString(logFormatFlagName) == "console" { + banner.InitString(colorable.NewColorableStdout(), true, true, ` + {{ .AnsiColor.BrightRed }} ______ __ ________ _______ ______ + {{ .AnsiColor.BrightRed }} /_____/\ /_/\ /_______/\ /______/\ /_____/\ + {{ .AnsiColor.BrightRed }} \::::_\/_\:\ \ \::: _ \ \\::::__\/__\:::_ \ \ + {{ .AnsiColor.BrightRed }} \:\/___/\\:\ \ \::(_) \ \\:\ /____/\\:\ \ \ \ + {{ .AnsiColor.BrightRed }} \:::._\/ \:\ \____\:: __ \ \\:\\_ _\/ \:\ \ \ \ + {{ .AnsiColor.BrightRed }} \:\ \ \:\/___/\\:.\ \ \ \\:\_\ \ \ \:\/.:| | + {{ .AnsiColor.BrightRed }} \_\/ \_____\/ \__\/\__\/ \_____\/ \____/_/ +{{ .AnsiColor.Default }} +`) + } + }, // Uncomment the following line if your bare application // has an action associated with it: // Run: func(cmd *cobra.Command, args []string) { }, diff --git a/flagd/main.go b/flagd/main.go index 75d70b32..18e1a786 100644 --- a/flagd/main.go +++ b/flagd/main.go @@ -1,31 +1,13 @@ package main -import ( - "bytes" - - "github.com/dimiro1/banner" - "github.com/mattn/go-colorable" - "github.com/open-feature/flagd/flagd/cmd" -) +import "github.com/open-feature/flagd/flagd/cmd" var ( - version = "dev" - commit = "HEAD" - date = "unknown" - bannerText = ` - {{ .AnsiColor.BrightRed }} ______ __ ________ _______ ______ - {{ .AnsiColor.BrightRed }} /_____/\ /_/\ /_______/\ /______/\ /_____/\ - {{ .AnsiColor.BrightRed }} \::::_\/_\:\ \ \::: _ \ \\::::__\/__\:::_ \ \ - {{ .AnsiColor.BrightRed }} \:\/___/\\:\ \ \::(_) \ \\:\ /____/\\:\ \ \ \ - {{ .AnsiColor.BrightRed }} \:::._\/ \:\ \____\:: __ \ \\:\\_ _\/ \:\ \ \ \ - {{ .AnsiColor.BrightRed }} \:\ \ \:\/___/\\:.\ \ \ \\:\_\ \ \ \:\/.:| | - {{ .AnsiColor.BrightRed }} \_\/ \_____\/ \__\/\__\/ \_____\/ \____/_/ -{{ .AnsiColor.Default }} -` + version = "dev" + commit = "HEAD" + date = "unknown" ) func main() { - banner.Init(colorable.NewColorableStdout(), true, true, - bytes.NewBufferString(bannerText)) cmd.Execute(version, commit, date) }