Skip to content

Commit

Permalink
Add config option to disable printing of container logs
Browse files Browse the repository at this point in the history
Update docs

Signed-off-by: Nick Hudson <[email protected]>
  • Loading branch information
nhudson committed Sep 16, 2022
1 parent 68f3fff commit d25e580
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion doc/ct.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ in given chart directories.
* [ct list-changed](ct_list-changed.md) - List changed charts
* [ct version](ct_version.md) - Print version information

###### Auto generated by spf13/cobra on 23-Mar-2022
###### Auto generated by spf13/cobra on 16-Sep-2022
2 changes: 1 addition & 1 deletion doc/ct_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ ct install [flags]

* [ct](ct.md) - The Helm chart testing tool

###### Auto generated by spf13/cobra on 23-Mar-2022
###### Auto generated by spf13/cobra on 16-Sep-2022
2 changes: 1 addition & 1 deletion doc/ct_lint-and-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ ct lint-and-install [flags]

* [ct](ct.md) - The Helm chart testing tool

###### Auto generated by spf13/cobra on 23-Mar-2022
###### Auto generated by spf13/cobra on 16-Sep-2022
2 changes: 1 addition & 1 deletion doc/ct_lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ ct lint [flags]

* [ct](ct.md) - The Helm chart testing tool

###### Auto generated by spf13/cobra on 23-Mar-2022
###### Auto generated by spf13/cobra on 16-Sep-2022
2 changes: 1 addition & 1 deletion doc/ct_list-changed.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ ct list-changed [flags]

* [ct](ct.md) - The Helm chart testing tool

###### Auto generated by spf13/cobra on 23-Mar-2022
###### Auto generated by spf13/cobra on 16-Sep-2022
2 changes: 1 addition & 1 deletion doc/ct_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ ct version [flags]

* [ct](ct.md) - The Helm chart testing tool

###### Auto generated by spf13/cobra on 23-Mar-2022
###### Auto generated by spf13/cobra on 16-Sep-2022
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 d25e580

Please sign in to comment.