blob: b5706684587c50c48b9e3ad2bd4635bf8d385917 [file] [log] [blame]
Scott Bakere7144bc2019-10-01 14:16:47 -07001/*
2Copyright 2016 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package 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.
22type 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
32var EmptyObjectKind = emptyObjectKind{}
33
34type emptyObjectKind struct{}
35
36// SetGroupVersionKind implements the ObjectKind interface
37func (emptyObjectKind) SetGroupVersionKind(gvk GroupVersionKind) {}
38
39// GroupVersionKind implements the ObjectKind interface
40func (emptyObjectKind) GroupVersionKind() GroupVersionKind { return GroupVersionKind{} }