From 13760258ab6022847e127f26effa02a458af92ea Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Sat, 25 Apr 2020 12:06:25 +0300 Subject: [PATCH] Add verbose option to create source --- cmd/tk/create_source.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/tk/create_source.go b/cmd/tk/create_source.go index c6226e0f..c3cb26cd 100644 --- a/cmd/tk/create_source.go +++ b/cmd/tk/create_source.go @@ -43,6 +43,7 @@ var ( sourceGitSemver string sourceUsername string sourcePassword string + sourceVerbose bool ) func init() { @@ -51,6 +52,8 @@ func init() { createSourceCmd.Flags().StringVar(&sourceGitSemver, "git-semver", "", "git tag semver range") createSourceCmd.Flags().StringVarP(&sourceUsername, "username", "u", "", "basic authentication username") createSourceCmd.Flags().StringVarP(&sourcePassword, "password", "p", "", "basic authentication password") + createSourceCmd.Flags().BoolVarP(&sourceVerbose, "verbose", "", false, "print generated source object") + createCmd.AddCommand(createSourceCmd) } @@ -121,7 +124,10 @@ func createSourceCmdRun(cmd *cobra.Command, args []string) error { if err := writer.Flush(); err != nil { return fmt.Errorf("source flush failed: %w", err) } - fmt.Print(data.String()) + + if sourceVerbose { + fmt.Print(data.String()) + } command := fmt.Sprintf("echo '%s' | kubectl apply -f-", data.String()) c := exec.Command("/bin/sh", "-c", command)