kubelatte-ce
Форк от sbertech/kubelatte-ce
80 строк · 2.0 Кб
1package v1alpha1
2
3import "reflect"
4
5type Match struct {
6Operations []string `json:"operations,omitempty"`
7
8// +kubebuilder:validation:Enum=*;Cluster;Namespaced
9Scope string `json:"scope,omitempty"`
10
11UserInfo UserInfo `json:"userInfo,omitempty"`
12Kinds []Kind `json:"kinds"`
13
14Name Name `json:"name,omitempty"`
15
16NamespaceSelector NamespaceSelector `json:"namespaceSelector,omitempty"`
17ExcludedNamespaces Namespace `json:"excludedNamespaces,omitempty"`
18IncludedNamespaces Namespace `json:"namespaces,omitempty"`
19
20AnnotationSelector AnnotationSelector `json:"annotationSelector,omitempty"`
21LabelSelector LabelSelector `json:"labelSelector,omitempty"`
22
23MatchConditions MatchConditions `json:"matchConditions,omitempty"`
24}
25
26type Namespace struct {
27Values []string `json:"values,omitempty"`
28Regex []string `json:"regex,omitempty"`
29}
30
31type Name struct {
32Value string `json:"value,omitempty"`
33Regex string `json:"regex,omitempty"`
34}
35
36type MatchConditions struct {
37Object []Obj `json:"object,omitempty"`
38OldObject []Obj `json:"oldObject,omitempty"`
39}
40
41type Obj struct {
42Path string `json:"path"`
43
44// +kubebuilder:validation:Enum=MustExist;MustNotExist
45Condition string `json:"condition"`
46}
47
48type Kind struct {
49Kind []string `json:"kinds,omitempty"`
50ApiGroups []string `json:"apiGroups,omitempty"`
51}
52
53type UserInfo struct {
54Username string `json:"username,omitempty"`
55UsernameRegex string `json:"usernameRegex,omitempty"`
56}
57
58type NamespaceSelector struct {
59MatchExpressions []MatchExpression `json:"matchExpressions"`
60}
61
62type AnnotationSelector struct {
63MatchExpressions []MatchExpression `json:"matchExpressions"`
64}
65
66type LabelSelector struct {
67MatchExpressions []MatchExpression `json:"matchExpressions"`
68}
69
70type MatchExpression struct {
71Key string `json:"key"`
72
73// +kubebuilder:validation:Enum=In;NotIn;Exists;DoesNotExist
74Operator string `json:"operator"`
75Values []string `json:"values,omitempty"`
76}
77
78func (in *Match) IsEmpty() bool {
79return reflect.DeepEqual(*in, Match{})
80}
81