2014-10-29 16:33:46 +00:00
|
|
|
/*
|
2015-05-01 16:19:44 +00:00
|
|
|
Copyright 2014 The Kubernetes Authors All rights reserved.
|
2014-10-29 16:33:46 +00:00
|
|
|
|
|
|
|
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 (
|
2015-11-13 13:13:55 +00:00
|
|
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
2015-08-05 22:03:47 +00:00
|
|
|
"k8s.io/kubernetes/pkg/runtime"
|
|
|
|
"k8s.io/kubernetes/pkg/types"
|
2014-10-29 16:33:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// VersionInterfaces contains the interfaces one should use for dealing with types of a particular version.
|
|
|
|
type VersionInterfaces struct {
|
|
|
|
runtime.Codec
|
2014-11-02 14:31:29 +00:00
|
|
|
runtime.ObjectConvertor
|
2014-10-29 16:33:46 +00:00
|
|
|
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.
|
2015-01-19 02:22:55 +00:00
|
|
|
// TODO: rename to ObjectInterface when we clear up these interfaces.
|
2014-10-29 16:33:46 +00:00
|
|
|
type Interface interface {
|
2015-01-19 02:22:55 +00:00
|
|
|
TypeInterface
|
|
|
|
|
2014-10-29 16:33:46 +00:00
|
|
|
Namespace() string
|
|
|
|
SetNamespace(namespace string)
|
|
|
|
Name() string
|
|
|
|
SetName(name string)
|
2015-04-14 22:03:26 +00:00
|
|
|
GenerateName() string
|
|
|
|
SetGenerateName(name string)
|
2015-01-14 23:22:21 +00:00
|
|
|
UID() types.UID
|
|
|
|
SetUID(uid types.UID)
|
2014-10-29 16:33:46 +00:00
|
|
|
ResourceVersion() string
|
|
|
|
SetResourceVersion(version string)
|
|
|
|
SelfLink() string
|
|
|
|
SetSelfLink(selfLink string)
|
2014-11-28 20:06:07 +00:00
|
|
|
Labels() map[string]string
|
|
|
|
SetLabels(labels map[string]string)
|
|
|
|
Annotations() map[string]string
|
|
|
|
SetAnnotations(annotations map[string]string)
|
2014-10-29 16:33:46 +00:00
|
|
|
}
|
|
|
|
|
2015-01-19 02:22:55 +00:00
|
|
|
// TypeInterface exposes the type and APIVersion of versioned or internal API objects.
|
|
|
|
type TypeInterface interface {
|
|
|
|
APIVersion() string
|
|
|
|
SetAPIVersion(version string)
|
|
|
|
Kind() string
|
|
|
|
SetKind(kind string)
|
|
|
|
}
|
|
|
|
|
2014-10-29 16:33:46 +00:00
|
|
|
// 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
|
|
|
|
|
2015-04-14 22:03:26 +00:00
|
|
|
GenerateName(obj runtime.Object) (string, error)
|
|
|
|
SetGenerateName(obj runtime.Object, name string) error
|
|
|
|
|
2015-01-14 23:22:21 +00:00
|
|
|
UID(obj runtime.Object) (types.UID, error)
|
|
|
|
SetUID(obj runtime.Object, uid types.UID) error
|
2014-10-29 16:33:46 +00:00
|
|
|
|
|
|
|
SelfLink(obj runtime.Object) (string, error)
|
|
|
|
SetSelfLink(obj runtime.Object, selfLink string) error
|
|
|
|
|
2014-11-28 20:06:07 +00:00
|
|
|
Labels(obj runtime.Object) (map[string]string, error)
|
|
|
|
SetLabels(obj runtime.Object, labels map[string]string) error
|
|
|
|
|
|
|
|
Annotations(obj runtime.Object) (map[string]string, error)
|
|
|
|
SetAnnotations(obj runtime.Object, annotations map[string]string) error
|
|
|
|
|
2014-10-29 16:33:46 +00:00
|
|
|
runtime.ResourceVersioner
|
|
|
|
}
|
|
|
|
|
2015-01-29 22:46:54 +00:00
|
|
|
type RESTScopeName string
|
|
|
|
|
|
|
|
const (
|
|
|
|
RESTScopeNameNamespace RESTScopeName = "namespace"
|
|
|
|
RESTScopeNameRoot RESTScopeName = "root"
|
|
|
|
)
|
|
|
|
|
|
|
|
// RESTScope contains the information needed to deal with REST resources that are in a resource hierarchy
|
|
|
|
type RESTScope interface {
|
|
|
|
// Name of the scope
|
|
|
|
Name() RESTScopeName
|
2015-01-29 16:35:06 +00:00
|
|
|
// ParamName is the optional name of the parameter that should be inserted in the resource url
|
|
|
|
// If empty, no param will be inserted
|
2015-01-29 22:46:54 +00:00
|
|
|
ParamName() string
|
2015-06-18 20:20:28 +00:00
|
|
|
// ArgumentName is the optional name that should be used for the variable holding the value.
|
|
|
|
ArgumentName() string
|
2015-01-29 16:35:06 +00:00
|
|
|
// ParamDescription is the optional description to use to document the parameter in api documentation
|
2015-01-29 22:46:54 +00:00
|
|
|
ParamDescription() string
|
2015-01-29 16:35:06 +00:00
|
|
|
}
|
|
|
|
|
2014-10-29 16:33:46 +00:00
|
|
|
// 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
|
2015-11-13 13:13:55 +00:00
|
|
|
|
|
|
|
GroupVersionKind unversioned.GroupVersionKind
|
2014-10-29 16:33:46 +00:00
|
|
|
|
2015-01-29 16:35:06 +00:00
|
|
|
// Scope contains the information needed to deal with REST Resources that are in a resource hierarchy
|
|
|
|
Scope RESTScope
|
|
|
|
|
2014-10-29 16:33:46 +00:00
|
|
|
runtime.Codec
|
2014-11-02 14:31:29 +00:00
|
|
|
runtime.ObjectConvertor
|
2014-10-29 16:33:46 +00:00
|
|
|
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
|
2015-09-17 10:26:01 +00:00
|
|
|
// consumers of Kubernetes compatible REST APIs as defined in docs/devel/api-conventions.md.
|
2015-08-12 18:29:05 +00:00
|
|
|
//
|
|
|
|
// The Kubernetes API provides versioned resources and object kinds which are scoped
|
|
|
|
// to API groups. In other words, kinds and resources should not be assumed to be
|
|
|
|
// unique across groups.
|
|
|
|
//
|
|
|
|
// TODO(caesarxuchao): Add proper multi-group support so that kinds & resources are
|
|
|
|
// scoped to groups. See http://issues.k8s.io/12413 and http://issues.k8s.io/10009.
|
2014-10-29 16:33:46 +00:00
|
|
|
type RESTMapper interface {
|
2015-11-16 20:14:27 +00:00
|
|
|
// KindFor takes a resource and returns back the unambiguous Kind (GroupVersionKind)
|
|
|
|
KindFor(resource string) (unversioned.GroupVersionKind, error)
|
|
|
|
|
2014-12-12 19:05:27 +00:00
|
|
|
RESTMapping(kind string, versions ...string) (*RESTMapping, error)
|
2015-04-08 15:05:41 +00:00
|
|
|
AliasesForResource(resource string) ([]string, bool)
|
2015-07-01 22:47:43 +00:00
|
|
|
ResourceSingularizer(resource string) (singular string, err error)
|
2015-09-24 01:17:09 +00:00
|
|
|
ResourceIsValid(resource string) bool
|
2014-10-29 16:33:46 +00:00
|
|
|
}
|