@@ -56,6 +56,23 @@ func runTroubleshoot(v *viper.Viper, arg string) error {
5656
5757 collector := obj .(* troubleshootv1beta1.Collector )
5858
59+ var additionalRedactors * troubleshootv1beta1.Redactor
60+ if v .GetString ("redactors" ) != "" {
61+ redactorContent , err := loadSpec (v , v .GetString ("redactors" ))
62+ if err != nil {
63+ return errors .Wrap (err , "failed to load redactor spec" )
64+ }
65+ obj , _ , err := decode ([]byte (redactorContent ), nil , nil )
66+ if err != nil {
67+ return errors .Wrapf (err , "failed to parse redactors %s" , v .GetString ("redactors" ))
68+ }
69+ var ok bool
70+ additionalRedactors , ok = obj .(* troubleshootv1beta1.Redactor )
71+ if ! ok {
72+ return fmt .Errorf ("%s is not a troubleshootv1beta1 redactor type" , v .GetString ("redactors" ))
73+ }
74+ }
75+
5976 s := spin .New ()
6077 finishedCh := make (chan bool , 1 )
6178 progressChan := make (chan interface {}, 0 ) // non-zero buffer can result in missed messages
@@ -87,7 +104,7 @@ func runTroubleshoot(v *viper.Viper, arg string) error {
87104 close (finishedCh )
88105 }()
89106
90- archivePath , err := runCollectors (v , * collector , progressChan )
107+ archivePath , err := runCollectors (v , * collector , additionalRedactors , progressChan )
91108 if err != nil {
92109 return errors .Wrap (err , "run collectors" )
93110 }
@@ -193,7 +210,7 @@ func canTryInsecure(v *viper.Viper) bool {
193210 return true
194211}
195212
196- func runCollectors (v * viper.Viper , collector troubleshootv1beta1.Collector , progressChan chan interface {}) (string , error ) {
213+ func runCollectors (v * viper.Viper , collector troubleshootv1beta1.Collector , additionalRedactors * troubleshootv1beta1. Redactor , progressChan chan interface {}) (string , error ) {
197214 bundlePath , err := ioutil .TempDir ("" , "troubleshoot" )
198215 if err != nil {
199216 return "" , errors .Wrap (err , "create temp dir" )
@@ -241,6 +258,11 @@ func runCollectors(v *viper.Viper, collector troubleshootv1beta1.Collector, prog
241258 return "" , errors .New ("insufficient permissions to run all collectors" )
242259 }
243260
261+ globalRedactors := []* troubleshootv1beta1.Redact {}
262+ if additionalRedactors != nil {
263+ globalRedactors = additionalRedactors .Spec .Redactors
264+ }
265+
244266 // Run preflights collectors synchronously
245267 for _ , collector := range collectors {
246268 if len (collector .RBACErrors ) > 0 {
@@ -253,7 +275,7 @@ func runCollectors(v *viper.Viper, collector troubleshootv1beta1.Collector, prog
253275
254276 progressChan <- collector .GetDisplayName ()
255277
256- result , err := collector .RunCollectorSync ()
278+ result , err := collector .RunCollectorSync (globalRedactors )
257279 if err != nil {
258280 progressChan <- fmt .Errorf ("failed to run collector %q: %v" , collector .GetDisplayName (), err )
259281 continue
0 commit comments