@@ -19,7 +19,7 @@ type LogsOutput struct {
1919 PodLogs map [string ][]byte `json:"logs/,omitempty"`
2020}
2121
22- func Logs (logsCollector * troubleshootv1beta1.Logs ) error {
22+ func Logs (logsCollector * troubleshootv1beta1.Logs , redact bool ) error {
2323 cfg , err := config .GetConfig ()
2424 if err != nil {
2525 return err
@@ -35,7 +35,7 @@ func Logs(logsCollector *troubleshootv1beta1.Logs) error {
3535 return err
3636 }
3737
38- logsOutput := LogsOutput {
38+ logsOutput := & LogsOutput {
3939 PodLogs : make (map [string ][]byte ),
4040 }
4141 for _ , pod := range pods {
@@ -49,6 +49,13 @@ func Logs(logsCollector *troubleshootv1beta1.Logs) error {
4949 }
5050 }
5151
52+ if redact {
53+ logsOutput , err = logsOutput .Redact ()
54+ if err != nil {
55+ return err
56+ }
57+ }
58+
5259 b , err := json .MarshalIndent (logsOutput , "" , " " )
5360 if err != nil {
5461 return err
@@ -114,3 +121,14 @@ func getPodLogs(client *kubernetes.Clientset, pod corev1.Pod, limits *troublesho
114121 fmt .Sprintf ("%s/%s.txt" , pod .Namespace , pod .Name ): buf .Bytes (),
115122 }, nil
116123}
124+
125+ func (l * LogsOutput ) Redact () (* LogsOutput , error ) {
126+ podLogs , err := redactMap (l .PodLogs )
127+ if err != nil {
128+ return nil , err
129+ }
130+
131+ return & LogsOutput {
132+ PodLogs : podLogs ,
133+ }, nil
134+ }
0 commit comments