Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions cmd/troubleshoot/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ func runTroubleshoot(v *viper.Viper, arg string) error {
return errors.Wrap(err, "failed to load collector spec")
}

multidocs := strings.Split(string(collectorContent), "---")

troubleshootclientsetscheme.AddToScheme(scheme.Scheme)
decode := scheme.Codecs.UniversalDeserializer().Decode
obj, _, err := decode([]byte(collectorContent), nil, nil)
obj, _, err := decode([]byte(multidocs[0]), nil, nil)
if err != nil {
return errors.Wrapf(err, "failed to parse %s", arg)
}

collector := obj.(*troubleshootv1beta1.Collector)

var additionalRedactors *troubleshootv1beta1.Redactor
additionalRedactors := &troubleshootv1beta1.Redactor{}
if v.GetString("redactors") != "" {
redactorContent, err := loadSpec(v, v.GetString("redactors"))
if err != nil {
Expand All @@ -73,6 +75,18 @@ func runTroubleshoot(v *viper.Viper, arg string) error {
}
}

for i, additionalDoc := range multidocs[1:] {
obj, _, err := decode([]byte(additionalDoc), nil, nil)
if err != nil {
return errors.Wrapf(err, "failed to parse additional doc %d", i)
}
multidocRedactors, ok := obj.(*troubleshootv1beta1.Redactor)
if !ok {
continue
}
additionalRedactors.Spec.Redactors = append(additionalRedactors.Spec.Redactors, multidocRedactors.Spec.Redactors...)
}

s := spin.New()
finishedCh := make(chan bool, 1)
progressChan := make(chan interface{}, 0) // non-zero buffer can result in missed messages
Expand Down
13 changes: 0 additions & 13 deletions sample-redactors.yaml

This file was deleted.

14 changes: 14 additions & 0 deletions sample-troubleshoot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,17 @@ spec:
data: |
my super secret password is abc123
another redaction will go here
---
apiVersion: troubleshoot.replicated.com/v1beta1
kind: Redactor
metadata:
name: my-application-name
spec:
redactors:
- name: replace password # names are not used internally, but are useful for recordkeeping
file: data/my-password-dump # this targets a single file
values:
- abc123 # this is a very good password, and I don't want it to be exposed
- name: all files # as no file is specified, this redactor will run against all files
regex:
- (another)(?P<mask>.*)(here) # this will replace anything between the strings `another` and `here` with `***HIDDEN***`