-
Notifications
You must be signed in to change notification settings - Fork 764
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ns exclusion audit from cache (#3129)
Signed-off-by: Alex Pana <[email protected]> Signed-off-by: alex <[email protected]> Signed-off-by: Sertaç Özercan <[email protected]> Co-authored-by: Sertaç Özercan <[email protected]>
- Loading branch information
Showing
3 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package fakes | ||
|
||
import ( | ||
"github.com/open-policy-agent/frameworks/constraint/pkg/apis/constraints" | ||
templatesv1beta1 "github.com/open-policy-agent/frameworks/constraint/pkg/apis/templates/v1beta1" | ||
"github.com/open-policy-agent/frameworks/constraint/pkg/core/templates" | ||
"github.com/open-policy-agent/gatekeeper/v3/pkg/target" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
func DenyAllRegoTemplate() *templates.ConstraintTemplate { | ||
return &templates.ConstraintTemplate{ | ||
TypeMeta: metav1.TypeMeta{ | ||
APIVersion: templatesv1beta1.SchemeGroupVersion.String(), | ||
Kind: "ConstraintTemplate", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "denyall", | ||
}, | ||
Spec: templates.ConstraintTemplateSpec{ | ||
CRD: templates.CRD{ | ||
Spec: templates.CRDSpec{ | ||
Names: templates.Names{ | ||
Kind: "denyall", | ||
}, | ||
}, | ||
}, | ||
Targets: []templates.Target{{ | ||
Target: target.Name, | ||
Code: []templates.Code{{ | ||
Engine: "Rego", | ||
Source: &templates.Anything{ | ||
Value: map[string]interface{}{"rego": ` | ||
package goodrego | ||
violation[{"msg": msg}] { | ||
msg := "denyall" | ||
}`}, | ||
}, | ||
}}, | ||
}}, | ||
}, | ||
} | ||
} | ||
|
||
func DenyAllConstraint() *unstructured.Unstructured { | ||
return ConstraintFor("denyall") | ||
} | ||
|
||
func ConstraintFor(kind string) *unstructured.Unstructured { | ||
u := &unstructured.Unstructured{} | ||
|
||
u.SetGroupVersionKind(schema.GroupVersionKind{ | ||
Group: constraints.Group, | ||
Version: "v1beta1", | ||
Kind: kind, | ||
}) | ||
u.SetName("constraint") | ||
|
||
return u | ||
} |