2014-10-29 16:33:46 +00:00
|
|
|
/*
|
|
|
|
Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package meta
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
|
|
|
)
|
|
|
|
|
|
|
|
// VersionInterfaces contains the interfaces one should use for dealing with types of a particular version.
|
|
|
|
type VersionInterfaces struct {
|
|
|
|
runtime.Codec
|
|
|
|
MetadataAccessor
|
|
|
|
}
|
|
|
|
|
|
|
|
// Interface lets you work with object and list metadata from any of the versioned or
|
|
|
|
// internal API objects. Attempting to set or retrieve a field on an object that does
|
|
|
|
// not support that field (Name, UID, Namespace on lists) will be a no-op and return
|
|
|
|
// a default value.
|
|
|
|
type Interface interface {
|
|
|
|
Namespace() string
|
|
|
|
SetNamespace(namespace string)
|
|
|
|
Name() string
|
|
|
|
SetName(name string)
|
|
|
|
UID() string
|
|
|
|
SetUID(uid string)
|
|
|
|
APIVersion() string
|
|
|
|
SetAPIVersion(version string)
|
|
|
|
Kind() string
|
|
|
|
SetKind(kind string)
|
|
|
|
ResourceVersion() string
|
|
|
|
SetResourceVersion(version string)
|
|
|
|
SelfLink() string
|
|
|
|
SetSelfLink(selfLink string)
|
|
|
|
}
|
|
|
|
|
|
|
|
// MetadataAccessor lets you work with object and list metadata from any of the versioned or
|
|
|
|
// internal API objects. Attempting to set or retrieve a field on an object that does
|
|
|
|
// not support that field (Name, UID, Namespace on lists) will be a no-op and return
|
|
|
|
// a default value.
|
|
|
|
//
|
|
|
|
// MetadataAccessor exposes Interface in a way that can be used with multiple objects.
|
|
|
|
type MetadataAccessor interface {
|
|
|
|
APIVersion(obj runtime.Object) (string, error)
|
|
|
|
SetAPIVersion(obj runtime.Object, version string) error
|
|
|
|
|
|
|
|
Kind(obj runtime.Object) (string, error)
|
|
|
|
SetKind(obj runtime.Object, kind string) error
|
|
|
|
|
|
|
|
Namespace(obj runtime.Object) (string, error)
|
|
|
|
SetNamespace(obj runtime.Object, namespace string) error
|
|
|
|
|
|
|
|
Name(obj runtime.Object) (string, error)
|
|
|
|
SetName(obj runtime.Object, name string) error
|
|
|
|
|
|
|
|
UID(obj runtime.Object) (string, error)
|
|
|
|
SetUID(obj runtime.Object, uid string) error
|
|
|
|
|
|
|
|
SelfLink(obj runtime.Object) (string, error)
|
|
|
|
SetSelfLink(obj runtime.Object, selfLink string) error
|
|
|
|
|
|
|
|
runtime.ResourceVersioner
|
|
|
|
}
|
|
|
|
|
|
|
|
// RESTMapping contains the information needed to deal with objects of a specific
|
|
|
|
// resource and kind in a RESTful manner.
|
|
|
|
type RESTMapping struct {
|
|
|
|
// Resource is a string representing the name of this resource as a REST client would see it
|
|
|
|
Resource string
|
|
|
|
// APIVersion represents the APIVersion that represents the resource as presented. It is provided
|
|
|
|
// for convenience for passing around a consistent mapping.
|
|
|
|
APIVersion string
|
2014-11-02 14:21:25 +00:00
|
|
|
Kind string
|
2014-10-29 16:33:46 +00:00
|
|
|
|
|
|
|
runtime.Codec
|
|
|
|
MetadataAccessor
|
|
|
|
}
|
|
|
|
|
|
|
|
// RESTMapper allows clients to map resources to kind, and map kind and version
|
|
|
|
// to interfaces for manipulating those objects. It is primarily intended for
|
|
|
|
// consumers of Kubernetes compatible REST APIs as defined in docs/api-conventions.md.
|
|
|
|
type RESTMapper interface {
|
|
|
|
VersionAndKindForResource(resource string) (defaultVersion, kind string, err error)
|
|
|
|
RESTMapping(version, kind string) (*RESTMapping, error)
|
|
|
|
}
|