1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 16:06:56 +00:00
kyverno/cmd/cli/kubectl-kyverno/apis/v1alpha1/test.go

67 lines
1.9 KiB
Go
Raw Normal View History

package v1alpha1
import (
"github.com/kyverno/kyverno-json/pkg/apis/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope="Cluster"
// Test declares a test
type Test struct {
metav1.TypeMeta `json:",inline,omitempty"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Name is the name of the test.
// This field is deprecated, use `metadata.name` instead
Name string `json:"name,omitempty"`
// Policies are the policies to be used in the test
Policies []string `json:"policies,omitempty"`
// Resources are the resource to be used in the test
Resources []string `json:"resources,omitempty"`
// Variables is the values to be used in the test
Variables string `json:"variables,omitempty"`
// UserInfo is the user info to be used in the test
UserInfo string `json:"userinfo,omitempty"`
// Results are the results to be checked in the test
Results []TestResult `json:"results,omitempty"`
// Checks are the verifications to be checked in the test
Checks []CheckResult `json:"checks,omitempty"`
// Values are the values to be used in the test
Values *ValuesSpec `json:"values,omitempty"`
Support PolicyExceptions with CLI (#9525) * loding policyExecptions from func Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> * adding PolicyExceptions in crds Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> * adding PolicyExceptions in GetPolicy function Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> * adding policyexceptions in Load function Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> * resolve error becuase of now Getpolicy return policyexceptions Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> * added -exception flag loaded policyexception Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> * added policyexceptions in processor and NewEngine Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> * Revert "added -exception flag loaded policyexception" This reverts commit f53b205c089e780033b14c9a6343a141c20875b6. * Revert "Added support for PolicyExceptions for apply command " This reverts commit 82689ea0c1b914c566ac8ef30ab863f33d9b5460. * Update cmd/cli/kubectl-kyverno/commands/test/test.go loading exceptions with policies Co-authored-by: Mariam Fahmy <mariamfahmy66@gmail.com> Signed-off-by: Sanskar Gurdasani <92817635+Sanskarzz@users.noreply.github.com> * updated GetFullPaths function and remove unnecessary code Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> * added tests for loading exceptions in GetPolicy function Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> * added tests for loading policy exceptions Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> * Used selector in List function Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> * generated cli crd Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> * updated loadpolicy_test tests and corrected kind Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> * resolved unit test error in path_test.go file Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> * limiting the usage of exceptions to ValidatingAdmissionPolicies Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> * remove changes in common code Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fixes Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fixes Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fixes Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fixes Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fixes Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fixes Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fixes Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fixes Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fixes Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fixes Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * codegen Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> --------- Signed-off-by: Sanskarzz <sanskar.gur@gmail.com> Signed-off-by: Sanskar Gurdasani <92817635+Sanskarzz@users.noreply.github.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Co-authored-by: Mariam Fahmy <mariamfahmy66@gmail.com> Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2024-02-01 03:58:14 +05:30
// Policy Exceptions are the policy exceptions to be used in the test
PolicyExceptions []string `json:"exceptions,omitempty"`
}
type CheckResult struct {
// Match tells how to match relevant rule responses
Match CheckMatch `json:"match,omitempty"`
// Assert contains assertion to be performed on the relevant rule responses
Assert v1alpha1.Any `json:"assert"`
// Error contains negative assertion to be performed on the relevant rule responses
Error v1alpha1.Any `json:"error"`
}
type CheckMatch struct {
// Resource filters engine responses
Resource *v1alpha1.Any `json:"resource,omitempty"`
// Policy filters engine responses
Policy *v1alpha1.Any `json:"policy,omitempty"`
// Rule filters rule responses
Rule *v1alpha1.Any `json:"rule,omitempty"`
}