Documentation
¶
Overview ¶
Package matcher provides functionality for building and composing functions for matching against various properties of resources.Resource objects based on user input.
Index ¶
- type AllMatcher
- type AnyMatcher
- type Matcher
- func NewAPIVersionMatcher(apiVersion string) (Matcher, error)
- func NewAnnotationMatcher(selector string) (Matcher, error)
- func NewCELMatcher(expression string) (Matcher, error)
- func NewClusterScopedMatcher() Matcher
- func NewContainsMatcher(substring string) (Matcher, error)
- func NewDiffMatcher(filename string) (Matcher, error)
- func NewExecMatcher(command string) (Matcher, error)
- func NewFieldPathMatcher(selector string) (Matcher, error)
- func NewGitMatcher(pattern string) (Matcher, error)
- func NewJsonpathMatcher(selector string) (Matcher, error)
- func NewKindMatcher(kind string) (Matcher, error)
- func NewLabelMatcher(selector string) (Matcher, error)
- func NewNameMatcher(name string) (Matcher, error)
- func NewNamespaceMatcher(namespace string) (Matcher, error)
- func NewNamespaceScopedMatcher() Matcher
- func NewPatchMatcher() Matcher
- func NewPathMatcher(path string) (Matcher, error)
- func NewReferenceMatcher(reference string) (Matcher, error)
- func NewRegoMatcher(filename string) (Matcher, error)
- func NewSelectorMatcher(selector string) (Matcher, error)
- func NotMatcher(matcher Matcher) Matcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllMatcher ¶
type AllMatcher struct {
// contains filtered or unexported fields
}
AllMatcher wraps a sequence of Matcher instances and returns true if each of the wrapped Matcher instances returns true.
func (*AllMatcher) Append ¶
func (m *AllMatcher) Append(matcher Matcher)
Append adds the given Matcher to the sequence of wrapped Matcher instances.
type AnyMatcher ¶
type AnyMatcher struct {
// contains filtered or unexported fields
}
AnyMatcher wraps a sequence of Matcher instances and returns true if any of the wrapped Matcher instances returns true. An empty AnyMatcher will also return true.
func (*AnyMatcher) Append ¶
func (m *AnyMatcher) Append(matcher Matcher)
Append adds the given Matcher to the sequence of wrapped Matcher instances.
type Matcher ¶
type Matcher interface {
// Matches returns true if the given resources.Resource object matches based
// on the logic and inputs for a concrete matcher.
Matches(item resources.Resource) bool
}
Matcher represents the logic for matching against the properties of a resources.Resource based on some inputs.
func NewAPIVersionMatcher ¶
NewAPIVersionMatcher matches resources.Resource instances based on the given apiversion glob.
func NewAnnotationMatcher ¶
NewAnnotationMatcher matches resources.Resource instances that contain the given annotation, and optionally matching a value for that annotation.
func NewCELMatcher ¶ added in v0.4.0
NewCELMatcher matches resources.Resource instances based on the results of evaluating a boolean CEL expression.
func NewClusterScopedMatcher ¶
func NewClusterScopedMatcher() Matcher
NewClusterScopedMatcher matches resources.Resource instances that are known (via the resolver) to be cluster-scoped. As a caveat, this matcher will not match unresolved resources even if they are cluster-scoped in reality.
func NewContainsMatcher ¶
NewContainsMatcher matches resources.Resource instances that contain the given substring after being re-marshalled back into YAML. This also applies to resources that were originally decoded from JSON files. Additionally, these re-marshalled YAML documents no longer contain any of the original comments or other formatting.
func NewDiffMatcher ¶
NewDiffMatcher matches resources.Resource instances that differ from companion resources decoded from the given filename. An example usage would be to save the output of `kustomize build` to a file, make refactors to the kustomize code, then rerun `kustomize build` to check if resources were changed.
func NewExecMatcher ¶
NewExecMatcher matches resources.Resource instances based on the results of executing an external program.
func NewFieldPathMatcher ¶ added in v0.3.0
NewFieldPathMatcher matches resources.Resource instances that contain the given Kustomize-style fieldpath, and optionally matching a target value at that path.
func NewGitMatcher ¶ added in v0.4.0
NewGitMatcher matches resources.Resource instances based on the current git status of the underlying resource file.
func NewJsonpathMatcher ¶
NewJsonpathMatcher matches resources.Resource instances that contain the given jsonpath, and optionally matching a target value at that path.
func NewKindMatcher ¶
NewKindMatcher matches resources.Resource instances based on the given kind which might be the kind verbatim, a glob, or a kind alias.
For example, a resource of kind `Service` would be matched by the input "Service", "svc", or "sv*".
func NewLabelMatcher ¶
NewLabelMatcher matches resources.Resource instances that contain the given label, and optionally matching a value for that label.
func NewNameMatcher ¶
NewNameMatcher matches resources.Resource instances based on the given name.
func NewNamespaceMatcher ¶
NewNamespaceMatcher matches resources.Resource instances based on the given namespace.
func NewNamespaceScopedMatcher ¶
func NewNamespaceScopedMatcher() Matcher
NewNamespaceScopedMatcher matches resources.Resource instances that are known (via the resolver) to be namespace-scoped. As a caveat, this matcher will not match unresolved resources even if they are namespace-scoped in reality.
func NewPatchMatcher ¶
func NewPatchMatcher() Matcher
NewPatchMatcher matches resources.Resource instances that were decoded from a kustomize patch file (the convention being a filename with the suffix `.patch.yaml`).
For example, a resource decoded from the file `kustomize/environments/production/deployment.patch.yaml` would be matched.
func NewPathMatcher ¶
NewPathMatcher matches resources.Resource instances based on the given file path substring.
For example, a resource decoded from the file `kustomize/environments/production/deployment.yaml` would be matched by the input `environments/production` or `deployment.yaml`.
func NewReferenceMatcher ¶
NewReferenceMatcher matches resources.Resource instances that reference the given named resource. A name glob like "my-secret-*" can be used to match any reference to a resource with that name, or can include a kind like "cm/my-configmap-*" to match any reference to a resource with that kind and name.
func NewRegoMatcher ¶ added in v0.4.0
NewRegoMatcher matches resources.Resource instances based on an evaluation of the given rego file.
The rego file must have a package value of `krf.joshdk.github.com` and provide a rule named `matches` in order to match a resource.
func NewSelectorMatcher ¶ added in v0.4.0
NewSelectorMatcher matches resources.Resource instances that match the given Kubernetes label selector.
func NotMatcher ¶
NotMatcher wraps the given Matcher instances and inverts its value.
Source Files
¶
- glob.go
- matcher-annotations.go
- matcher-apiversion.go
- matcher-cel.go
- matcher-contains.go
- matcher-diff.go
- matcher-exec.go
- matcher-fieldpath.go
- matcher-git.go
- matcher-jsonpath.go
- matcher-kind.go
- matcher-labels.go
- matcher-logic.go
- matcher-name.go
- matcher-namespace.go
- matcher-patch.go
- matcher-path.go
- matcher-reference.go
- matcher-rego.go
- matcher-scoped.go
- matcher-selector.go
- matcher.go