register.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. Copyright 2015 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 abac
  14. import (
  15. "k8s.io/apimachinery/pkg/runtime"
  16. "k8s.io/apimachinery/pkg/runtime/schema"
  17. "k8s.io/apimachinery/pkg/runtime/serializer"
  18. )
  19. // GroupName is the API group for abac
  20. const GroupName = "abac.authorization.kubernetes.io"
  21. // SchemeGroupVersion is the API group version used to register abac internal
  22. var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
  23. // Scheme is the default instance of runtime.Scheme to which types in the abac API group are api.Registry.
  24. // TODO: remove this, abac should not have its own scheme.
  25. var Scheme = runtime.NewScheme()
  26. // Codecs provides access to encoding and decoding for the scheme
  27. var Codecs = serializer.NewCodecFactory(Scheme)
  28. func init() {
  29. // TODO: delete this, abac should not have its own scheme.
  30. addKnownTypes(Scheme)
  31. }
  32. var (
  33. // SchemeBuilder is the scheme builder with scheme init functions to run for this API package
  34. SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
  35. // AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme
  36. AddToScheme = SchemeBuilder.AddToScheme
  37. )
  38. func addKnownTypes(scheme *runtime.Scheme) error {
  39. scheme.AddKnownTypes(SchemeGroupVersion,
  40. &Policy{},
  41. )
  42. return nil
  43. }