Switch to versioned ListOptions in server.

pull/6/head
Wojciech Tyczynski 2015-12-16 14:02:09 +01:00
parent 837a070d2f
commit 58336829be
34 changed files with 218 additions and 232 deletions

View File

@ -39,14 +39,6 @@ func init() {
obj.FieldSelector = fields.Everything() obj.FieldSelector = fields.Everything()
} }
}, },
func(obj *unversioned.ListOptions) {
if obj.LabelSelector.Selector == nil {
obj.LabelSelector = unversioned.LabelSelector{labels.Everything()}
}
if obj.FieldSelector.Selector == nil {
obj.FieldSelector = unversioned.FieldSelector{fields.Everything()}
}
},
) )
Scheme.AddConversionFuncs( Scheme.AddConversionFuncs(
func(in *unversioned.Time, out *unversioned.Time, s conversion.Scope) error { func(in *unversioned.Time, out *unversioned.Time, s conversion.Scope) error {

View File

@ -24,6 +24,8 @@ import (
resource "k8s.io/kubernetes/pkg/api/resource" resource "k8s.io/kubernetes/pkg/api/resource"
unversioned "k8s.io/kubernetes/pkg/api/unversioned" unversioned "k8s.io/kubernetes/pkg/api/unversioned"
conversion "k8s.io/kubernetes/pkg/conversion" conversion "k8s.io/kubernetes/pkg/conversion"
fields "k8s.io/kubernetes/pkg/fields"
labels "k8s.io/kubernetes/pkg/labels"
runtime "k8s.io/kubernetes/pkg/runtime" runtime "k8s.io/kubernetes/pkg/runtime"
intstr "k8s.io/kubernetes/pkg/util/intstr" intstr "k8s.io/kubernetes/pkg/util/intstr"
inf "speter.net/go/exp/math/dec/inf" inf "speter.net/go/exp/math/dec/inf"
@ -807,6 +809,35 @@ func deepCopy_api_List(in List, out *List, c *conversion.Cloner) error {
return nil return nil
} }
func deepCopy_api_ListOptions(in ListOptions, out *ListOptions, c *conversion.Cloner) error {
if err := deepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
}
if newVal, err := c.DeepCopy(in.LabelSelector); err != nil {
return err
} else if newVal == nil {
out.LabelSelector = nil
} else {
out.LabelSelector = newVal.(labels.Selector)
}
if newVal, err := c.DeepCopy(in.FieldSelector); err != nil {
return err
} else if newVal == nil {
out.FieldSelector = nil
} else {
out.FieldSelector = newVal.(fields.Selector)
}
out.Watch = in.Watch
out.ResourceVersion = in.ResourceVersion
if in.TimeoutSeconds != nil {
out.TimeoutSeconds = new(int64)
*out.TimeoutSeconds = *in.TimeoutSeconds
} else {
out.TimeoutSeconds = nil
}
return nil
}
func deepCopy_api_LoadBalancerIngress(in LoadBalancerIngress, out *LoadBalancerIngress, c *conversion.Cloner) error { func deepCopy_api_LoadBalancerIngress(in LoadBalancerIngress, out *LoadBalancerIngress, c *conversion.Cloner) error {
out.IP = in.IP out.IP = in.IP
out.Hostname = in.Hostname out.Hostname = in.Hostname
@ -2386,6 +2417,7 @@ func init() {
deepCopy_api_LimitRangeList, deepCopy_api_LimitRangeList,
deepCopy_api_LimitRangeSpec, deepCopy_api_LimitRangeSpec,
deepCopy_api_List, deepCopy_api_List,
deepCopy_api_ListOptions,
deepCopy_api_LoadBalancerIngress, deepCopy_api_LoadBalancerIngress,
deepCopy_api_LoadBalancerStatus, deepCopy_api_LoadBalancerStatus,
deepCopy_api_LocalObjectReference, deepCopy_api_LocalObjectReference,

View File

@ -89,7 +89,6 @@ func init() {
// Register Unversioned types // Register Unversioned types
// TODO this should not be done here // TODO this should not be done here
Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.ExportOptions{}) Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.ExportOptions{})
Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.ListOptions{})
Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.Status{}) Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.Status{})
Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.APIVersions{}) Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.APIVersions{})
Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.APIGroupList{}) Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.APIGroupList{})

View File

@ -61,7 +61,7 @@ type Lister interface {
// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object) // This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
NewList() runtime.Object NewList() runtime.Object
// List selects resources in the storage which match to the selector. 'options' can be nil. // List selects resources in the storage which match to the selector. 'options' can be nil.
List(ctx api.Context, options *unversioned.ListOptions) (runtime.Object, error) List(ctx api.Context, options *api.ListOptions) (runtime.Object, error)
} }
// Exporter is an object that knows how to strip a RESTful resource for export // Exporter is an object that knows how to strip a RESTful resource for export
@ -141,7 +141,7 @@ type CollectionDeleter interface {
// them or return an invalid request error. // them or return an invalid request error.
// DeleteCollection may not be atomic - i.e. it may delete some objects and still // DeleteCollection may not be atomic - i.e. it may delete some objects and still
// return an error after it. On success, returns a list of deleted objects. // return an error after it. On success, returns a list of deleted objects.
DeleteCollection(ctx api.Context, options *api.DeleteOptions, listOptions *unversioned.ListOptions) (runtime.Object, error) DeleteCollection(ctx api.Context, options *api.DeleteOptions, listOptions *api.ListOptions) (runtime.Object, error)
} }
// Creater is an object that can create an instance of a RESTful object. // Creater is an object that can create an instance of a RESTful object.
@ -201,7 +201,7 @@ type Watcher interface {
// are supported; an error should be returned if 'field' tries to select on a field that // are supported; an error should be returned if 'field' tries to select on a field that
// isn't supported. 'resourceVersion' allows for continuing/starting a watch at a // isn't supported. 'resourceVersion' allows for continuing/starting a watch at a
// particular version. // particular version.
Watch(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) Watch(ctx api.Context, options *api.ListOptions) (watch.Interface, error)
} }
// StandardStorage is an interface covering the common verbs. Provided for testing whether a // StandardStorage is an interface covering the common verbs. Provided for testing whether a

View File

