Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Fieldspec filter supports wildcard match #4457

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions api/types/fieldspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,21 @@ type FieldSpec struct {
resid.Gvk `json:",inline,omitempty" yaml:",inline,omitempty"`
Path string `json:"path,omitempty" yaml:"path,omitempty"`
CreateIfNotPresent bool `json:"create,omitempty" yaml:"create,omitempty"`
// RegexPattern defines and constructs the value format of the fieldSpec node.
// It extends the usability of fieldSpec and related filters to set ScalarNode
// flexibly. Consider this as the ApplyFilter rules defined on the FieldSpec level.
RegexPattern string `json:"regexPattern,omitempty" yaml:"regexPattern,omitempty"`
}

func (fs FieldSpec) String() string {
return fmt.Sprintf(
"%s:%v:%s", fs.Gvk.String(), fs.CreateIfNotPresent, fs.Path)
if fs.RegexPattern == "" {
return fmt.Sprintf(
"%s:%v:%s", fs.Gvk.String(), fs.CreateIfNotPresent, fs.Path)
} else {

return fmt.Sprintf(
"%s:%v:%s:%s", fs.Gvk.String(), fs.CreateIfNotPresent, fs.Path, fs.RegexPattern)
}
}

// If true, the primary key is the same, but other fields might not be.
Expand Down