1 /* 2 Copyright 2018 The Kubernetes Authors. 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 http://www.apache.org/licenses/LICENSE-2.0 7 Unless required by applicable law or agreed to in writing, software 8 distributed under the License is distributed on an "AS IS" BASIS, 9 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 See the License for the specific language governing permissions and 11 limitations under the License. 12 */ 13 14 package v1 15 16 import ( 17 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 18 "k8s.io/apimachinery/pkg/runtime" 19 "k8s.io/apimachinery/pkg/runtime/schema" 20 ) 21 22 // GroupName is the group name use in this package. 23 const GroupName = "snapshot.storage.k8s.io" 24 25 var ( 26 // SchemeBuilder is the new scheme builder 27 SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) 28 // AddToScheme adds to scheme 29 AddToScheme = SchemeBuilder.AddToScheme 30 // SchemeGroupVersion is the group version used to register these objects. 31 SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"} 32 ) 33 34 // Resource takes an unqualified resource and returns a Group-qualified GroupResource. 35 func Resource(resource string) schema.GroupResource { 36 return SchemeGroupVersion.WithResource(resource).GroupResource() 37 } 38 39 func init() { 40 // We only register manually written functions here. The registration of the 41 // generated functions takes place in the generated files. The separation 42 // makes the code compile even when the generated files are missing. 43 SchemeBuilder.Register(addKnownTypes) 44 } 45 46 // addKnownTypes adds the set of types defined in this package to the supplied scheme. 47 func addKnownTypes(scheme *runtime.Scheme) error { 48 scheme.AddKnownTypes(SchemeGroupVersion, 49 &VolumeSnapshotClass{}, 50 &VolumeSnapshotClassList{}, 51 &VolumeSnapshot{}, 52 &VolumeSnapshotList{}, 53 &VolumeSnapshotContent{}, 54 &VolumeSnapshotContentList{}, 55 ) 56 metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 57 return nil 58 } 59