register.go 2.2 KB

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