add support for custom multiline redactors, add yaml redactors to spec

This commit is contained in:
Andrew Lavery
2020-04-27 16:50:25 -04:00
parent 7752a33268
commit 8f594e8764
3 changed files with 47 additions and 7 deletions

View File

@@ -1,9 +1,16 @@
package v1beta1
type Redact struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
File string `json:"file,omitempty" yaml:"file,omitempty"`
Files []string `json:"files,omitempty" yaml:"files,omitempty"`
Values []string `json:"values,omitempty" yaml:"values,omitempty"`
Regex []string `json:"regex,omitempty" yaml:"regex,omitempty"`
type MultiLine struct {
Selector string `json:"selector,omitempty" yaml:"selector,omitempty"`
Redactor string `json:"redactor,omitempty" yaml:"redactor,omitempty"`
}
type Redact struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
File string `json:"file,omitempty" yaml:"file,omitempty"`
Files []string `json:"files,omitempty" yaml:"files,omitempty"`
Values []string `json:"values,omitempty" yaml:"values,omitempty"`
Regex []string `json:"regex,omitempty" yaml:"regex,omitempty"`
MultiLine []MultiLine `json:"multiLine,omitempty" yaml:"multiLine,omitempty"`
Yaml []string `json:"yaml,omitempty" yaml:"yaml,omitempty"`
}

View File

@@ -915,6 +915,21 @@ func (in *Logs) DeepCopy() *Logs {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MultiLine) DeepCopyInto(out *MultiLine) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MultiLine.
func (in *MultiLine) DeepCopy() *MultiLine {
if in == nil {
return nil
}
out := new(MultiLine)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeResourceFilters) DeepCopyInto(out *NodeResourceFilters) {
*out = *in
@@ -1165,6 +1180,16 @@ func (in *Redact) DeepCopyInto(out *Redact) {
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.MultiLine != nil {
in, out := &in.MultiLine, &out.MultiLine
*out = make([]MultiLine, len(*in))
copy(*out, *in)
}
if in.Yaml != nil {
in, out := &in.Yaml, &out.Yaml
*out = make([]string, len(*in))
copy(*out, *in)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Redact.

View File

@@ -65,7 +65,7 @@ func buildAdditionalRedactors(path string, redacts []*troubleshootv1beta1.Redact
for _, re := range redact.Regex {
r, err := NewSingleLineRedactor(re, MASK_TEXT)
if err != nil {
return nil, err // maybe skip broken ones?
return nil, errors.Wrapf(err, "redactor %q", re)
}
additionalRedactors = append(additionalRedactors, r)
}
@@ -73,6 +73,14 @@ func buildAdditionalRedactors(path string, redacts []*troubleshootv1beta1.Redact
for _, literal := range redact.Values {
additionalRedactors = append(additionalRedactors, literalString(literal))
}
for _, re := range redact.MultiLine {
r, err := NewMultiLineRedactor(re.Selector, re.Redactor, MASK_TEXT)
if err != nil {
return nil, errors.Wrapf(err, "multiline redactor %+v", re)
}
additionalRedactors = append(additionalRedactors, r)
}
}
return additionalRedactors, nil
}