github.com/oam-dev/kubevela@v1.9.11/apis/core.oam.dev/v1beta1/policy_definition.go (about) 1 /* 2 Copyright 2021. The KubeVela 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 v1beta1 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 22 "github.com/oam-dev/kubevela/apis/core.oam.dev/condition" 23 24 "github.com/oam-dev/kubevela/apis/core.oam.dev/common" 25 ) 26 27 // PolicyDefinitionSpec defines the desired state of PolicyDefinition 28 type PolicyDefinitionSpec struct { 29 // Reference to the CustomResourceDefinition that defines this trait kind. 30 Reference common.DefinitionReference `json:"definitionRef,omitempty"` 31 32 // Schematic defines the data format and template of the encapsulation of the policy definition. 33 // Only CUE schematic is supported for now. 34 // +optional 35 Schematic *common.Schematic `json:"schematic,omitempty"` 36 37 // ManageHealthCheck means the policy will handle health checking and skip application controller 38 // built-in health checking. 39 ManageHealthCheck bool `json:"manageHealthCheck,omitempty"` 40 } 41 42 // PolicyDefinitionStatus is the status of PolicyDefinition 43 type PolicyDefinitionStatus struct { 44 // ConditionedStatus reflects the observed status of a resource 45 condition.ConditionedStatus `json:",inline"` 46 47 // ConfigMapRef refer to a ConfigMap which contains OpenAPI V3 JSON schema of Component parameters. 48 ConfigMapRef string `json:"configMapRef,omitempty"` 49 50 // LatestRevision of the component definition 51 // +optional 52 LatestRevision *common.Revision `json:"latestRevision,omitempty"` 53 } 54 55 // SetConditions set condition for PolicyDefinition 56 func (d *PolicyDefinition) SetConditions(c ...condition.Condition) { 57 d.Status.SetConditions(c...) 58 } 59 60 // GetCondition gets condition from PolicyDefinition 61 func (d *PolicyDefinition) GetCondition(conditionType condition.ConditionType) condition.Condition { 62 return d.Status.GetCondition(conditionType) 63 } 64 65 // +kubebuilder:object:root=true 66 67 // PolicyDefinition is the Schema for the policydefinitions API 68 // +kubebuilder:resource:scope=Namespaced,categories={oam},shortName=def-policy 69 // +kubebuilder:storageversion 70 // +kubebuilder:subresource:status 71 // +genclient 72 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 73 type PolicyDefinition struct { 74 metav1.TypeMeta `json:",inline"` 75 metav1.ObjectMeta `json:"metadata,omitempty"` 76 77 Spec PolicyDefinitionSpec `json:"spec,omitempty"` 78 Status PolicyDefinitionStatus `json:"status,omitempty"` 79 } 80 81 // +kubebuilder:object:root=true 82 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 83 84 // PolicyDefinitionList contains a list of PolicyDefinition 85 type PolicyDefinitionList struct { 86 metav1.TypeMeta `json:",inline"` 87 metav1.ListMeta `json:"metadata,omitempty"` 88 Items []PolicyDefinition `json:"items"` 89 }