Skip to content

Commit d25e580

Browse files
committed
Add config option to disable printing of container logs
Update docs Signed-off-by: Nick Hudson <[email protected]>
1 parent 68f3fff commit d25e580

File tree

8 files changed

+24
-20
lines changed

8 files changed

+24
-20
lines changed

doc/ct.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ in given chart directories.
2626
* [ct list-changed](ct_list-changed.md) - List changed charts
2727
* [ct version](ct_version.md) - Print version information
2828

29-
###### Auto generated by spf13/cobra on 23-Mar-2022
29+
###### Auto generated by spf13/cobra on 16-Sep-2022

doc/ct_install.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ ct install [flags]
7878

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

81-
###### Auto generated by spf13/cobra on 23-Mar-2022
81+
###### Auto generated by spf13/cobra on 16-Sep-2022

doc/ct_lint-and-install.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ ct lint-and-install [flags]
7777

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

80-
###### Auto generated by spf13/cobra on 23-Mar-2022
80+
###### Auto generated by spf13/cobra on 16-Sep-2022

doc/ct_lint.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ ct lint [flags]
7474

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

77-
###### Auto generated by spf13/cobra on 23-Mar-2022
77+
###### Auto generated by spf13/cobra on 16-Sep-2022

doc/ct_list-changed.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ ct list-changed [flags]
3232

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

35-
###### Auto generated by spf13/cobra on 23-Mar-2022
35+
###### Auto generated by spf13/cobra on 16-Sep-2022

doc/ct_version.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ ct version [flags]
1616

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

19-
###### Auto generated by spf13/cobra on 23-Mar-2022
19+
###### Auto generated by spf13/cobra on 16-Sep-2022

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)