Skip to content

Commit

Permalink
Add configuration option to disable container logging
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Hudson <[email protected]>
  • Loading branch information
nhudson committed Sep 19, 2022
1 parent f554590 commit 3422ef1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
30 changes: 16 additions & 14 deletions pkg/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,22 +901,24 @@ func (t *Testing) PrintEventsPodDetailsAndLogs(namespace string, selector string
return
}

printDetails(pod, "Logs of init container", "-",
func(item string) error {
return t.kubectl.Logs(namespace, pod, item)
}, initContainers...)
if t.config.PrintLogs {
printDetails(pod, "Logs of init container", "-",
func(item string) error {
return t.kubectl.Logs(namespace, pod, item)
}, initContainers...)

containers, err := t.kubectl.GetContainers(namespace, pod)
if err != nil {
fmt.Printf("failed printing logs: %v\n", err.Error())
return
}
containers, err := t.kubectl.GetContainers(namespace, pod)
if err != nil {
fmt.Printf("failed printing logs: %v\n", err.Error())
return
}

printDetails(pod, "Logs of container", "-",
func(item string) error {
return t.kubectl.Logs(namespace, pod, item)
},
containers...)
printDetails(pod, "Logs of container", "-",
func(item string) error {
return t.kubectl.Logs(namespace, pod, item)
},
containers...)
}
}

util.PrintDelimiterLineToWriter(os.Stdout, "=")
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ type Configuration struct {
ReleaseLabel string `mapstructure:"release-label"`
ExcludeDeprecated bool `mapstructure:"exclude-deprecated"`
KubectlTimeout time.Duration `mapstructure:"kubectl-timeout"`
PrintLogs bool `mapstructure:"print-logs"`
}

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

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

cmd.Flags().VisitAll(func(flag *flag.Flag) {
flagName := flag.Name
Expand Down

0 comments on commit 3422ef1

Please sign in to comment.