Skip to content

Commit db43a6b

Browse files
committed
Add config option to disable printing of container logs
1 parent 1d3feac commit db43a6b

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

pkg/chart/chart.go

+17-13
Original file line numberDiff line numberDiff line change
@@ -902,22 +902,26 @@ func (t *Testing) PrintEventsPodDetailsAndLogs(namespace string, selector string
902902
return
903903
}
904904

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

910-
containers, err := t.kubectl.GetContainers(namespace, pod)
911-
if err != nil {
912-
fmt.Println("Error printing logs:", err)
913-
return
911+
containers, err := t.kubectl.GetContainers(namespace, pod)
912+
if err != nil {
913+
fmt.Println("Error printing logs:", err)
914+
return
915+
}
914916
}
915917

916-
printDetails(pod, "Logs of container", "-",
917-
func(item string) error {
918-
return t.kubectl.Logs(namespace, pod, item)
919-
},
920-
containers...)
918+
if t.config.PrintLogs {
919+
printDetails(pod, "Logs of container", "-",
920+
func(item string) error {
921+
return t.kubectl.Logs(namespace, pod, item)
922+
},
923+
containers...)
924+
}
921925
}
922926

923927
util.PrintDelimiterLine("=")

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", time.Duration(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)