Skip to content

Commit 3422ef1

Browse files
committed
Add configuration option to disable container logging
Signed-off-by: Nick Hudson <[email protected]>
1 parent f554590 commit 3422ef1

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

pkg/chart/chart.go

+16-14
Original file line numberDiff line numberDiff line change
@@ -901,22 +901,24 @@ func (t *Testing) PrintEventsPodDetailsAndLogs(namespace string, selector string
901901
return
902902
}
903903

904-
printDetails(pod, "Logs of init container", "-",
905-
func(item string) error {
906-
return t.kubectl.Logs(namespace, pod, item)
907-
}, initContainers...)
904+
if t.config.PrintLogs {
905+
printDetails(pod, "Logs of init container", "-",
906+
func(item string) error {
907+
return t.kubectl.Logs(namespace, pod, item)
908+
}, initContainers...)
908909

909-
containers, err := t.kubectl.GetContainers(namespace, pod)
910-
if err != nil {
911-
fmt.Printf("failed printing logs: %v\n", err.Error())
912-
return
913-
}
910+
containers, err := t.kubectl.GetContainers(namespace, pod)
911+
if err != nil {
912+
fmt.Printf("failed printing logs: %v\n", err.Error())
913+
return
914+
}
914915

915-
printDetails(pod, "Logs of container", "-",
916-
func(item string) error {
917-
return t.kubectl.Logs(namespace, pod, item)
918-
},
919-
containers...)
916+
printDetails(pod, "Logs of container", "-",
917+
func(item string) error {
918+
return t.kubectl.Logs(namespace, pod, item)
919+
},
920+
containers...)
921+
}
920922
}
921923

922924
util.PrintDelimiterLineToWriter(os.Stdout, "=")

pkg/config/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@ type Configuration struct {
6868
ReleaseLabel string `mapstructure:"release-label"`
6969
ExcludeDeprecated bool `mapstructure:"exclude-deprecated"`
7070
KubectlTimeout time.Duration `mapstructure:"kubectl-timeout"`
71+
PrintLogs bool `mapstructure:"print-logs"`
7172
}
7273

7374
func LoadConfiguration(cfgFile string, cmd *cobra.Command, printConfig bool) (*Configuration, error) {
7475
v := viper.New()
7576

7677
v.SetDefault("kubectl-timeout", 30*time.Second)
78+
v.SetDefault("print-logs", bool(true))
7779

7880
cmd.Flags().VisitAll(func(flag *flag.Flag) {
7981
flagName := flag.Name

0 commit comments

Comments
 (0)