Skip to content

Commit 7752a33

Browse files
authored
Merge pull request #183 from replicatedhq/laverya/allow-specifying-multiple-redact-specs
allow specifying multiple redact specs
2 parents 33580e9 + 94e27eb commit 7752a33

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

cmd/troubleshoot/cli/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ from a server that can be used to assist when troubleshooting a server.`,
4343
cmd.Flags().String("collectors", "", "name of the collectors to use")
4444
cmd.Flags().String("image", "", "the full name of the collector image to use")
4545
cmd.Flags().String("pullpolicy", "", "the pull policy of the collector image")
46-
cmd.Flags().String("redactors", "", "name of the additional redactors to use")
46+
cmd.Flags().StringSlice("redactors", []string{}, "names of the additional redactors to use")
4747
cmd.Flags().Bool("redact", true, "enable/disable default redactions")
4848
cmd.Flags().Bool("collect-without-permissions", false, "always run troubleshoot collectors even if some require permissions that troubleshoot does not have")
4949

cmd/troubleshoot/cli/run.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,21 @@ func runTroubleshoot(v *viper.Viper, arg string) error {
5959
collector := obj.(*troubleshootv1beta1.Collector)
6060

6161
additionalRedactors := &troubleshootv1beta1.Redactor{}
62-
if v.GetString("redactors") != "" {
63-
redactorContent, err := loadSpec(v, v.GetString("redactors"))
62+
for idx, redactor := range v.GetStringSlice("redactors") {
63+
redactorContent, err := loadSpec(v, redactor)
6464
if err != nil {
65-
return errors.Wrap(err, "failed to load redactor spec")
65+
return errors.Wrapf(err, "failed to load redactor spec #%d", idx)
6666
}
6767
obj, _, err := decode([]byte(redactorContent), nil, nil)
6868
if err != nil {
69-
return errors.Wrapf(err, "failed to parse redactors %s", v.GetString("redactors"))
69+
return errors.Wrapf(err, "failed to parse redactors %s", redactor)
7070
}
71-
var ok bool
72-
additionalRedactors, ok = obj.(*troubleshootv1beta1.Redactor)
71+
loopRedactors, ok := obj.(*troubleshootv1beta1.Redactor)
7372
if !ok {
74-
return fmt.Errorf("%s is not a troubleshootv1beta1 redactor type", v.GetString("redactors"))
73+
return fmt.Errorf("%s is not a troubleshootv1beta1 redactor type", redactor)
74+
}
75+
if loopRedactors != nil {
76+
additionalRedactors.Spec.Redactors = append(additionalRedactors.Spec.Redactors, loopRedactors.Spec.Redactors...)
7577
}
7678
}
7779

0 commit comments

Comments
 (0)