Matteo Scandolo | a428586 | 2020-12-01 18:10:10 -0800 | [diff] [blame^] | 1 | /* |
| 2 | Copyright 2016 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 schema |
| 18 | |
| 19 | // All objects that are serialized from a Scheme encode their type information. This interface is used |
| 20 | // by serialization to set type information from the Scheme onto the serialized version of an object. |
| 21 | // For objects that cannot be serialized or have unique requirements, this interface may be a no-op. |
| 22 | type ObjectKind interface { |
| 23 | // SetGroupVersionKind sets or clears the intended serialized kind of an object. Passing kind nil |
| 24 | // should clear the current setting. |
| 25 | SetGroupVersionKind(kind GroupVersionKind) |
| 26 | // GroupVersionKind returns the stored group, version, and kind of an object, or nil if the object does |
| 27 | // not expose or provide these fields. |
| 28 | GroupVersionKind() GroupVersionKind |
| 29 | } |
| 30 | |
| 31 | // EmptyObjectKind implements the ObjectKind interface as a noop |
| 32 | var EmptyObjectKind = emptyObjectKind{} |
| 33 | |
| 34 | type emptyObjectKind struct{} |
| 35 | |
| 36 | // SetGroupVersionKind implements the ObjectKind interface |
| 37 | func (emptyObjectKind) SetGroupVersionKind(gvk GroupVersionKind) {} |
| 38 | |
| 39 | // GroupVersionKind implements the ObjectKind interface |
| 40 | func (emptyObjectKind) GroupVersionKind() GroupVersionKind { return GroupVersionKind{} } |