diff --git a/pkg/apis/troubleshoot/v1beta1/redact_shared.go b/pkg/apis/troubleshoot/v1beta1/redact_shared.go index 53008f223..edc0e1b73 100644 --- a/pkg/apis/troubleshoot/v1beta1/redact_shared.go +++ b/pkg/apis/troubleshoot/v1beta1/redact_shared.go @@ -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 { diff --git a/pkg/apis/troubleshoot/v1beta1/zz_generated.deepcopy.go b/pkg/apis/troubleshoot/v1beta1/zz_generated.deepcopy.go index 6b500b388..0a3e6a364 100644 --- a/pkg/apis/troubleshoot/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/troubleshoot/v1beta1/zz_generated.deepcopy.go @@ -1312,8 +1312,8 @@ func (in *Removals) DeepCopyInto(out *Removals) { *out = make([]Regex, len(*in)) copy(*out, *in) } - if in.Yaml != nil { - in, out := &in.Yaml, &out.Yaml + if in.YamlPath != nil { + in, out := &in.YamlPath, &out.YamlPath *out = make([]string, len(*in)) copy(*out, *in) } diff --git a/pkg/collect/collector_test.go b/pkg/collect/collector_test.go index 9e0346be0..71d8f5926 100644 --- a/pkg/collect/collector_test.go +++ b/pkg/collect/collector_test.go @@ -211,7 +211,7 @@ another line here`, Redactors: []*troubleshootv1beta1.Redact{ { Removals: troubleshootv1beta1.Removals{ - Yaml: []string{ + YamlPath: []string{ `abc`, }, }, diff --git a/pkg/redact/redact.go b/pkg/redact/redact.go index cd881d584..e3b9106a3 100644 --- a/pkg/redact/redact.go +++ b/pkg/redact/redact.go @@ -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) } diff --git a/sample-troubleshoot.yaml b/sample-troubleshoot.yaml index dd155cfda..7724050dd 100644 --- a/sample-troubleshoot.yaml +++ b/sample-troubleshoot.yaml @@ -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.*)(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.*)(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