knative.dev/pkg@v0.0.0-20260602142205-ac97e43f6622/apis/test/example/v1alpha1/fiz_types.go (about) 1 /* 2 Copyright 2020 The Knative 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 "context" 21 22 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 23 "k8s.io/apimachinery/pkg/runtime/schema" 24 "knative.dev/pkg/apis" 25 duckv1 "knative.dev/pkg/apis/duck/v1" 26 "knative.dev/pkg/kmeta" 27 ) 28 29 // +genclient 30 // +genclient:nonNamespaced 31 // +genreconciler 32 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 33 34 // ClusterFiz is for testing. 35 type ClusterFiz struct { 36 metav1.TypeMeta `json:",inline"` 37 // +optional 38 metav1.ObjectMeta `json:"metadata,omitempty"` 39 40 // Spec holds the desired state of the ClusterFiz (from the client). 41 // +optional 42 Spec ClusterFizSpec `json:"spec,omitempty"` 43 44 // Status communicates the observed state of the ClusterFiz (from the controller). 45 // +optional 46 Status ClusterFizStatus `json:"status,omitempty"` 47 } 48 49 // Check that ClusterFiz can be validated and defaulted. 50 var ( 51 _ apis.Validatable = (*ClusterFiz)(nil) 52 _ apis.Defaultable = (*ClusterFiz)(nil) 53 _ kmeta.OwnerRefable = (*ClusterFiz)(nil) 54 _ duckv1.KRShaped = (*ClusterFiz)(nil) 55 ) 56 57 // ClusterFizSpec holds the desired state of the ClusterFiz (from the client). 58 type ClusterFizSpec struct{} 59 60 // ClusterFizStatus communicates the observed state of the ClusterFiz (from the controller). 61 type ClusterFizStatus struct { 62 duckv1.Status `json:",inline"` 63 } 64 65 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 66 67 // ClusterFizList is a list of ClusterFiz resources 68 type ClusterFizList struct { 69 metav1.TypeMeta `json:",inline"` 70 metav1.ListMeta `json:"metadata"` 71 72 Items []ClusterFiz `json:"items"` 73 } 74 75 // -- lifecycle -- 76 77 func (fs *ClusterFizStatus) InitializeConditions() {} 78 79 // GetGroupVersionKind implements kmeta.OwnerRefable 80 func (f *ClusterFiz) GetGroupVersionKind() schema.GroupVersionKind { 81 return SchemeGroupVersion.WithKind("Bar") 82 } 83 84 // -- Defaults -- 85 86 // SetDefaults implements apis.Defaultable 87 func (f *ClusterFiz) SetDefaults(ctx context.Context) { 88 // Nothing to default. 89 } 90 91 // -- Validation -- 92 93 // Validate implements apis.Validatable 94 func (f *ClusterFiz) Validate(ctx context.Context) *apis.FieldError { 95 // Nothing to validate. 96 return nil 97 } 98 99 // GetStatus retrieves the status of the ClusterFiz. Implements the KRShaped interface. 100 func (f *ClusterFiz) GetStatus() *duckv1.Status { 101 return &f.Status.Status 102 } 103 104 // GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface. 105 func (*ClusterFiz) GetConditionSet() apis.ConditionSet { 106 return apis.NewLivingConditionSet() 107 }