@ -864,7 +864,7 @@ func (t *Tester) testListMatchLabels(obj runtime.Object, assignFn AssignFunc) {
filtered := []runtime.Object{objs[1]} filtered := []runtime.Object{objs[1]}
selector := labels.SelectorFromSet(labels.Set(testLabels)) selector := labels.SelectorFromSet(labels.Set(testLabels))
options := &unversioned.ListOptions{LabelSelector: unversioned.LabelSelector{selector}} options := &api.ListOptions{LabelSelector: selector}
listObj, err := t.storage.(rest.Lister).List(ctx, options) listObj, err := t.storage.(rest.Lister).List(ctx, options)
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
@ -906,7 +906,7 @@ func (t *Tester) testWatchFields(obj runtime.Object, emitFn EmitFunc, fieldsPass
for _, field := range fieldsPass { for _, field := range fieldsPass {
for _, action := range actions { for _, action := range actions {
options := &unversioned.ListOptions{FieldSelector: unversioned.FieldSelector{field.AsSelector()}, ResourceVersion: "1"} options := &api.ListOptions{FieldSelector: field.AsSelector(), ResourceVersion: "1"}
watcher, err := t.storage.(rest.Watcher).Watch(ctx, options) watcher, err := t.storage.(rest.Watcher).Watch(ctx, options)
if err != nil { if err != nil {
t.Errorf("unexpected error: %v, %v", err, action) t.Errorf("unexpected error: %v, %v", err, action)
@ -930,7 +930,7 @@ func (t *Tester) testWatchFields(obj runtime.Object, emitFn EmitFunc, fieldsPass
for _, field := range fieldsFail { for _, field := range fieldsFail {
for _, action := range actions { for _, action := range actions {
options := &unversioned.ListOptions{FieldSelector: unversioned.FieldSelector{field.AsSelector()}, ResourceVersion: "1"} options := &api.ListOptions{FieldSelector: field.AsSelector(), ResourceVersion: "1"}
watcher, err := t.storage.(rest.Watcher).Watch(ctx, options) watcher, err := t.storage.(rest.Watcher).Watch(ctx, options)
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
@ -955,7 +955,7 @@ func (t *Tester) testWatchLabels(obj runtime.Object, emitFn EmitFunc, labelsPass
for _, label := range labelsPass { for _, label := range labelsPass {
for _, action := range actions { for _, action := range actions {
options := &unversioned.ListOptions{LabelSelector: unversioned.LabelSelector{label.AsSelector()}, ResourceVersion: "1"} options := &api.ListOptions{LabelSelector: label.AsSelector(), ResourceVersion: "1"}
watcher, err := t.storage.(rest.Watcher).Watch(ctx, options) watcher, err := t.storage.(rest.Watcher).Watch(ctx, options)
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
@ -978,7 +978,7 @@ func (t *Tester) testWatchLabels(obj runtime.Object, emitFn EmitFunc, labelsPass
for _, label := range labelsFail { for _, label := range labelsFail {
for _, action := range actions { for _, action := range actions {
options := &unversioned.ListOptions{LabelSelector: unversioned.LabelSelector{label.AsSelector()}, ResourceVersion: "1"} options := &api.ListOptions{LabelSelector: label.AsSelector(), ResourceVersion: "1"}
watcher, err := t.storage.(rest.Watcher).Watch(ctx, options) watcher, err := t.storage.(rest.Watcher).Watch(ctx, options)
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)

View File

@ -103,13 +103,6 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
field, _ := fields.ParseSelector("a=b") field, _ := fields.ParseSelector("a=b")
j.FieldSelector = field j.FieldSelector = field
}, },
func(j *unversioned.ListOptions, c fuzz.Continue) {
// TODO: add some parsing
label, _ := labels.Parse("a=b")
j.LabelSelector = unversioned.LabelSelector{label}
field, _ := fields.ParseSelector("a=b")
j.FieldSelector = unversioned.FieldSelector{field}
},
func(j *api.PodExecOptions, c fuzz.Continue) { func(j *api.PodExecOptions, c fuzz.Continue) {
j.Stdout = true j.Stdout = true
j.Stderr = true j.Stderr = true

View File

@ -34,7 +34,6 @@ func (obj *TypeMeta) GroupVersionKind() *GroupVersionKind {
return FromAPIVersionAndKind(obj.APIVersion, obj.Kind) return FromAPIVersionAndKind(obj.APIVersion, obj.Kind)
} }
func (obj *ListOptions) GetObjectKind() ObjectKind { return &obj.TypeMeta }
func (obj *Status) GetObjectKind() ObjectKind { return &obj.TypeMeta } func (obj *Status) GetObjectKind() ObjectKind { return &obj.TypeMeta }
func (obj *APIVersions) GetObjectKind() ObjectKind { return &obj.TypeMeta } func (obj *APIVersions) GetObjectKind() ObjectKind { return &obj.TypeMeta }
func (obj *APIGroupList) GetObjectKind() ObjectKind { return &obj.TypeMeta } func (obj *APIGroupList) GetObjectKind() ObjectKind { return &obj.TypeMeta }

View File

@ -63,27 +63,6 @@ type ExportOptions struct {
Exact bool `json:"exact"` Exact bool `json:"exact"`
} }
// ListOptions is the query options to a standard REST list/watch calls.
type ListOptions struct {
TypeMeta `json:",inline"`
// A selector to restrict the list of returned objects by their labels.
// Defaults to everything.
LabelSelector LabelSelector `json:"labelSelector,omitempty"`
// A selector to restrict the list of returned objects by their fields.
// Defaults to everything.
FieldSelector FieldSelector `json:"fieldSelector,omitempty"`
// Watch for changes to the described resources and return them as a stream of
// add, update, and remove notifications. Specify resourceVersion.
Watch bool `json:"watch,omitempty"`
// When specified with a watch call, shows changes that occur after that particular version of a resource.
// Defaults to changes from the beginning of history.
ResourceVersion string `json:"resourceVersion,omitempty"`
// Timeout for the list/watch call.
TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"`
}
// Status is a return value for calls that don't return other objects. // Status is a return value for calls that don't return other objects.
type Status struct { type Status struct {
TypeMeta `json:",inline"` TypeMeta `json:",inline"`

View File

@ -106,19 +106,6 @@ func (ListMeta) SwaggerDoc() map[string]string {
return map_ListMeta return map_ListMeta
} }
var map_ListOptions = map[string]string{
"": "ListOptions is the query options to a standard REST list/watch calls.",
"labelSelector": "A selector to restrict the list of returned objects by their labels. Defaults to everything.",
"fieldSelector": "A selector to restrict the list of returned objects by their fields. Defaults to everything.",
"watch": "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.",
"resourceVersion": "When specified with a watch call, shows changes that occur after that particular version of a resource. Defaults to changes from the beginning of history.",
"timeoutSeconds": "Timeout for the list/watch call.",
}
func (ListOptions) SwaggerDoc() map[string]string {
return map_ListOptions
}
var map_Patch = map[string]string{ var map_Patch = map[string]string{
"": "Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.", "": "Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.",
} }

View File

@ -1116,6 +1116,34 @@ func convert_api_List_To_v1_List(in *api.List, out *List, s conversion.Scope) er
return autoconvert_api_List_To_v1_List(in, out, s) return autoconvert_api_List_To_v1_List(in, out, s)
} }
func autoconvert_api_ListOptions_To_v1_ListOptions(in *api.ListOptions, out *ListOptions, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*api.ListOptions))(in)
}
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
return err
}
if err := s.Convert(&in.LabelSelector, &out.LabelSelector, 0); err != nil {
return err
}
if err := s.Convert(&in.FieldSelector, &out.FieldSelector, 0); err != nil {
return err
}
out.Watch = in.Watch
out.ResourceVersion = in.ResourceVersion
if in.TimeoutSeconds != nil {
out.TimeoutSeconds = new(int64)
*out.TimeoutSeconds = *in.TimeoutSeconds
} else {
out.TimeoutSeconds = nil
}
return nil
}
func convert_api_ListOptions_To_v1_ListOptions(in *api.ListOptions, out *ListOptions, s conversion.Scope) error {
return autoconvert_api_ListOptions_To_v1_ListOptions(in, out, s)
}
func autoconvert_api_LoadBalancerIngress_To_v1_LoadBalancerIngress(in *api.LoadBalancerIngress, out *LoadBalancerIngress, s conversion.Scope) error { func autoconvert_api_LoadBalancerIngress_To_v1_LoadBalancerIngress(in *api.LoadBalancerIngress, out *LoadBalancerIngress, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*api.LoadBalancerIngress))(in) defaulting.(func(*api.LoadBalancerIngress))(in)
@ -3054,34 +3082,6 @@ func convert_unversioned_ExportOptions_To_v1_ExportOptions(in *unversioned.Expor
return autoconvert_unversioned_ExportOptions_To_v1_ExportOptions(in, out, s) return autoconvert_unversioned_ExportOptions_To_v1_ExportOptions(in, out, s)
} }
func autoconvert_unversioned_ListOptions_To_v1_ListOptions(in *unversioned.ListOptions, out *ListOptions, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*unversioned.ListOptions))(in)
}
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
return err
}
if err := s.Convert(&in.LabelSelector, &out.LabelSelector, 0); err != nil {
return err
}
if err := s.Convert(&in.FieldSelector, &out.FieldSelector, 0); err != nil {
return err
}
out.Watch = in.Watch
out.ResourceVersion = in.ResourceVersion
if in.TimeoutSeconds != nil {
out.TimeoutSeconds = new(int64)
*out.TimeoutSeconds = *in.TimeoutSeconds
} else {
out.TimeoutSeconds = nil
}
return nil
}
func convert_unversioned_ListOptions_To_v1_ListOptions(in *unversioned.ListOptions, out *ListOptions, s conversion.Scope) error {
return autoconvert_unversioned_ListOptions_To_v1_ListOptions(in, out, s)
}
func autoconvert_v1_AWSElasticBlockStoreVolumeSource_To_api_AWSElasticBlockStoreVolumeSource(in *AWSElasticBlockStoreVolumeSource, out *api.AWSElasticBlockStoreVolumeSource, s conversion.Scope) error { func autoconvert_v1_AWSElasticBlockStoreVolumeSource_To_api_AWSElasticBlockStoreVolumeSource(in *AWSElasticBlockStoreVolumeSource, out *api.AWSElasticBlockStoreVolumeSource, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*AWSElasticBlockStoreVolumeSource))(in) defaulting.(func(*AWSElasticBlockStoreVolumeSource))(in)
@ -4187,7 +4187,7 @@ func convert_v1_List_To_api_List(in *List, out *api.List, s conversion.Scope) er
return autoconvert_v1_List_To_api_List(in, out, s) return autoconvert_v1_List_To_api_List(in, out, s)
} }
func autoconvert_v1_ListOptions_To_unversioned_ListOptions(in *ListOptions, out *unversioned.ListOptions, s conversion.Scope) error { func autoconvert_v1_ListOptions_To_api_ListOptions(in *ListOptions, out *api.ListOptions, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*ListOptions))(in) defaulting.(func(*ListOptions))(in)
} }
@ -4211,8 +4211,8 @@ func autoconvert_v1_ListOptions_To_unversioned_ListOptions(in *ListOptions, out
return nil return nil
} }
func convert_v1_ListOptions_To_unversioned_ListOptions(in *ListOptions, out *unversioned.ListOptions, s conversion.Scope) error { func convert_v1_ListOptions_To_api_ListOptions(in *ListOptions, out *api.ListOptions, s conversion.Scope) error {
return autoconvert_v1_ListOptions_To_unversioned_ListOptions(in, out, s) return autoconvert_v1_ListOptions_To_api_ListOptions(in, out, s)
} }
func autoconvert_v1_LoadBalancerIngress_To_api_LoadBalancerIngress(in *LoadBalancerIngress, out *api.LoadBalancerIngress, s conversion.Scope) error { func autoconvert_v1_LoadBalancerIngress_To_api_LoadBalancerIngress(in *LoadBalancerIngress, out *api.LoadBalancerIngress, s conversion.Scope) error {
@ -6187,6 +6187,7 @@ func init() {
autoconvert_api_LimitRangeList_To_v1_LimitRangeList, autoconvert_api_LimitRangeList_To_v1_LimitRangeList,
autoconvert_api_LimitRangeSpec_To_v1_LimitRangeSpec, autoconvert_api_LimitRangeSpec_To_v1_LimitRangeSpec,
autoconvert_api_LimitRange_To_v1_LimitRange, autoconvert_api_LimitRange_To_v1_LimitRange,
autoconvert_api_ListOptions_To_v1_ListOptions,
autoconvert_api_List_To_v1_List, autoconvert_api_List_To_v1_List,
autoconvert_api_LoadBalancerIngress_To_v1_LoadBalancerIngress, autoconvert_api_LoadBalancerIngress_To_v1_LoadBalancerIngress,
autoconvert_api_LoadBalancerStatus_To_v1_LoadBalancerStatus, autoconvert_api_LoadBalancerStatus_To_v1_LoadBalancerStatus,
@ -6260,7 +6261,6 @@ func init() {
autoconvert_api_VolumeSource_To_v1_VolumeSource, autoconvert_api_VolumeSource_To_v1_VolumeSource,
autoconvert_api_Volume_To_v1_Volume, autoconvert_api_Volume_To_v1_Volume,
autoconvert_unversioned_ExportOptions_To_v1_ExportOptions, autoconvert_unversioned_ExportOptions_To_v1_ExportOptions,
autoconvert_unversioned_ListOptions_To_v1_ListOptions,
autoconvert_v1_AWSElasticBlockStoreVolumeSource_To_api_AWSElasticBlockStoreVolumeSource, autoconvert_v1_AWSElasticBlockStoreVolumeSource_To_api_AWSElasticBlockStoreVolumeSource,
autoconvert_v1_Binding_To_api_Binding, autoconvert_v1_Binding_To_api_Binding,
autoconvert_v1_Capabilities_To_api_Capabilities, autoconvert_v1_Capabilities_To_api_Capabilities,
@ -6307,7 +6307,7 @@ func init() {
autoconvert_v1_LimitRangeList_To_api_LimitRangeList, autoconvert_v1_LimitRangeList_To_api_LimitRangeList,
autoconvert_v1_LimitRangeSpec_To_api_LimitRangeSpec, autoconvert_v1_LimitRangeSpec_To_api_LimitRangeSpec,
autoconvert_v1_LimitRange_To_api_LimitRange, autoconvert_v1_LimitRange_To_api_LimitRange,
autoconvert_v1_ListOptions_To_unversioned_ListOptions, autoconvert_v1_ListOptions_To_api_ListOptions,
autoconvert_v1_List_To_api_List, autoconvert_v1_List_To_api_List,
autoconvert_v1_LoadBalancerIngress_To_api_LoadBalancerIngress, autoconvert_v1_LoadBalancerIngress_To_api_LoadBalancerIngress,
autoconvert_v1_LoadBalancerStatus_To_api_LoadBalancerStatus, autoconvert_v1_LoadBalancerStatus_To_api_LoadBalancerStatus,

View File

@ -17,12 +17,9 @@ limitations under the License.
package v1_test package v1_test
import ( import (
"encoding/json"
"reflect"
"testing" "testing"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
versioned "k8s.io/kubernetes/pkg/api/v1" versioned "k8s.io/kubernetes/pkg/api/v1"
) )
@ -71,33 +68,3 @@ func TestPodSpecConversion(t *testing.T) {
} }
} }
} }
func TestListOptionsConversion(t *testing.T) {
testCases := []versioned.ListOptions{
{},
{ResourceVersion: "1"},
{LabelSelector: "a=b,c=d", FieldSelector: "a=b,c!=d", ResourceVersion: "5"},
}
for _, test := range testCases {
marshalled, err := json.Marshal(test)
if err != nil {
t.Errorf("unexpected error: %#v", err)
}
newRep := unversioned.ListOptions{}
if err := json.Unmarshal(marshalled, &newRep); err != nil {
t.Errorf("unexpected error: %#v", err)
}
unversionedMarshalled, err := json.Marshal(newRep)
if err != nil {
t.Errorf("unexpected error: %#", err)
}
base := versioned.ListOptions{}
if err := json.Unmarshal(unversionedMarshalled, &base); err != nil {
t.Errorf("unexpected error: %#v", err)
}
if !reflect.DeepEqual(test, base) {
t.Errorf("expected: %#v, got: %#v", test, base)
}
}
}

View File

@ -89,7 +89,7 @@ type APIGroupVersion struct {
RequestInfoResolver *RequestInfoResolver RequestInfoResolver *RequestInfoResolver
// OptionsExternalVersion controls the Kubernetes APIVersion used for common objects in the apiserver // OptionsExternalVersion controls the Kubernetes APIVersion used for common objects in the apiserver
// schema like api.Status, api.DeleteOptions, and unversioned.ListOptions. Other implementors may // schema like api.Status, api.DeleteOptions, and api.ListOptions. Other implementors may
// define a version "v1beta1" but want to use the Kubernetes "v1" internal objects. If // define a version "v1beta1" but want to use the Kubernetes "v1" internal objects. If
// empty, defaults to GroupVersion. // empty, defaults to GroupVersion.
OptionsExternalVersion *unversioned.GroupVersion OptionsExternalVersion *unversioned.GroupVersion

View File

@ -108,24 +108,51 @@ func newMapper() *meta.DefaultRESTMapper {
} }
func addGrouplessTypes() { func addGrouplessTypes() {
type ListOptions struct {
runtime.Object
unversioned.TypeMeta `json:",inline"`
LabelSelector string `json:"labelSelector,omitempty"`
FieldSelector string `json:"fieldSelector,omitempty"`
Watch bool `json:"watch,omitempty"`
ResourceVersion string `json:"resourceVersion,omitempty"`
TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"`
}
api.Scheme.AddKnownTypes( api.Scheme.AddKnownTypes(
grouplessGroupVersion, &apiservertesting.Simple{}, &apiservertesting.SimpleList{}, &unversioned.Status{}, grouplessGroupVersion, &apiservertesting.Simple{}, &apiservertesting.SimpleList{}, &unversioned.Status{},
&unversioned.ListOptions{}, &api.DeleteOptions{}, &apiservertesting.SimpleGetOptions{}, &apiservertesting.SimpleRoot{}) &ListOptions{}, &api.DeleteOptions{}, &apiservertesting.SimpleGetOptions{}, &apiservertesting.SimpleRoot{})
api.Scheme.AddKnownTypes(grouplessGroupVersion, &api.Pod{}) api.Scheme.AddKnownTypes(grouplessGroupVersion, &api.Pod{})
} }
func addTestTypes() { func addTestTypes() {
type ListOptions struct {
runtime.Object
unversioned.TypeMeta `json:",inline"`
LabelSelector string `json:"labelSelector,omitempty"`
FieldSelector string `json:"fieldSelector,omitempty"`
Watch bool `json:"watch,omitempty"`
ResourceVersion string `json:"resourceVersion,omitempty"`
TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"`
}
api.Scheme.AddKnownTypes( api.Scheme.AddKnownTypes(
testGroupVersion, &apiservertesting.Simple{}, &apiservertesting.SimpleList{}, &unversioned.Status{}, testGroupVersion, &apiservertesting.Simple{}, &apiservertesting.SimpleList{}, &unversioned.Status{},
&unversioned.ListOptions{}, &api.DeleteOptions{}, &apiservertesting.SimpleGetOptions{}, &apiservertesting.SimpleRoot{}, &ListOptions{}, &api.DeleteOptions{}, &apiservertesting.SimpleGetOptions{}, &apiservertesting.SimpleRoot{},
&unversioned.ExportOptions{}) &unversioned.ExportOptions{})
api.Scheme.AddKnownTypes(testGroupVersion, &api.Pod{}) api.Scheme.AddKnownTypes(testGroupVersion, &api.Pod{})
} }
func addNewTestTypes() { func addNewTestTypes() {
type ListOptions struct {
runtime.Object
unversioned.TypeMeta `json:",inline"`
LabelSelector string `json:"labelSelector,omitempty"`
FieldSelector string `json:"fieldSelector,omitempty"`
Watch bool `json:"watch,omitempty"`
ResourceVersion string `json:"resourceVersion,omitempty"`
TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"`
}
api.Scheme.AddKnownTypes( api.Scheme.AddKnownTypes(
newGroupVersion, &apiservertesting.Simple{}, &apiservertesting.SimpleList{}, &unversioned.Status{}, newGroupVersion, &apiservertesting.Simple{}, &apiservertesting.SimpleList{}, &unversioned.Status{},
&unversioned.ListOptions{}, &api.DeleteOptions{}, &apiservertesting.SimpleGetOptions{}, &apiservertesting.SimpleRoot{}, &ListOptions{}, &api.DeleteOptions{}, &apiservertesting.SimpleGetOptions{}, &apiservertesting.SimpleRoot{},
&unversioned.ExportOptions{}) &unversioned.ExportOptions{})
} }
@ -136,7 +163,7 @@ func init() {
// "internal" version // "internal" version
api.Scheme.AddKnownTypes( api.Scheme.AddKnownTypes(
testInternalGroupVersion, &apiservertesting.Simple{}, &apiservertesting.SimpleList{}, &unversioned.Status{}, testInternalGroupVersion, &apiservertesting.Simple{}, &apiservertesting.SimpleList{}, &unversioned.Status{},
&unversioned.ListOptions{}, &apiservertesting.SimpleGetOptions{}, &apiservertesting.SimpleRoot{}) &api.ListOptions{}, &apiservertesting.SimpleGetOptions{}, &apiservertesting.SimpleRoot{})
api.Scheme.AddInternalGroupVersion(testInternalGroupVersion) api.Scheme.AddInternalGroupVersion(testInternalGroupVersion)
addGrouplessTypes() addGrouplessTypes()
addTestTypes() addTestTypes()
@ -351,18 +378,18 @@ func (storage *SimpleRESTStorage) Export(ctx api.Context, name string, opts unve
return obj, storage.errors["export"] return obj, storage.errors["export"]
} }
func (storage *SimpleRESTStorage) List(ctx api.Context, options *unversioned.ListOptions) (runtime.Object, error) { func (storage *SimpleRESTStorage) List(ctx api.Context, options *api.ListOptions) (runtime.Object, error) {
storage.checkContext(ctx) storage.checkContext(ctx)
result := &apiservertesting.SimpleList{ result := &apiservertesting.SimpleList{
Items: storage.list, Items: storage.list,
} }
storage.requestedLabelSelector = labels.Everything() storage.requestedLabelSelector = labels.Everything()
if options != nil && options.LabelSelector.Selector != nil { if options != nil && options.LabelSelector != nil {
storage.requestedLabelSelector = options.LabelSelector.Selector storage.requestedLabelSelector = options.LabelSelector
} }
storage.requestedFieldSelector = fields.Everything() storage.requestedFieldSelector = fields.Everything()
if options != nil && options.FieldSelector.Selector != nil { if options != nil && options.FieldSelector != nil {
storage.requestedFieldSelector = options.FieldSelector.Selector storage.requestedFieldSelector = options.FieldSelector
} }
return result, storage.errors["list"] return result, storage.errors["list"]
} }
@ -460,15 +487,15 @@ func (storage *SimpleRESTStorage) Update(ctx api.Context, obj runtime.Object) (r
} }
// Implement ResourceWatcher. // Implement ResourceWatcher.
func (storage *SimpleRESTStorage) Watch(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) { func (storage *SimpleRESTStorage) Watch(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
storage.checkContext(ctx) storage.checkContext(ctx)
storage.requestedLabelSelector = labels.Everything() storage.requestedLabelSelector = labels.Everything()
if options != nil && options.LabelSelector.Selector != nil { if options != nil && options.LabelSelector != nil {
storage.requestedLabelSelector = options.LabelSelector.Selector storage.requestedLabelSelector = options.LabelSelector
} }
storage.requestedFieldSelector = fields.Everything() storage.requestedFieldSelector = fields.Everything()
if options != nil && options.FieldSelector.Selector != nil { if options != nil && options.FieldSelector != nil {
storage.requestedFieldSelector = options.FieldSelector.Selector storage.requestedFieldSelector = options.FieldSelector
} }
storage.requestedResourceVersion = "" storage.requestedResourceVersion = ""
if options != nil { if options != nil {

View File

@ -264,19 +264,29 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch
ctx := scope.ContextFunc(req) ctx := scope.ContextFunc(req)
ctx = api.WithNamespace(ctx, namespace) ctx = api.WithNamespace(ctx, namespace)
opts := unversioned.ListOptions{} listOptionsGVK := scope.Kind.GroupVersion().WithKind("ListOptions")
if err := scope.Codec.DecodeParametersInto(req.Request.URL.Query(), &opts); err != nil { versioned, err := scope.Creater.New(listOptionsGVK)
if err != nil {
errorJSON(err, scope.Codec, w)
return
}
if err := scope.Codec.DecodeParametersInto(req.Request.URL.Query(), versioned); err != nil {
errorJSON(err, scope.Codec, w)
return
}
opts := api.ListOptions{}
if err := scope.Convertor.Convert(versioned, &opts); err != nil {
errorJSON(err, scope.Codec, w) errorJSON(err, scope.Codec, w)
return return
} }
// transform fields // transform fields
// TODO: DecodeParametersInto should do this. // TODO: DecodeParametersInto should do this.
if opts.FieldSelector.Selector != nil { if opts.FieldSelector != nil {
fn := func(label, value string) (newLabel, newValue string, err error) { fn := func(label, value string) (newLabel, newValue string, err error) {
return scope.Convertor.ConvertFieldLabel(scope.Kind.GroupVersion().String(), scope.Kind.Kind, label, value) return scope.Convertor.ConvertFieldLabel(scope.Kind.GroupVersion().String(), scope.Kind.Kind, label, value)
} }
if opts.FieldSelector.Selector, err = opts.FieldSelector.Selector.Transform(fn); err != nil { if opts.FieldSelector, err = opts.FieldSelector.Transform(fn); err != nil {
// TODO: allow bad request to set field causes based on query parameters // TODO: allow bad request to set field causes based on query parameters
err = errors.NewBadRequest(err.Error()) err = errors.NewBadRequest(err.Error())
errorJSON(err, scope.Codec, w) errorJSON(err, scope.Codec, w)
@ -290,7 +300,7 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch
// a request for a single object and optimize the // a request for a single object and optimize the
// storage query accordingly. // storage query accordingly.
nameSelector := fields.OneTermEqualSelector("metadata.name", name) nameSelector := fields.OneTermEqualSelector("metadata.name", name)
if opts.FieldSelector.Selector != nil && !opts.FieldSelector.Selector.Empty() { if opts.FieldSelector != nil && !opts.FieldSelector.Empty() {
// It doesn't make sense to ask for both a name // It doesn't make sense to ask for both a name
// and a field selector, since just the name is // and a field selector, since just the name is
// sufficient to narrow down the request to a // sufficient to narrow down the request to a
@ -302,7 +312,7 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch
) )
return return
} }
opts.FieldSelector.Selector = nameSelector opts.FieldSelector = nameSelector
} }
if (opts.Watch || forceWatch) && rw != nil { if (opts.Watch || forceWatch) && rw != nil {
@ -777,19 +787,29 @@ func DeleteCollection(r rest.CollectionDeleter, checkBody bool, scope RequestSco
} }
} }
listOptions := unversioned.ListOptions{} listOptionsGVK := scope.Kind.GroupVersion().WithKind("ListOptions")
if err := scope.Codec.DecodeParametersInto(req.Request.URL.Query(), &listOptions); err != nil { versioned, err := scope.Creater.New(listOptionsGVK)
if err != nil {
errorJSON(err, scope.Codec, w)
return
}
if err := scope.Codec.DecodeParametersInto(req.Request.URL.Query(), versioned); err != nil {
errorJSON(err, scope.Codec, w)
return
}
listOptions := api.ListOptions{}
if err := scope.Convertor.Convert(versioned, &listOptions); err != nil {
errorJSON(err, scope.Codec, w) errorJSON(err, scope.Codec, w)
return return
} }
// transform fields // transform fields
// TODO: DecodeParametersInto should do this. // TODO: DecodeParametersInto should do this.
if listOptions.FieldSelector.Selector != nil { if listOptions.FieldSelector != nil {
fn := func(label, value string) (newLabel, newValue string, err error) { fn := func(label, value string) (newLabel, newValue string, err error) {
return scope.Convertor.ConvertFieldLabel(scope.Kind.GroupVersion().String(), scope.Kind.Kind, label, value) return scope.Convertor.ConvertFieldLabel(scope.Kind.GroupVersion().String(), scope.Kind.Kind, label, value)
} }
if listOptions.FieldSelector.Selector, err = listOptions.FieldSelector.Selector.Transform(fn); err != nil { if listOptions.FieldSelector, err = listOptions.FieldSelector.Transform(fn); err != nil {
// TODO: allow bad request to set field causes based on query parameters // TODO: allow bad request to set field causes based on query parameters
err = errors.NewBadRequest(err.Error()) err = errors.NewBadRequest(err.Error())
errorJSON(err, scope.Codec, w) errorJSON(err, scope.Codec, w)

View File

@ -21,7 +21,6 @@ import (
"net/http" "net/http"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apiserver" "k8s.io/kubernetes/pkg/apiserver"
"k8s.io/kubernetes/pkg/probe" "k8s.io/kubernetes/pkg/probe"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
@ -51,7 +50,7 @@ func (rs *REST) NewList() runtime.Object {
// Returns the list of component status. Note that the label and field are both ignored. // Returns the list of component status. Note that the label and field are both ignored.
// Note that this call doesn't support labels or selectors. // Note that this call doesn't support labels or selectors.
func (rs *REST) List(ctx api.Context, options *unversioned.ListOptions) (runtime.Object, error) { func (rs *REST) List(ctx api.Context, options *api.ListOptions) (runtime.Object, error) {
servers := rs.GetServersToValidate() servers := rs.GetServersToValidate()
wait := sync.WaitGroup{} wait := sync.WaitGroup{}

View File

@ -19,15 +19,14 @@ package configmap
import ( import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest" "k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
) )
// Registry is an interface for things that know how to store ConfigMaps. // Registry is an interface for things that know how to store ConfigMaps.
type Registry interface { type Registry interface {
ListConfigMaps(ctx api.Context, options *unversioned.ListOptions) (*extensions.ConfigMapList, error) ListConfigMaps(ctx api.Context, options *api.ListOptions) (*extensions.ConfigMapList, error)
WatchConfigMaps(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) WatchConfigMaps(ctx api.Context, options *api.ListOptions) (watch.Interface, error)
GetConfigMap(ctx api.Context, name string) (*extensions.ConfigMap, error) GetConfigMap(ctx api.Context, name string) (*extensions.ConfigMap, error)
CreateConfigMap(ctx api.Context, cfg *extensions.ConfigMap) (*extensions.ConfigMap, error) CreateConfigMap(ctx api.Context, cfg *extensions.ConfigMap) (*extensions.ConfigMap, error)
UpdateConfigMap(ctx api.Context, cfg *extensions.ConfigMap) (*extensions.ConfigMap, error) UpdateConfigMap(ctx api.Context, cfg *extensions.ConfigMap) (*extensions.ConfigMap, error)
@ -45,7 +44,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListConfigMaps(ctx api.Context, options *unversioned.ListOptions) (*extensions.ConfigMapList, error) { func (s *storage) ListConfigMaps(ctx api.Context, options *api.ListOptions) (*extensions.ConfigMapList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
@ -54,7 +53,7 @@ func (s *storage) ListConfigMaps(ctx api.Context, options *unversioned.ListOptio
return obj.(*extensions.ConfigMapList), err return obj.(*extensions.ConfigMapList), err
} }
func (s *storage) WatchConfigMaps(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) { func (s *storage) WatchConfigMaps(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }

View File

@ -21,14 +21,13 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest" "k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
) )
// Registry is an interface for things that know how to store ReplicationControllers. // Registry is an interface for things that know how to store ReplicationControllers.
type Registry interface { type Registry interface {
ListControllers(ctx api.Context, options *unversioned.ListOptions) (*api.ReplicationControllerList, error) ListControllers(ctx api.Context, options *api.ListOptions) (*api.ReplicationControllerList, error)
WatchControllers(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) WatchControllers(ctx api.Context, options *api.ListOptions) (watch.Interface, error)
GetController(ctx api.Context, controllerID string) (*api.ReplicationController, error) GetController(ctx api.Context, controllerID string) (*api.ReplicationController, error)
CreateController(ctx api.Context, controller *api.ReplicationController) (*api.ReplicationController, error) CreateController(ctx api.Context, controller *api.ReplicationController) (*api.ReplicationController, error)
UpdateController(ctx api.Context, controller *api.ReplicationController) (*api.ReplicationController, error) UpdateController(ctx api.Context, controller *api.ReplicationController) (*api.ReplicationController, error)
@ -46,8 +45,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListControllers(ctx api.Context, options *unversioned.ListOptions) (*api.ReplicationControllerList, error) { func (s *storage) ListControllers(ctx api.Context, options *api.ListOptions) (*api.ReplicationControllerList, error) {
if options != nil && options.FieldSelector.Selector != nil && !options.FieldSelector.Selector.Empty() { if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() {
return nil, fmt.Errorf("field selector not supported yet") return nil, fmt.Errorf("field selector not supported yet")
} }
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
@ -57,7 +56,7 @@ func (s *storage) ListControllers(ctx api.Context, options *unversioned.ListOpti
return obj.(*api.ReplicationControllerList), err return obj.(*api.ReplicationControllerList), err
} }
func (s *storage) WatchControllers(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) { func (s *storage) WatchControllers(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }

View File

@ -21,13 +21,12 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest" "k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
) )
// Registry is an interface for things that know how to store Deployments. // Registry is an interface for things that know how to store Deployments.
type Registry interface { type Registry interface {
ListDeployments(ctx api.Context, options *unversioned.ListOptions) (*extensions.DeploymentList, error) ListDeployments(ctx api.Context, options *api.ListOptions) (*extensions.DeploymentList, error)
GetDeployment(ctx api.Context, deploymentID string) (*extensions.Deployment, error) GetDeployment(ctx api.Context, deploymentID string) (*extensions.Deployment, error)
CreateDeployment(ctx api.Context, deployment *extensions.Deployment) (*extensions.Deployment, error) CreateDeployment(ctx api.Context, deployment *extensions.Deployment) (*extensions.Deployment, error)
UpdateDeployment(ctx api.Context, deployment *extensions.Deployment) (*extensions.Deployment, error) UpdateDeployment(ctx api.Context, deployment *extensions.Deployment) (*extensions.Deployment, error)
@ -44,8 +43,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListDeployments(ctx api.Context, options *unversioned.ListOptions) (*extensions.DeploymentList, error) { func (s *storage) ListDeployments(ctx api.Context, options *api.ListOptions) (*extensions.DeploymentList, error) {
if options != nil && options.FieldSelector.Selector != nil && !options.FieldSelector.Selector.Empty() { if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() {
return nil, fmt.Errorf("field selector not supported yet") return nil, fmt.Errorf("field selector not supported yet")
} }
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)

View File

@ -19,15 +19,14 @@ package endpoint
import ( import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest" "k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
) )
// Registry is an interface for things that know how to store endpoints. // Registry is an interface for things that know how to store endpoints.
type Registry interface { type Registry interface {
ListEndpoints(ctx api.Context, options *unversioned.ListOptions) (*api.EndpointsList, error) ListEndpoints(ctx api.Context, options *api.ListOptions) (*api.EndpointsList, error)
GetEndpoints(ctx api.Context, name string) (*api.Endpoints, error) GetEndpoints(ctx api.Context, name string) (*api.Endpoints, error)
WatchEndpoints(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) WatchEndpoints(ctx api.Context, options *api.ListOptions) (watch.Interface, error)
UpdateEndpoints(ctx api.Context, e *api.Endpoints) error UpdateEndpoints(ctx api.Context, e *api.Endpoints) error
DeleteEndpoints(ctx api.Context, name string) error DeleteEndpoints(ctx api.Context, name string) error
} }
@ -43,7 +42,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListEndpoints(ctx api.Context, options *unversioned.ListOptions) (*api.EndpointsList, error) { func (s *storage) ListEndpoints(ctx api.Context, options *api.ListOptions) (*api.EndpointsList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
@ -51,7 +50,7 @@ func (s *storage) ListEndpoints(ctx api.Context, options *unversioned.ListOption
return obj.(*api.EndpointsList), nil return obj.(*api.EndpointsList), nil
} }
func (s *storage) WatchEndpoints(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) { func (s *storage) WatchEndpoints(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }

View File

@ -162,20 +162,20 @@ func (e *Etcd) NewList() runtime.Object {
} }
// List returns a list of items matching labels and field // List returns a list of items matching labels and field
func (e *Etcd) List(ctx api.Context, options *unversioned.ListOptions) (runtime.Object, error) { func (e *Etcd) List(ctx api.Context, options *api.ListOptions) (runtime.Object, error) {
label := labels.Everything() label := labels.Everything()
if options != nil && options.LabelSelector.Selector != nil { if options != nil && options.LabelSelector != nil {
label = options.LabelSelector.Selector label = options.LabelSelector
} }
field := fields.Everything() field := fields.Everything()
if options != nil && options.FieldSelector.Selector != nil { if options != nil && options.FieldSelector != nil {
field = options.FieldSelector.Selector field = options.FieldSelector
} }
return e.ListPredicate(ctx, e.PredicateFunc(label, field), options) return e.ListPredicate(ctx, e.PredicateFunc(label, field), options)
} }
// ListPredicate returns a list of all the items matching m. // ListPredicate returns a list of all the items matching m.
func (e *Etcd) ListPredicate(ctx api.Context, m generic.Matcher, options *unversioned.ListOptions) (runtime.Object, error) { func (e *Etcd) ListPredicate(ctx api.Context, m generic.Matcher, options *api.ListOptions) (runtime.Object, error) {
list := e.NewListFunc() list := e.NewListFunc()
filterFunc := e.filterAndDecorateFunction(m) filterFunc := e.filterAndDecorateFunction(m)
if name, ok := m.MatchesSingle(); ok { if name, ok := m.MatchesSingle(); ok {
@ -187,7 +187,7 @@ func (e *Etcd) ListPredicate(ctx api.Context, m generic.Matcher, options *unvers
} }
if options == nil { if options == nil {
options = &unversioned.ListOptions{ResourceVersion: "0"} options = &api.ListOptions{ResourceVersion: "0"}
} }
err := e.Storage.List(ctx, e.KeyRootFunc(ctx), options.ResourceVersion, filterFunc, list) err := e.Storage.List(ctx, e.KeyRootFunc(ctx), options.ResourceVersion, filterFunc, list)
return list, etcderr.InterpretListError(err, e.QualifiedResource) return list, etcderr.InterpretListError(err, e.QualifiedResource)
@ -432,7 +432,7 @@ func (e *Etcd) Delete(ctx api.Context, name string, options *api.DeleteOptions)
// are removing all objects of a given type) with the current API (it's technically // are removing all objects of a given type) with the current API (it's technically
// possibly with etcd API, but watch is not delivered correctly then). // possibly with etcd API, but watch is not delivered correctly then).
// It will be possible to fix it with v3 etcd API. // It will be possible to fix it with v3 etcd API.
func (e *Etcd) DeleteCollection(ctx api.Context, options *api.DeleteOptions, listOptions *unversioned.ListOptions) (runtime.Object, error) { func (e *Etcd) DeleteCollection(ctx api.Context, options *api.DeleteOptions, listOptions *api.ListOptions) (runtime.Object, error) {
listObj, err := e.List(ctx, listOptions) listObj, err := e.List(ctx, listOptions)
if err != nil { if err != nil {
return nil, err return nil, err
@ -474,14 +474,14 @@ func (e *Etcd) finalizeDelete(obj runtime.Object, runHooks bool) (runtime.Object
// WatchPredicate. If possible, you should customize PredicateFunc to produre a // WatchPredicate. If possible, you should customize PredicateFunc to produre a
// matcher that matches by key. generic.SelectionPredicate does this for you // matcher that matches by key. generic.SelectionPredicate does this for you
// automatically. // automatically.
func (e *Etcd) Watch(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) { func (e *Etcd) Watch(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
label := labels.Everything() label := labels.Everything()
if options != nil && options.LabelSelector.Selector != nil { if options != nil && options.LabelSelector != nil {
label = options.LabelSelector.Selector label = options.LabelSelector
} }
field := fields.Everything() field := fields.Everything()
if options != nil && options.FieldSelector.Selector != nil { if options != nil && options.FieldSelector != nil {
field = options.FieldSelector.Selector field = options.FieldSelector
} }
resourceVersion := "" resourceVersion := ""
if options != nil { if options != nil {

View File

@ -500,7 +500,7 @@ func TestEtcdDeleteCollection(t *testing.T) {
} }
// Delete all pods. // Delete all pods.
deleted, err := registry.DeleteCollection(testContext, nil, &unversioned.ListOptions{}) deleted, err := registry.DeleteCollection(testContext, nil, &api.ListOptions{})
if err != nil { if err != nil {
t.Fatalf("Unexpected error: %v", err) t.Fatalf("Unexpected error: %v", err)
} }
@ -537,7 +537,7 @@ func TestEtcdDeleteCollectionWithWatch(t *testing.T) {
t.Fatalf("Unexpected error: %v", err) t.Fatalf("Unexpected error: %v", err)
} }
if _, err := registry.DeleteCollection(testContext, nil, &unversioned.ListOptions{}); err != nil { if _, err := registry.DeleteCollection(testContext, nil, &api.ListOptions{}); err != nil {
t.Fatalf("Unexpected error: %v", err) t.Fatalf("Unexpected error: %v", err)
} }

View File

@ -19,14 +19,13 @@ package namespace
import ( import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest" "k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
) )
// Registry is an interface implemented by things that know how to store Namespace objects. // Registry is an interface implemented by things that know how to store Namespace objects.
type Registry interface { type Registry interface {
ListNamespaces(ctx api.Context, options *unversioned.ListOptions) (*api.NamespaceList, error) ListNamespaces(ctx api.Context, options *api.ListOptions) (*api.NamespaceList, error)
WatchNamespaces(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) WatchNamespaces(ctx api.Context, options *api.ListOptions) (watch.Interface, error)
GetNamespace(ctx api.Context, namespaceID string) (*api.Namespace, error) GetNamespace(ctx api.Context, namespaceID string) (*api.Namespace, error)
CreateNamespace(ctx api.Context, namespace *api.Namespace) error CreateNamespace(ctx api.Context, namespace *api.Namespace) error
UpdateNamespace(ctx api.Context, namespace *api.Namespace) error UpdateNamespace(ctx api.Context, namespace *api.Namespace) error
@ -44,7 +43,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListNamespaces(ctx api.Context, options *unversioned.ListOptions) (*api.NamespaceList, error) { func (s *storage) ListNamespaces(ctx api.Context, options *api.ListOptions) (*api.NamespaceList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
@ -52,7 +51,7 @@ func (s *storage) ListNamespaces(ctx api.Context, options *unversioned.ListOptio
return obj.(*api.NamespaceList), nil return obj.(*api.NamespaceList), nil
} }
func (s *storage) WatchNamespaces(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) { func (s *storage) WatchNamespaces(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }

View File

@ -19,18 +19,17 @@ package node
import ( import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest" "k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
) )
// Registry is an interface for things that know how to store node. // Registry is an interface for things that know how to store node.
type Registry interface { type Registry interface {
ListNodes(ctx api.Context, options *unversioned.ListOptions) (*api.NodeList, error) ListNodes(ctx api.Context, options *api.ListOptions) (*api.NodeList, error)
CreateNode(ctx api.Context, node *api.Node) error CreateNode(ctx api.Context, node *api.Node) error
UpdateNode(ctx api.Context, node *api.Node) error UpdateNode(ctx api.Context, node *api.Node) error
GetNode(ctx api.Context, nodeID string) (*api.Node, error) GetNode(ctx api.Context, nodeID string) (*api.Node, error)
DeleteNode(ctx api.Context, nodeID string) error DeleteNode(ctx api.Context, nodeID string) error
WatchNodes(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) WatchNodes(ctx api.Context, options *api.ListOptions) (watch.Interface, error)
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
@ -44,7 +43,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListNodes(ctx api.Context, options *unversioned.ListOptions) (*api.NodeList, error) { func (s *storage) ListNodes(ctx api.Context, options *api.ListOptions) (*api.NodeList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
@ -63,7 +62,7 @@ func (s *storage) UpdateNode(ctx api.Context, node *api.Node) error {
return err return err
} }
func (s *storage) WatchNodes(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) { func (s *storage) WatchNodes(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }

View File

@ -22,7 +22,6 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
) )
@ -35,7 +34,7 @@ type EndpointRegistry struct {
lock sync.Mutex lock sync.Mutex
} }
func (e *EndpointRegistry) ListEndpoints(ctx api.Context, options *unversioned.ListOptions) (*api.EndpointsList, error) { func (e *EndpointRegistry) ListEndpoints(ctx api.Context, options *api.ListOptions) (*api.EndpointsList, error) {
// TODO: support namespaces in this mock // TODO: support namespaces in this mock
e.lock.Lock() e.lock.Lock()
defer e.lock.Unlock() defer e.lock.Unlock()
@ -60,7 +59,7 @@ func (e *EndpointRegistry) GetEndpoints(ctx api.Context, name string) (*api.Endp
return nil, errors.NewNotFound(api.Resource("endpoints"), name) return nil, errors.NewNotFound(api.Resource("endpoints"), name)
} }
func (e *EndpointRegistry) WatchEndpoints(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) { func (e *EndpointRegistry) WatchEndpoints(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return nil, fmt.Errorf("unimplemented!") return nil, fmt.Errorf("unimplemented!")
} }

View File

@ -21,7 +21,6 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
) )
@ -58,7 +57,7 @@ func (r *NodeRegistry) SetError(err error) {
r.Err = err r.Err = err
} }
func (r *NodeRegistry) ListNodes(ctx api.Context, options *unversioned.ListOptions) (*api.NodeList, error) { func (r *NodeRegistry) ListNodes(ctx api.Context, options *api.ListOptions) (*api.NodeList, error) {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
return &r.Nodes, r.Err return &r.Nodes, r.Err
@ -111,6 +110,6 @@ func (r *NodeRegistry) DeleteNode(ctx api.Context, nodeID string) error {
return r.Err return r.Err
} }
func (r *NodeRegistry) WatchNodes(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) { func (r *NodeRegistry) WatchNodes(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return nil, r.Err return nil, r.Err
} }

View File

@ -20,7 +20,6 @@ import (
"sync" "sync"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
) )
@ -46,7 +45,7 @@ func (r *ServiceRegistry) SetError(err error) {
r.Err = err r.Err = err
} }
func (r *ServiceRegistry) ListServices(ctx api.Context, options *unversioned.ListOptions) (*api.ServiceList, error) { func (r *ServiceRegistry) ListServices(ctx api.Context, options *api.ListOptions) (*api.ServiceList, error) {
r.mu.Lock() r.mu.Lock()
defer r.mu.Unlock() defer r.mu.Unlock()
@ -107,7 +106,7 @@ func (r *ServiceRegistry) UpdateService(ctx api.Context, svc *api.Service) (*api
return svc, r.Err return svc, r.Err
} }
func (r *ServiceRegistry) WatchServices(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) { func (r *ServiceRegistry) WatchServices(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
r.mu.Lock() r.mu.Lock()
defer r.mu.Unlock() defer r.mu.Unlock()

View File

@ -19,14 +19,13 @@ package secret
import ( import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest" "k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
) )
// Registry is an interface implemented by things that know how to store Secret objects. // Registry is an interface implemented by things that know how to store Secret objects.
type Registry interface { type Registry interface {
ListSecrets(ctx api.Context, options *unversioned.ListOptions) (*api.SecretList, error) ListSecrets(ctx api.Context, options *api.ListOptions) (*api.SecretList, error)
WatchSecrets(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) WatchSecrets(ctx api.Context, options *api.ListOptions) (watch.Interface, error)
GetSecret(ctx api.Context, name string) (*api.Secret, error) GetSecret(ctx api.Context, name string) (*api.Secret, error)
CreateSecret(ctx api.Context, Secret *api.Secret) (*api.Secret, error) CreateSecret(ctx api.Context, Secret *api.Secret) (*api.Secret, error)
UpdateSecret(ctx api.Context, Secret *api.Secret) (*api.Secret, error) UpdateSecret(ctx api.Context, Secret *api.Secret) (*api.Secret, error)
@ -44,7 +43,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListSecrets(ctx api.Context, options *unversioned.ListOptions) (*api.SecretList, error) { func (s *storage) ListSecrets(ctx api.Context, options *api.ListOptions) (*api.SecretList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
@ -52,7 +51,7 @@ func (s *storage) ListSecrets(ctx api.Context, options *unversioned.ListOptions)
return obj.(*api.SecretList), nil return obj.(*api.SecretList), nil
} }
func (s *storage) WatchSecrets(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) { func (s *storage) WatchSecrets(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }

View File

@ -22,7 +22,6 @@ import (
"time" "time"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/registry/service" "k8s.io/kubernetes/pkg/registry/service"
"k8s.io/kubernetes/pkg/registry/service/ipallocator" "k8s.io/kubernetes/pkg/registry/service/ipallocator"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
@ -93,7 +92,7 @@ func (c *Repair) RunOnce() error {
} }
ctx := api.WithNamespace(api.NewDefaultContext(), api.NamespaceAll) ctx := api.WithNamespace(api.NewDefaultContext(), api.NamespaceAll)
options := &unversioned.ListOptions{ResourceVersion: latest.ObjectMeta.ResourceVersion} options := &api.ListOptions{ResourceVersion: latest.ObjectMeta.ResourceVersion}
list, err := c.registry.ListServices(ctx, options) list, err := c.registry.ListServices(ctx, options)
if err != nil { if err != nil {
return fmt.Errorf("unable to refresh the service IP block: %v", err) return fmt.Errorf("unable to refresh the service IP block: %v", err)

View File

@ -21,7 +21,6 @@ import (
"time" "time"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/registry/service" "k8s.io/kubernetes/pkg/registry/service"
"k8s.io/kubernetes/pkg/registry/service/portallocator" "k8s.io/kubernetes/pkg/registry/service/portallocator"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
@ -80,7 +79,7 @@ func (c *Repair) RunOnce() error {
} }
ctx := api.WithNamespace(api.NewDefaultContext(), api.NamespaceAll) ctx := api.WithNamespace(api.NewDefaultContext(), api.NamespaceAll)
options := &unversioned.ListOptions{ResourceVersion: latest.ObjectMeta.ResourceVersion} options := &api.ListOptions{ResourceVersion: latest.ObjectMeta.ResourceVersion}
list, err := c.registry.ListServices(ctx, options) list, err := c.registry.ListServices(ctx, options)
if err != nil { if err != nil {
return fmt.Errorf("unable to refresh the port block: %v", err) return fmt.Errorf("unable to refresh the port block: %v", err)

View File

@ -19,18 +19,17 @@ package service
import ( import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest" "k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
) )
// Registry is an interface for things that know how to store services. // Registry is an interface for things that know how to store services.
type Registry interface { type Registry interface {
ListServices(ctx api.Context, options *unversioned.ListOptions) (*api.ServiceList, error) ListServices(ctx api.Context, options *api.ListOptions) (*api.ServiceList, error)
CreateService(ctx api.Context, svc *api.Service) (*api.Service, error) CreateService(ctx api.Context, svc *api.Service) (*api.Service, error)
GetService(ctx api.Context, name string) (*api.Service, error) GetService(ctx api.Context, name string) (*api.Service, error)
DeleteService(ctx api.Context, name string) error DeleteService(ctx api.Context, name string) error
UpdateService(ctx api.Context, svc *api.Service) (*api.Service, error) UpdateService(ctx api.Context, svc *api.Service) (*api.Service, error)
WatchServices(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) WatchServices(ctx api.Context, options *api.ListOptions) (watch.Interface, error)
} }
// storage puts strong typing around storage calls // storage puts strong typing around storage calls
@ -44,7 +43,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListServices(ctx api.Context, options *unversioned.ListOptions) (*api.ServiceList, error) { func (s *storage) ListServices(ctx api.Context, options *api.ListOptions) (*api.ServiceList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
@ -81,7 +80,7 @@ func (s *storage) UpdateService(ctx api.Context, svc *api.Service) (*api.Service
return obj.(*api.Service), nil return obj.(*api.Service), nil
} }
func (s *storage) WatchServices(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) { func (s *storage) WatchServices(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }

View File

@ -178,13 +178,13 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) {
return rs.registry.GetService(ctx, id) return rs.registry.GetService(ctx, id)
} }
func (rs *REST) List(ctx api.Context, options *unversioned.ListOptions) (runtime.Object, error) { func (rs *REST) List(ctx api.Context, options *api.ListOptions) (runtime.Object, error) {
return rs.registry.ListServices(ctx, options) return rs.registry.ListServices(ctx, options)
} }
// Watch returns Services events via a watch.Interface. // Watch returns Services events via a watch.Interface.
// It implements rest.Watcher. // It implements rest.Watcher.
func (rs *REST) Watch(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) { func (rs *REST) Watch(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return rs.registry.WatchServices(ctx, options) return rs.registry.WatchServices(ctx, options)
} }

View File

@ -19,14 +19,13 @@ package serviceaccount
import ( import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest" "k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
) )
// Registry is an interface implemented by things that know how to store ServiceAccount objects. // Registry is an interface implemented by things that know how to store ServiceAccount objects.
type Registry interface { type Registry interface {
ListServiceAccounts(ctx api.Context, options *unversioned.ListOptions) (*api.ServiceAccountList, error) ListServiceAccounts(ctx api.Context, options *api.ListOptions) (*api.ServiceAccountList, error)
WatchServiceAccounts(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) WatchServiceAccounts(ctx api.Context, options *api.ListOptions) (watch.Interface, error)
GetServiceAccount(ctx api.Context, name string) (*api.ServiceAccount, error) GetServiceAccount(ctx api.Context, name string) (*api.ServiceAccount, error)
CreateServiceAccount(ctx api.Context, ServiceAccount *api.ServiceAccount) error CreateServiceAccount(ctx api.Context, ServiceAccount *api.ServiceAccount) error
UpdateServiceAccount(ctx api.Context, ServiceAccount *api.ServiceAccount) error UpdateServiceAccount(ctx api.Context, ServiceAccount *api.ServiceAccount) error
@ -44,7 +43,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListServiceAccounts(ctx api.Context, options *unversioned.ListOptions) (*api.ServiceAccountList, error) { func (s *storage) ListServiceAccounts(ctx api.Context, options *api.ListOptions) (*api.ServiceAccountList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
@ -52,7 +51,7 @@ func (s *storage) ListServiceAccounts(ctx api.Context, options *unversioned.List
return obj.(*api.ServiceAccountList), nil return obj.(*api.ServiceAccountList), nil
} }
func (s *storage) WatchServiceAccounts(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) { func (s *storage) WatchServiceAccounts(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }

View File

@ -302,6 +302,13 @@ func (t *thirdPartyResourceDataCreator) New(kind unversioned.GroupVersionKind) (
return nil, fmt.Errorf("unknown kind %v", kind) return nil, fmt.Errorf("unknown kind %v", kind)
} }
return &extensions.ThirdPartyResourceDataList{}, nil return &extensions.ThirdPartyResourceDataList{}, nil
case "ListOptions":
if apiutil.GetGroupVersion(t.group, t.version) == kind.GroupVersion().String() {
// Translate third party group to external group.
gvk := latest.ExternalVersions[0].WithKind(kind.Kind)
return t.delegate.New(gvk)
}
return t.delegate.New(kind)
default: default:
return t.delegate.New(kind) return t.delegate.New(kind)
} }

View File

@ -19,15 +19,14 @@ package thirdpartyresourcedata
import ( import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/rest" "k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/watch" "k8s.io/kubernetes/pkg/watch"
) )
// Registry is an interface implemented by things that know how to store ThirdPartyResourceData objects. // Registry is an interface implemented by things that know how to store ThirdPartyResourceData objects.
type Registry interface { type Registry interface {
ListThirdPartyResourceData(ctx api.Context, options *unversioned.ListOptions) (*extensions.ThirdPartyResourceDataList, error) ListThirdPartyResourceData(ctx api.Context, options *api.ListOptions) (*extensions.ThirdPartyResourceDataList, error)
WatchThirdPartyResourceData(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) WatchThirdPartyResourceData(ctx api.Context, options *api.ListOptions) (watch.Interface, error)
GetThirdPartyResourceData(ctx api.Context, name string) (*extensions.ThirdPartyResourceData, error) GetThirdPartyResourceData(ctx api.Context, name string) (*extensions.ThirdPartyResourceData, error)
CreateThirdPartyResourceData(ctx api.Context, resource *extensions.ThirdPartyResourceData) (*extensions.ThirdPartyResourceData, error) CreateThirdPartyResourceData(ctx api.Context, resource *extensions.ThirdPartyResourceData) (*extensions.ThirdPartyResourceData, error)
UpdateThirdPartyResourceData(ctx api.Context, resource *extensions.ThirdPartyResourceData) (*extensions.ThirdPartyResourceData, error) UpdateThirdPartyResourceData(ctx api.Context, resource *extensions.ThirdPartyResourceData) (*extensions.ThirdPartyResourceData, error)
@ -45,7 +44,7 @@ func NewRegistry(s rest.StandardStorage) Registry {
return &storage{s} return &storage{s}
} }
func (s *storage) ListThirdPartyResourceData(ctx api.Context, options *unversioned.ListOptions) (*extensions.ThirdPartyResourceDataList, error) { func (s *storage) ListThirdPartyResourceData(ctx api.Context, options *api.ListOptions) (*extensions.ThirdPartyResourceDataList, error) {
obj, err := s.List(ctx, options) obj, err := s.List(ctx, options)
if err != nil { if err != nil {
return nil, err return nil, err
@ -53,7 +52,7 @@ func (s *storage) ListThirdPartyResourceData(ctx api.Context, options *unversion
return obj.(*extensions.ThirdPartyResourceDataList), nil return obj.(*extensions.ThirdPartyResourceDataList), nil
} }
func (s *storage) WatchThirdPartyResourceData(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) { func (s *storage) WatchThirdPartyResourceData(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
return s.Watch(ctx, options) return s.Watch(ctx, options)
} }