kubesphere.io/api@v0.0.0-20231107125330-c9a03957060c/auditing/v1alpha1/rule_types.go (about)

     1  /*
     2  Copyright 2020 The KubeSphere Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package v1alpha1
    18  
    19  import (
    20  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    21  )
    22  
    23  // EDIT THIS FILE!  THIS IS SCAFFOLDING FOR YOU TO OWN!
    24  // NOTE: json tags are required.  Any new fields you add must have json tags for the fields to be serialized.
    25  
    26  type PolicyRule struct {
    27  	// Rule name
    28  	Name string `json:"name,omitempty" protobuf:"bytes,8,opt,name=name"`
    29  	// Rule type, rule, macro,list,alias
    30  	Type string `json:"type,omitempty" protobuf:"bytes,8,opt,name=type"`
    31  	// Rule describe
    32  	Desc string `json:"desc,omitempty" protobuf:"bytes,8,opt,name=desc"`
    33  	// Rule condition
    34  	// This effective When the rule type is rule
    35  	Condition string `json:"condition,omitempty" protobuf:"bytes,8,opt,name=condition"`
    36  	// This effective When the rule type is macro
    37  	Macro string `json:"macro,omitempty" protobuf:"bytes,8,opt,name=macro"`
    38  	// This effective When the rule type is alias
    39  	Alias string `json:"alias,omitempty" protobuf:"bytes,8,opt,name=alias"`
    40  	// This effective When the rule type is list
    41  	List []string `json:"list,omitempty" protobuf:"bytes,8,opt,name=list"`
    42  	// Is the rule enable
    43  	Enable bool `json:"enable" protobuf:"bytes,8,opt,name=enable"`
    44  	// The output formater of message which send to user
    45  	Output string `json:"output,omitempty" protobuf:"bytes,8,opt,name=output"`
    46  	// Rule priority, DEBUG, INFO, WARNING
    47  	Priority string `json:"priority,omitempty" protobuf:"bytes,8,opt,name=priority"`
    48  }
    49  
    50  // AuditRuleSpec defines the desired state of Rule
    51  type RuleSpec struct {
    52  	// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
    53  	// Important: Run "make" to regenerate code after modifying this file
    54  
    55  	PolicyRules []PolicyRule `json:"rules,omitempty" protobuf:"bytes,8,opt,name=rules"`
    56  }
    57  
    58  // AuditRuleStatus defines the observed state of Rule
    59  type RuleStatus struct {
    60  	// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
    61  	// Important: Run "make" to regenerate code after modifying this file
    62  }
    63  
    64  // +genclient
    65  // +genclient:noStatus
    66  // +genclient:nonNamespaced
    67  // +kubebuilder:object:root=true
    68  
    69  // Rule is the Schema for the rules API
    70  type Rule struct {
    71  	metav1.TypeMeta   `json:",inline"`
    72  	metav1.ObjectMeta `json:"metadata,omitempty"`
    73  
    74  	Spec   RuleSpec   `json:"spec,omitempty"`
    75  	Status RuleStatus `json:"status,omitempty"`
    76  }
    77  
    78  // +kubebuilder:object:root=true
    79  
    80  // AuditRuleList contains a list of Rule
    81  type RuleList struct {
    82  	metav1.TypeMeta `json:",inline"`
    83  	metav1.ListMeta `json:"metadata,omitempty"`
    84  	Items           []Rule `json:"items"`
    85  }
    86  
    87  func init() {
    88  	SchemeBuilder.Register(&Rule{}, &RuleList{})
    89  }