interfaces.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. Copyright 2016 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 schema
  14. // All objects that are serialized from a Scheme encode their type information. This interface is used
  15. // by serialization to set type information from the Scheme onto the serialized version of an object.
  16. // For objects that cannot be serialized or have unique requirements, this interface may be a no-op.
  17. type ObjectKind interface {
  18. // SetGroupVersionKind sets or clears the intended serialized kind of an object. Passing kind nil
  19. // should clear the current setting.
  20. SetGroupVersionKind(kind GroupVersionKind)
  21. // GroupVersionKind returns the stored group, version, and kind of an object, or nil if the object does
  22. // not expose or provide these fields.
  23. GroupVersionKind() GroupVersionKind
  24. }
  25. // EmptyObjectKind implements the ObjectKind interface as a noop
  26. var EmptyObjectKind = emptyObjectKind{}
  27. type emptyObjectKind struct{}
  28. // SetGroupVersionKind implements the ObjectKind interface
  29. func (emptyObjectKind) SetGroupVersionKind(gvk GroupVersionKind) {}
  30. // GroupVersionKind implements the ObjectKind interface
  31. func (emptyObjectKind) GroupVersionKind() GroupVersionKind { return GroupVersionKind{} }