Skip to content

Commit

Permalink
update yaml key name, fixup example troubleshoot
Browse files Browse the repository at this point in the history
  • Loading branch information
laverya committed Jun 15, 2020
1 parent afd2ee9 commit 6e87448
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
6 changes: 3 additions & 3 deletions pkg/apis/troubleshoot/v1beta1/redact_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ type FileSelector struct {
}

type Removals struct {
Values []string `json:"values,omitempty" yaml:"values,omitempty"`
Regex []Regex `json:"regex,omitempty" yaml:"regex,omitempty"`
Yaml []string `json:"yaml,omitempty" yaml:"yaml,omitempty"`
Values []string `json:"values,omitempty" yaml:"values,omitempty"`
Regex []Regex `json:"regex,omitempty" yaml:"regex,omitempty"`
YamlPath []string `json:"yamlPath,omitempty" yaml:"yamlPath,omitempty"`
}

type Redact struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/troubleshoot/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/collect/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ another line here`,
Redactors: []*troubleshootv1beta1.Redact{
{
Removals: troubleshootv1beta1.Removals{
Yaml: []string{
YamlPath: []string{
`abc`,
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/redact/redact.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func buildAdditionalRedactors(path string, redacts []*troubleshootv1beta1.Redact
additionalRedactors = append(additionalRedactors, newRedactor)
}

for j, yaml := range redact.Removals.Yaml {
for j, yaml := range redact.Removals.YamlPath {
r := NewYamlRedactor(yaml, path, redactorName(i, j, redact.Name, "yaml"))
additionalRedactors = append(additionalRedactors, r)
}
Expand Down
22 changes: 12 additions & 10 deletions sample-troubleshoot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ metadata:
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
fileSelector:
file: data/my-password-dump # this targets a single file
removals:
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***`
multiLine:
- selector: 'S3_ENDPOINT' # remove the value in lines following those that contain the string S3_ENDPOINT
redactor: '("value": ").*(")'
yaml:
- "abc.xyz.*" # redact all items in the array at key xyz within key abc in yaml documents
removals:
regex:
- redactor: (another)(?P<mask>.*)(here) # this will replace anything between the strings `another` and `here` with `***HIDDEN***`
- selector: 'S3_ENDPOINT' # remove the value in lines following those that contain the string S3_ENDPOINT
redactor: '("value": ").*(")'
yamlPath:
- "abc.xyz.*" # redact all items in the array at key xyz within key abc in yaml documents

0 comments on commit 6e87448

Please sign in to comment.