| 1 |
/* |
| 2 |
Copyright 2017 The Kubernetes 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 |
"k8s.io/apimachinery/pkg/apis/meta/v1" |
| 21 |
"k8s.io/apimachinery/pkg/conversion" |
| 22 |
"k8s.io/apimachinery/pkg/runtime" |
| 23 |
"k8s.io/apimachinery/pkg/runtime/schema" |
| 24 |
) |
| 25 |
|
| 26 |
// GroupName is the group name for this API. |
| 27 |
const GroupName = "meta.k8s.io" |
| 28 |
|
| 29 |
// SchemeGroupVersion is group version used to register these objects |
| 30 |
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} |
| 31 |
|
| 32 |
// Kind takes an unqualified kind and returns a Group qualified GroupKind |
| 33 |
func Kind(kind string) schema.GroupKind { |
| 34 |
return SchemeGroupVersion.WithKind(kind).GroupKind() |
| 35 |
} |
| 36 |
|
| 37 |
// AddMetaToScheme registers base meta types into schemas. |
| 38 |
func AddMetaToScheme(scheme *runtime.Scheme) error { |
| 39 |
scheme.AddKnownTypes(SchemeGroupVersion, |
| 40 |
&Table{}, |
| 41 |
&TableOptions{}, |
| 42 |
&PartialObjectMetadata{}, |
| 43 |
&PartialObjectMetadataList{}, |
| 44 |
) |
| 45 |
|
| 46 |
return nil |
| 47 |
} |
| 48 |
|
| 49 |
// RegisterConversions adds conversion functions to the given scheme. |
| 50 |
func RegisterConversions(s *runtime.Scheme) error { |
| 51 |
if err := s.AddGeneratedConversionFunc((*PartialObjectMetadataList)(nil), (*v1.PartialObjectMetadataList)(nil), func(a, b interface{}, scope conversion.Scope) error { |
| 52 |
return Convert_v1beta1_PartialObjectMetadataList_To_v1_PartialObjectMetadataList(a.(*PartialObjectMetadataList), b.(*v1.PartialObjectMetadataList), scope) |
| 53 |
}); err != nil { |
| 54 |
return err |
| 55 |
} |
| 56 |
if err := s.AddGeneratedConversionFunc((*v1.PartialObjectMetadataList)(nil), (*PartialObjectMetadataList)(nil), func(a, b interface{}, scope conversion.Scope) error { |
| 57 |
return Convert_v1_PartialObjectMetadataList_To_v1beta1_PartialObjectMetadataList(a.(*v1.PartialObjectMetadataList), b.(*PartialObjectMetadataList), scope) |
| 58 |
}); err != nil { |
| 59 |
return err |
| 60 |
} |
| 61 |
return nil |
| 62 |
} |