1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-10 09:56:55 +00:00
kyverno/cmd/cli/kubectl-kyverno/apis/v1alpha1/test.go
Charles-Edouard Brétéché b7eea2faa9
feat: use assertion trees in cli test command (#9380)
* feat: use assertion trees in cli test command

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* assert / error

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* output

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* check for nil

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2024-01-24 16:40:59 +00:00

63 lines
1.8 KiB
Go

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"`
}
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"`
}