Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
Signed-off-by: ShutingZhao <[email protected]>
  • Loading branch information
realshuting committed Aug 14, 2024
1 parent ca44d01 commit 96731bd
Show file tree
Hide file tree
Showing 7 changed files with 5,727 additions and 13,629 deletions.
36 changes: 3 additions & 33 deletions api/kyverno/v1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,9 @@ type Generation struct {
// +optional
GenerateExisting *bool `json:"generateExisting,omitempty" yaml:"generateExisting,omitempty"`

// ResourceSpec contains information to select the resource.
ResourceSpec `json:",omitempty" yaml:",omitempty"`

// Synchronize controls if generated resources should be kept in-sync with their source resource.
// If Synchronize is set to "true" changes to generated resources will be overwritten with resource
// data from Data or the resource specified in the Clone declaration.
Expand All @@ -763,9 +766,6 @@ type Generation struct {
// +optional
OrphanDownstreamOnPolicyDelete bool `json:"orphanDownstreamOnPolicyDelete,omitempty" yaml:"orphanDownstreamOnPolicyDelete,omitempty"`

// ResourceSpec contains information to select the resource.
ResourceSpec `json:",omitempty" yaml:",omitempty"`

// Data provides the resource declaration used to populate each generated resource.
// At most one of Data or Clone must be specified. If neither are provided, the generated
// resource will be created with default data only.
Expand All @@ -781,36 +781,6 @@ type Generation struct {
// CloneList specifies the list of source resource used to populate each generated resource.
// +optional
CloneList CloneList `json:"cloneList,omitempty" yaml:"cloneList,omitempty"`

// ForEach applies generate rules to a list of sub-elements by creating a context for each entry in the list and looping over it to apply the specified logic.
// +optional
ForEachGeneration []ForEachGeneration `json:"foreach,omitempty" yaml:"foreach,omitempty"`
}

type ForEachGeneration struct {
// List specifies a JMESPath expression that results in one or more elements
// to which the validation logic is applied.
List string `json:"list,omitempty" yaml:"list,omitempty"`

// Context defines variables and data sources that can be used during rule execution.
// +optional
Context []ContextEntry `json:"context,omitempty" yaml:"context,omitempty"`

// AnyAllConditions are used to determine if a policy rule should be applied by evaluating a
// set of conditions. The declaration can contain nested `any` or `all` statements.
// See: https://kyverno.io/docs/writing-policies/preconditions/
// +kubebuilder:validation:XPreserveUnknownFields
// +optional
AnyAllConditions *AnyAllConditions `json:"preconditions,omitempty" yaml:"preconditions,omitempty"`

// ResourceSpec contains information to select the resource.
ResourceSpec `json:",omitempty" yaml:",omitempty"`

// Data provides the resource declaration used to populate each generated resource.
// At most one of Data or Clone must be specified. If neither are provided, the generated
// resource will be created with default data only.
// +optional
RawData *apiextv1.JSON `json:"data,omitempty" yaml:"data,omitempty"`
}

type CloneList struct {
Expand Down
3,220 changes: 954 additions & 2,266 deletions charts/kyverno/charts/crds/templates/kyverno.io/kyverno.io_clusterpolicies.yaml

Large diffs are not rendered by default.

3,220 changes: 954 additions & 2,266 deletions charts/kyverno/charts/crds/templates/kyverno.io/kyverno.io_policies.yaml

Large diffs are not rendered by default.

3,220 changes: 954 additions & 2,266 deletions cmd/cli/kubectl-kyverno/data/crds/kyverno.io_clusterpolicies.yaml

Large diffs are not rendered by default.

3,220 changes: 954 additions & 2,266 deletions cmd/cli/kubectl-kyverno/data/crds/kyverno.io_policies.yaml

Large diffs are not rendered by default.

3,220 changes: 954 additions & 2,266 deletions config/crds/kyverno/kyverno.io_clusterpolicies.yaml

Large diffs are not rendered by default.

3,220 changes: 954 additions & 2,266 deletions config/crds/kyverno/kyverno.io_policies.yaml

Large diffs are not rendered by default.

0 comments on commit 96731bd

Please sign in to comment.