github.com/oam-dev/kubevela@v1.9.11/pkg/oam/types.go (about) 1 /* 2 Copyright 2019 The Crossplane 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 oam contains miscellaneous OAM helper types. 18 package oam 19 20 import ( 21 "context" 22 23 "github.com/oam-dev/kubevela/apis/core.oam.dev/condition" 24 25 corev1 "k8s.io/api/core/v1" 26 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 27 "k8s.io/apimachinery/pkg/runtime" 28 "k8s.io/apimachinery/pkg/runtime/schema" 29 ) 30 31 // TraitKind contains the type metadata for a kind of an OAM trait resource. 32 type TraitKind schema.GroupVersionKind 33 34 // WorkloadKind contains the type metadata for a kind of an OAM workload resource. 35 type WorkloadKind schema.GroupVersionKind 36 37 // A Conditioned may have conditions set or retrieved. Conditions are typically 38 // indicate the status of both a resource and its reconciliation process. 39 type Conditioned interface { 40 SetConditions(c ...condition.Condition) 41 GetCondition(condition.ConditionType) condition.Condition 42 } 43 44 // A WorkloadReferencer may reference an OAM workload. 45 type WorkloadReferencer interface { 46 GetWorkloadReference() corev1.ObjectReference 47 SetWorkloadReference(corev1.ObjectReference) 48 } 49 50 // A WorkloadsReferencer may reference an OAM workload. 51 type WorkloadsReferencer interface { 52 GetWorkloadReferences() []corev1.ObjectReference 53 AddWorkloadReference(corev1.ObjectReference) 54 } 55 56 // A Finalizer manages the finalizers on the resource. 57 type Finalizer interface { 58 AddFinalizer(ctx context.Context, obj Object) error 59 RemoveFinalizer(ctx context.Context, obj Object) error 60 } 61 62 // An Object is a Kubernetes object. 63 type Object interface { 64 metav1.Object 65 runtime.Object 66 } 67 68 // A Trait is a type of OAM trait. 69 type Trait interface { 70 Object 71 72 Conditioned 73 WorkloadReferencer 74 } 75 76 // A Workload is a type of OAM workload. 77 type Workload interface { 78 Object 79 80 Conditioned 81 }