mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-15 16:59:51 +00:00
Allow to skip resources using the GVK notation (#92)
* Allow to skip resources using the GVK notation * Update flags description, add integration tests and update readme Co-authored-by: Yann Hamon <yann@mandragor.org>
This commit is contained in:
parent
466ec73ed7
commit
d8e348a597
6 changed files with 52 additions and 10 deletions
|
|
@ -98,12 +98,23 @@ type v struct {
|
|||
// ValidateResource validates a single resource. This allows to validate
|
||||
// large resource streams using multiple Go Routines.
|
||||
func (val *v) ValidateResource(res resource.Resource) Result {
|
||||
// For backward compatibility reasons when determining whether
|
||||
// a resource should be skipped or rejected we use both
|
||||
// the GVK encoding of the resource signatures (the recommended method
|
||||
// for skipping/rejecting resources) and the raw Kind.
|
||||
|
||||
skip := func(signature resource.Signature) bool {
|
||||
if _, ok := val.opts.SkipKinds[signature.GroupVersionKind()]; ok {
|
||||
return ok
|
||||
}
|
||||
_, ok := val.opts.SkipKinds[signature.Kind]
|
||||
return ok
|
||||
}
|
||||
|
||||
reject := func(signature resource.Signature) bool {
|
||||
if _, ok := val.opts.RejectKinds[signature.GroupVersionKind()]; ok {
|
||||
return ok
|
||||
}
|
||||
_, ok := val.opts.RejectKinds[signature.Kind]
|
||||
return ok
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
package validator
|
||||
|
||||
import (
|
||||
"github.com/yannh/kubeconform/pkg/registry"
|
||||
"testing"
|
||||
|
||||
"github.com/yannh/kubeconform/pkg/registry"
|
||||
|
||||
"github.com/yannh/kubeconform/pkg/resource"
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue