kubevirt.io/api@v1.2.0/clone/v1alpha1/register.go (about) 1 /* 2 * This file is part of the KubeVirt project 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 * Copyright 2022 Red Hat, Inc. 17 * 18 */ 19 20 package v1alpha1 21 22 import ( 23 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 "k8s.io/apimachinery/pkg/runtime" 25 "k8s.io/apimachinery/pkg/runtime/schema" 26 27 "kubevirt.io/api/clone" 28 ) 29 30 var ( 31 // SchemeGroupVersion is group version used to register these objects 32 SchemeGroupVersion = schema.GroupVersion{Group: clone.GroupName, Version: clone.LatestVersion} 33 34 VirtualMachineCloneKind = schema.GroupVersionKind{Group: clone.GroupName, Version: clone.LatestVersion, Kind: clone.Kind} 35 VirtualMachineCloneListKind = schema.GroupVersionKind{Group: clone.GroupName, Version: clone.LatestVersion, Kind: clone.ListKind} 36 ) 37 38 // Kind takes an unqualified kind and returns back a Group qualified GroupKind 39 func Kind(kind string) schema.GroupKind { 40 return SchemeGroupVersion.WithKind(kind).GroupKind() 41 } 42 43 // Resource takes an unqualified resource and returns a Group qualified GroupResource 44 func Resource(resource string) schema.GroupResource { 45 return SchemeGroupVersion.WithResource(resource).GroupResource() 46 } 47 48 var ( 49 // SchemeBuilder initializes a scheme builder 50 SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) 51 // AddToScheme is a global function that registers this API group & version to a scheme 52 AddToScheme = SchemeBuilder.AddToScheme 53 ) 54 55 // Adds the list of known types to Scheme. 56 func addKnownTypes(scheme *runtime.Scheme) error { 57 scheme.AddKnownTypes(SchemeGroupVersion, 58 &VirtualMachineClone{}, 59 &VirtualMachineCloneList{}, 60 ) 61 62 metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 63 return nil 64 }