-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
- Loading branch information
1 parent
312135a
commit b26d4cd
Showing
11 changed files
with
94 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package v1alpha1 | ||
|
||
// ContextEntry adds variables and data sources to a rule Context. | ||
type ContextEntry struct { | ||
// Name is the variable name. | ||
Name string `json:"name"` | ||
|
||
// Variable defines an arbitrary JMESPath context variable that can be defined inline. | ||
Variable *Variable `json:"variable,omitempty"` | ||
} |
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,11 @@ | ||
package v1alpha1 | ||
|
||
type MatchResources struct { | ||
// Any allows specifying resources which will be ORed | ||
// +optional | ||
Any ResourceFilters `json:"any,omitempty"` | ||
|
||
// All allows specifying resources which will be ANDed | ||
// +optional | ||
All ResourceFilters `json:"all,omitempty"` | ||
} |
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,7 @@ | ||
package v1alpha1 | ||
|
||
type PolicySpec struct { | ||
// Rules is a list of Rule instances. A Policy contains multiple rules and | ||
// each rule can validate, mutate, or generate resources. | ||
Rules []Rule `json:"rules,omitempty"` | ||
} |
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,10 @@ | ||
package v1alpha1 | ||
|
||
// ResourceFilter allow users to "AND" or "OR" between resources | ||
type ResourceFilter struct { | ||
// ResourceDescription contains information about the resource being created or modified. | ||
// +kubebuilder:validation:Type=object | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Schemaless | ||
Resource map[string]interface{} `json:"resource,omitempty"` | ||
} |
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,4 @@ | ||
package v1alpha1 | ||
|
||
// ResourceFilters is a slice of ResourceFilter | ||
type ResourceFilters []ResourceFilter |
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,27 @@ | ||
package v1alpha1 | ||
|
||
type Rule struct { | ||
// Name is a label to identify the rule, It must be unique within the policy. | ||
// +kubebuilder:validation:MaxLength=63 | ||
Name string `json:"name"` | ||
|
||
// Context defines variables and data sources that can be used during rule execution. | ||
// +optional | ||
Context []ContextEntry `json:"context,omitempty"` | ||
|
||
// MatchResources defines when this policy rule should be applied. The match | ||
// criteria can include resource information (e.g. kind, name, namespace, labels) | ||
// and admission review request information like the user name or role. | ||
// At least one kind is required. | ||
MatchResources *MatchResources `json:"match,omitempty"` | ||
|
||
// ExcludeResources defines when this policy rule should not be applied. The exclude | ||
// criteria can include resource information (e.g. kind, name, namespace, labels) | ||
// and admission review request information like the name or role. | ||
// +optional | ||
ExcludeResources *MatchResources `json:"exclude,omitempty"` | ||
|
||
// Validation is used to validate matching resources. | ||
// +optional | ||
Validation *Validation `json:"validate,omitempty"` | ||
} |
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,14 @@ | ||
package v1alpha1 | ||
|
||
// Validation defines checks to be performed on matching resources. | ||
type Validation struct { | ||
// Message specifies a custom message to be displayed on failure. | ||
// +optional | ||
Message string `json:"message,omitempty"` | ||
|
||
// Pattern specifies an overlay-style pattern used to check resources. | ||
// +kubebuilder:validation:Type=object | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Schemaless | ||
Pattern map[string]interface{} `json:"pattern,omitempty"` | ||
} |
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,9 @@ | ||
package v1alpha1 | ||
|
||
// Variable defines an arbitrary JMESPath context variable that can be defined inline. | ||
type Variable struct { | ||
// Value is any arbitrary JSON object representable in YAML or JSON form. | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Schemaless | ||
Value interface{} `json:"value,omitempty"` | ||
} |
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