diff --git a/pkg/api/conversion.go b/pkg/api/conversion.go index 052e5a7343ddd..4b952de9eecf1 100644 --- a/pkg/api/conversion.go +++ b/pkg/api/conversion.go @@ -39,14 +39,6 @@ func init() { 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( func(in *unversioned.Time, out *unversioned.Time, s conversion.Scope) error { diff --git a/pkg/api/deep_copy_generated.go b/pkg/api/deep_copy_generated.go index 6da9e27f0a5b8..dead657d3fee5 100644 --- a/pkg/api/deep_copy_generated.go +++ b/pkg/api/deep_copy_generated.go @@ -24,6 +24,8 @@ import ( resource "k8s.io/kubernetes/pkg/api/resource" unversioned "k8s.io/kubernetes/pkg/api/unversioned" conversion "k8s.io/kubernetes/pkg/conversion" + fields "k8s.io/kubernetes/pkg/fields" + labels "k8s.io/kubernetes/pkg/labels" runtime "k8s.io/kubernetes/pkg/runtime" intstr "k8s.io/kubernetes/pkg/util/intstr" 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 } +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 { out.IP = in.IP out.Hostname = in.Hostname @@ -2386,6 +2417,7 @@ func init() { deepCopy_api_LimitRangeList, deepCopy_api_LimitRangeSpec, deepCopy_api_List, + deepCopy_api_ListOptions, deepCopy_api_LoadBalancerIngress, deepCopy_api_LoadBalancerStatus, deepCopy_api_LocalObjectReference, diff --git a/pkg/api/register.go b/pkg/api/register.go index 65c0a5d919362..c85a33ed88222 100644 --- a/pkg/api/register.go +++ b/pkg/api/register.go @@ -89,7 +89,6 @@ func init() { // Register Unversioned types // TODO this should not be done here Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.ExportOptions{}) - Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.ListOptions{}) Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.Status{}) Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.APIVersions{}) Scheme.AddKnownTypes(SchemeGroupVersion, &unversioned.APIGroupList{}) diff --git a/pkg/api/rest/rest.go b/pkg/api/rest/rest.go index ceb962062e28e..32c78215ca287 100644 --- a/pkg/api/rest/rest.go +++ b/pkg/api/rest/rest.go @@ -61,7 +61,7 @@ type Lister interface { // This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object) NewList() runtime.Object // 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 @@ -141,7 +141,7 @@ type CollectionDeleter interface { // them or return an invalid request error. // 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. - 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. @@ -201,7 +201,7 @@ type Watcher interface { // 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 // 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 diff --git a/pkg/api/rest/resttest/resttest.go b/pkg/api/rest/resttest/resttest.go index 058a515d4bd2e..d565eb0abd85f 100644 --- a/pkg/api/rest/resttest/resttest.go +++ b/pkg/api/rest/resttest/resttest.go @@ -864,7 +864,7 @@ func (t *Tester) testListMatchLabels(obj runtime.Object, assignFn AssignFunc) { filtered := []runtime.Object{objs[1]} 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) if err != nil { 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 _, 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) if err != nil { 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 _, 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) if err != nil { 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 _, 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) if err != nil { 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 _, 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) if err != nil { t.Errorf("unexpected error: %v", err) diff --git a/pkg/api/testing/fuzzer.go b/pkg/api/testing/fuzzer.go index 0e923a27892c6..6e31eeff6c235 100644 --- a/pkg/api/testing/fuzzer.go +++ b/pkg/api/testing/fuzzer.go @@ -103,13 +103,6 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer { field, _ := fields.ParseSelector("a=b") 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) { j.Stdout = true j.Stderr = true diff --git a/pkg/api/unversioned/register.go b/pkg/api/unversioned/register.go index 29f5151381653..babc21dfe84e5 100644 --- a/pkg/api/unversioned/register.go +++ b/pkg/api/unversioned/register.go @@ -34,7 +34,6 @@ func (obj *TypeMeta) GroupVersionKind() *GroupVersionKind { return FromAPIVersionAndKind(obj.APIVersion, obj.Kind) } -func (obj *ListOptions) GetObjectKind() ObjectKind { return &obj.TypeMeta } func (obj *Status) GetObjectKind() ObjectKind { return &obj.TypeMeta } func (obj *APIVersions) GetObjectKind() ObjectKind { return &obj.TypeMeta } func (obj *APIGroupList) GetObjectKind() ObjectKind { return &obj.TypeMeta } diff --git a/pkg/api/unversioned/types.go b/pkg/api/unversioned/types.go index f2c018ae1a0d3..3c77fcfdf91ec 100644 --- a/pkg/api/unversioned/types.go +++ b/pkg/api/unversioned/types.go @@ -63,27 +63,6 @@ type ExportOptions struct { 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. type Status struct { TypeMeta `json:",inline"` diff --git a/pkg/api/unversioned/types_swagger_doc_generated.go b/pkg/api/unversioned/types_swagger_doc_generated.go index 8e337dd820ffb..6633ddf4fc136 100644 --- a/pkg/api/unversioned/types_swagger_doc_generated.go +++ b/pkg/api/unversioned/types_swagger_doc_generated.go @@ -106,19 +106,6 @@ func (ListMeta) SwaggerDoc() map[string]string { 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{ "": "Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.", } diff --git a/pkg/api/v1/conversion_generated.go b/pkg/api/v1/conversion_generated.go index 4b1bbabd4b158..1f2a637f488c9 100644 --- a/pkg/api/v1/conversion_generated.go +++ b/pkg/api/v1/conversion_generated.go @@ -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) } +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 { if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { 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) } -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 { if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { 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) } -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 { defaulting.(func(*ListOptions))(in) } @@ -4211,8 +4211,8 @@ func autoconvert_v1_ListOptions_To_unversioned_ListOptions(in *ListOptions, out return nil } -func convert_v1_ListOptions_To_unversioned_ListOptions(in *ListOptions, out *unversioned.ListOptions, s conversion.Scope) error { - return autoconvert_v1_ListOptions_To_unversioned_ListOptions(in, out, s) +func convert_v1_ListOptions_To_api_ListOptions(in *ListOptions, out *api.ListOptions, s conversion.Scope) error { + 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 { @@ -6187,6 +6187,7 @@ func init() { autoconvert_api_LimitRangeList_To_v1_LimitRangeList, autoconvert_api_LimitRangeSpec_To_v1_LimitRangeSpec, autoconvert_api_LimitRange_To_v1_LimitRange, + autoconvert_api_ListOptions_To_v1_ListOptions, autoconvert_api_List_To_v1_List, autoconvert_api_LoadBalancerIngress_To_v1_LoadBalancerIngress, autoconvert_api_LoadBalancerStatus_To_v1_LoadBalancerStatus, @@ -6260,7 +6261,6 @@ func init() { autoconvert_api_VolumeSource_To_v1_VolumeSource, autoconvert_api_Volume_To_v1_Volume, autoconvert_unversioned_ExportOptions_To_v1_ExportOptions, - autoconvert_unversioned_ListOptions_To_v1_ListOptions, autoconvert_v1_AWSElasticBlockStoreVolumeSource_To_api_AWSElasticBlockStoreVolumeSource, autoconvert_v1_Binding_To_api_Binding, autoconvert_v1_Capabilities_To_api_Capabilities, @@ -6307,7 +6307,7 @@ func init() { autoconvert_v1_LimitRangeList_To_api_LimitRangeList, autoconvert_v1_LimitRangeSpec_To_api_LimitRangeSpec, 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_LoadBalancerIngress_To_api_LoadBalancerIngress, autoconvert_v1_LoadBalancerStatus_To_api_LoadBalancerStatus, diff --git a/pkg/api/v1/conversion_test.go b/pkg/api/v1/conversion_test.go index d6496cfb5e00b..ad9115994850e 100644 --- a/pkg/api/v1/conversion_test.go +++ b/pkg/api/v1/conversion_test.go @@ -17,12 +17,9 @@ limitations under the License. package v1_test import ( - "encoding/json" - "reflect" "testing" "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/unversioned" 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) - } - } -} diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index 7bbc0e0f51faf..f4f24090ee50c 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -89,7 +89,7 @@ type APIGroupVersion struct { RequestInfoResolver *RequestInfoResolver // 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 // empty, defaults to GroupVersion. OptionsExternalVersion *unversioned.GroupVersion diff --git a/pkg/apiserver/apiserver_test.go b/pkg/apiserver/apiserver_test.go index b91761369b7f0..6512d90fcebe5 100644 --- a/pkg/apiserver/apiserver_test.go +++ b/pkg/apiserver/apiserver_test.go @@ -108,24 +108,51 @@ func newMapper() *meta.DefaultRESTMapper { } 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( 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{}) } 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( testGroupVersion, &apiservertesting.Simple{}, &apiservertesting.SimpleList{}, &unversioned.Status{}, - &unversioned.ListOptions{}, &api.DeleteOptions{}, &apiservertesting.SimpleGetOptions{}, &apiservertesting.SimpleRoot{}, + &ListOptions{}, &api.DeleteOptions{}, &apiservertesting.SimpleGetOptions{}, &apiservertesting.SimpleRoot{}, &unversioned.ExportOptions{}) api.Scheme.AddKnownTypes(testGroupVersion, &api.Pod{}) } 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( newGroupVersion, &apiservertesting.Simple{}, &apiservertesting.SimpleList{}, &unversioned.Status{}, - &unversioned.ListOptions{}, &api.DeleteOptions{}, &apiservertesting.SimpleGetOptions{}, &apiservertesting.SimpleRoot{}, + &ListOptions{}, &api.DeleteOptions{}, &apiservertesting.SimpleGetOptions{}, &apiservertesting.SimpleRoot{}, &unversioned.ExportOptions{}) } @@ -136,7 +163,7 @@ func init() { // "internal" version api.Scheme.AddKnownTypes( testInternalGroupVersion, &apiservertesting.Simple{}, &apiservertesting.SimpleList{}, &unversioned.Status{}, - &unversioned.ListOptions{}, &apiservertesting.SimpleGetOptions{}, &apiservertesting.SimpleRoot{}) + &api.ListOptions{}, &apiservertesting.SimpleGetOptions{}, &apiservertesting.SimpleRoot{}) api.Scheme.AddInternalGroupVersion(testInternalGroupVersion) addGrouplessTypes() addTestTypes() @@ -351,18 +378,18 @@ func (storage *SimpleRESTStorage) Export(ctx api.Context, name string, opts unve 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) result := &apiservertesting.SimpleList{ Items: storage.list, } storage.requestedLabelSelector = labels.Everything() - if options != nil && options.LabelSelector.Selector != nil { - storage.requestedLabelSelector = options.LabelSelector.Selector + if options != nil && options.LabelSelector != nil { + storage.requestedLabelSelector = options.LabelSelector } storage.requestedFieldSelector = fields.Everything() - if options != nil && options.FieldSelector.Selector != nil { - storage.requestedFieldSelector = options.FieldSelector.Selector + if options != nil && options.FieldSelector != nil { + storage.requestedFieldSelector = options.FieldSelector } return result, storage.errors["list"] } @@ -460,15 +487,15 @@ func (storage *SimpleRESTStorage) Update(ctx api.Context, obj runtime.Object) (r } // 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.requestedLabelSelector = labels.Everything() - if options != nil && options.LabelSelector.Selector != nil { - storage.requestedLabelSelector = options.LabelSelector.Selector + if options != nil && options.LabelSelector != nil { + storage.requestedLabelSelector = options.LabelSelector } storage.requestedFieldSelector = fields.Everything() - if options != nil && options.FieldSelector.Selector != nil { - storage.requestedFieldSelector = options.FieldSelector.Selector + if options != nil && options.FieldSelector != nil { + storage.requestedFieldSelector = options.FieldSelector } storage.requestedResourceVersion = "" if options != nil { diff --git a/pkg/apiserver/resthandler.go b/pkg/apiserver/resthandler.go index cc3c4732b060f..15a637c6b9bbf 100644 --- a/pkg/apiserver/resthandler.go +++ b/pkg/apiserver/resthandler.go @@ -264,19 +264,29 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch ctx := scope.ContextFunc(req) ctx = api.WithNamespace(ctx, namespace) - opts := unversioned.ListOptions{} - if err := scope.Codec.DecodeParametersInto(req.Request.URL.Query(), &opts); err != nil { + listOptionsGVK := scope.Kind.GroupVersion().WithKind("ListOptions") + 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) return } // transform fields // TODO: DecodeParametersInto should do this. - if opts.FieldSelector.Selector != nil { + if opts.FieldSelector != nil { fn := func(label, value string) (newLabel, newValue string, err error) { 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 err = errors.NewBadRequest(err.Error()) 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 // storage query accordingly. 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 // and a field selector, since just the name is // sufficient to narrow down the request to a @@ -302,7 +312,7 @@ func ListResource(r rest.Lister, rw rest.Watcher, scope RequestScope, forceWatch ) return } - opts.FieldSelector.Selector = nameSelector + opts.FieldSelector = nameSelector } if (opts.Watch || forceWatch) && rw != nil { @@ -777,19 +787,29 @@ func DeleteCollection(r rest.CollectionDeleter, checkBody bool, scope RequestSco } } - listOptions := unversioned.ListOptions{} - if err := scope.Codec.DecodeParametersInto(req.Request.URL.Query(), &listOptions); err != nil { + listOptionsGVK := scope.Kind.GroupVersion().WithKind("ListOptions") + 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) return } // transform fields // TODO: DecodeParametersInto should do this. - if listOptions.FieldSelector.Selector != nil { + if listOptions.FieldSelector != nil { fn := func(label, value string) (newLabel, newValue string, err error) { 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 err = errors.NewBadRequest(err.Error()) errorJSON(err, scope.Codec, w) diff --git a/pkg/registry/componentstatus/rest.go b/pkg/registry/componentstatus/rest.go index 040fa19a0d96d..f4819bf6aed12 100644 --- a/pkg/registry/componentstatus/rest.go +++ b/pkg/registry/componentstatus/rest.go @@ -21,7 +21,6 @@ import ( "net/http" "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/apiserver" "k8s.io/kubernetes/pkg/probe" "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. // 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() wait := sync.WaitGroup{} diff --git a/pkg/registry/configmap/registry.go b/pkg/registry/configmap/registry.go index 53968e03b3178..a76ecbaa6d2ce 100644 --- a/pkg/registry/configmap/registry.go +++ b/pkg/registry/configmap/registry.go @@ -19,15 +19,14 @@ package configmap import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface for things that know how to store ConfigMaps. type Registry interface { - ListConfigMaps(ctx api.Context, options *unversioned.ListOptions) (*extensions.ConfigMapList, error) - WatchConfigMaps(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) + ListConfigMaps(ctx api.Context, options *api.ListOptions) (*extensions.ConfigMapList, error) + WatchConfigMaps(ctx api.Context, options *api.ListOptions) (watch.Interface, error) GetConfigMap(ctx api.Context, name string) (*extensions.ConfigMap, error) CreateConfigMap(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} } -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) if err != nil { return nil, err @@ -54,7 +53,7 @@ func (s *storage) ListConfigMaps(ctx api.Context, options *unversioned.ListOptio 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) } diff --git a/pkg/registry/controller/registry.go b/pkg/registry/controller/registry.go index 1f5f38a86f2c2..12aa757405c1e 100644 --- a/pkg/registry/controller/registry.go +++ b/pkg/registry/controller/registry.go @@ -21,14 +21,13 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface for things that know how to store ReplicationControllers. type Registry interface { - ListControllers(ctx api.Context, options *unversioned.ListOptions) (*api.ReplicationControllerList, error) - WatchControllers(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) + ListControllers(ctx api.Context, options *api.ListOptions) (*api.ReplicationControllerList, error) + WatchControllers(ctx api.Context, options *api.ListOptions) (watch.Interface, error) GetController(ctx api.Context, controllerID string) (*api.ReplicationController, error) CreateController(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} } -func (s *storage) ListControllers(ctx api.Context, options *unversioned.ListOptions) (*api.ReplicationControllerList, error) { - if options != nil && options.FieldSelector.Selector != nil && !options.FieldSelector.Selector.Empty() { +func (s *storage) ListControllers(ctx api.Context, options *api.ListOptions) (*api.ReplicationControllerList, error) { + if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() { return nil, fmt.Errorf("field selector not supported yet") } 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 } -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) } diff --git a/pkg/registry/deployment/registry.go b/pkg/registry/deployment/registry.go index f7d565cbeb61d..ec967e93d9cef 100644 --- a/pkg/registry/deployment/registry.go +++ b/pkg/registry/deployment/registry.go @@ -21,13 +21,12 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/apis/extensions" ) // Registry is an interface for things that know how to store Deployments. 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) CreateDeployment(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} } -func (s *storage) ListDeployments(ctx api.Context, options *unversioned.ListOptions) (*extensions.DeploymentList, error) { - if options != nil && options.FieldSelector.Selector != nil && !options.FieldSelector.Selector.Empty() { +func (s *storage) ListDeployments(ctx api.Context, options *api.ListOptions) (*extensions.DeploymentList, error) { + if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() { return nil, fmt.Errorf("field selector not supported yet") } obj, err := s.List(ctx, options) diff --git a/pkg/registry/endpoint/registry.go b/pkg/registry/endpoint/registry.go index 331bd82f71ba3..a034852fb6dd0 100644 --- a/pkg/registry/endpoint/registry.go +++ b/pkg/registry/endpoint/registry.go @@ -19,15 +19,14 @@ package endpoint import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface for things that know how to store endpoints. 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) - 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 DeleteEndpoints(ctx api.Context, name string) error } @@ -43,7 +42,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -51,7 +50,7 @@ func (s *storage) ListEndpoints(ctx api.Context, options *unversioned.ListOption 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) } diff --git a/pkg/registry/generic/etcd/etcd.go b/pkg/registry/generic/etcd/etcd.go index 33599ac1ad393..317ffea797232 100644 --- a/pkg/registry/generic/etcd/etcd.go +++ b/pkg/registry/generic/etcd/etcd.go @@ -162,20 +162,20 @@ func (e *Etcd) NewList() runtime.Object { } // 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() - if options != nil && options.LabelSelector.Selector != nil { - label = options.LabelSelector.Selector + if options != nil && options.LabelSelector != nil { + label = options.LabelSelector } field := fields.Everything() - if options != nil && options.FieldSelector.Selector != nil { - field = options.FieldSelector.Selector + if options != nil && options.FieldSelector != nil { + field = options.FieldSelector } return e.ListPredicate(ctx, e.PredicateFunc(label, field), options) } // 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() filterFunc := e.filterAndDecorateFunction(m) 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 { - options = &unversioned.ListOptions{ResourceVersion: "0"} + options = &api.ListOptions{ResourceVersion: "0"} } err := e.Storage.List(ctx, e.KeyRootFunc(ctx), options.ResourceVersion, filterFunc, list) 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 // possibly with etcd API, but watch is not delivered correctly then). // 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) if err != nil { 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 // matcher that matches by key. generic.SelectionPredicate does this for you // 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() - if options != nil && options.LabelSelector.Selector != nil { - label = options.LabelSelector.Selector + if options != nil && options.LabelSelector != nil { + label = options.LabelSelector } field := fields.Everything() - if options != nil && options.FieldSelector.Selector != nil { - field = options.FieldSelector.Selector + if options != nil && options.FieldSelector != nil { + field = options.FieldSelector } resourceVersion := "" if options != nil { diff --git a/pkg/registry/generic/etcd/etcd_test.go b/pkg/registry/generic/etcd/etcd_test.go index 01322cf3f1926..ef942e20a60b9 100644 --- a/pkg/registry/generic/etcd/etcd_test.go +++ b/pkg/registry/generic/etcd/etcd_test.go @@ -500,7 +500,7 @@ func TestEtcdDeleteCollection(t *testing.T) { } // Delete all pods. - deleted, err := registry.DeleteCollection(testContext, nil, &unversioned.ListOptions{}) + deleted, err := registry.DeleteCollection(testContext, nil, &api.ListOptions{}) if err != nil { t.Fatalf("Unexpected error: %v", err) } @@ -537,7 +537,7 @@ func TestEtcdDeleteCollectionWithWatch(t *testing.T) { 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) } diff --git a/pkg/registry/namespace/registry.go b/pkg/registry/namespace/registry.go index 4483aef73a7b1..33b50d32e673a 100644 --- a/pkg/registry/namespace/registry.go +++ b/pkg/registry/namespace/registry.go @@ -19,14 +19,13 @@ package namespace import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface implemented by things that know how to store Namespace objects. type Registry interface { - ListNamespaces(ctx api.Context, options *unversioned.ListOptions) (*api.NamespaceList, error) - WatchNamespaces(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) + ListNamespaces(ctx api.Context, options *api.ListOptions) (*api.NamespaceList, error) + WatchNamespaces(ctx api.Context, options *api.ListOptions) (watch.Interface, error) GetNamespace(ctx api.Context, namespaceID string) (*api.Namespace, error) CreateNamespace(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} } -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) if err != nil { return nil, err @@ -52,7 +51,7 @@ func (s *storage) ListNamespaces(ctx api.Context, options *unversioned.ListOptio 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) } diff --git a/pkg/registry/node/registry.go b/pkg/registry/node/registry.go index ff6839540d7dc..3d6f3bf07eace 100644 --- a/pkg/registry/node/registry.go +++ b/pkg/registry/node/registry.go @@ -19,18 +19,17 @@ package node import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface for things that know how to store node. 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 UpdateNode(ctx api.Context, node *api.Node) error GetNode(ctx api.Context, nodeID string) (*api.Node, 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 @@ -44,7 +43,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -63,7 +62,7 @@ func (s *storage) UpdateNode(ctx api.Context, node *api.Node) error { 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) } diff --git a/pkg/registry/registrytest/endpoint.go b/pkg/registry/registrytest/endpoint.go index 42c459510e9b0..d11dafa67277c 100644 --- a/pkg/registry/registrytest/endpoint.go +++ b/pkg/registry/registrytest/endpoint.go @@ -22,7 +22,6 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/errors" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/watch" ) @@ -35,7 +34,7 @@ type EndpointRegistry struct { 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 e.lock.Lock() 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) } -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!") } diff --git a/pkg/registry/registrytest/node.go b/pkg/registry/registrytest/node.go index 1f47c3e7b022a..8f917b9bcf535 100644 --- a/pkg/registry/registrytest/node.go +++ b/pkg/registry/registrytest/node.go @@ -21,7 +21,6 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/errors" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/watch" ) @@ -58,7 +57,7 @@ func (r *NodeRegistry) SetError(err error) { 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() defer r.Unlock() return &r.Nodes, r.Err @@ -111,6 +110,6 @@ func (r *NodeRegistry) DeleteNode(ctx api.Context, nodeID string) error { 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 } diff --git a/pkg/registry/registrytest/service.go b/pkg/registry/registrytest/service.go index b0791baba93ec..643c306cb724e 100644 --- a/pkg/registry/registrytest/service.go +++ b/pkg/registry/registrytest/service.go @@ -20,7 +20,6 @@ import ( "sync" "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/watch" ) @@ -46,7 +45,7 @@ func (r *ServiceRegistry) SetError(err error) { 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() defer r.mu.Unlock() @@ -107,7 +106,7 @@ func (r *ServiceRegistry) UpdateService(ctx api.Context, svc *api.Service) (*api 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() defer r.mu.Unlock() diff --git a/pkg/registry/secret/registry.go b/pkg/registry/secret/registry.go index 0369c1928fdb4..ef989f0067b00 100644 --- a/pkg/registry/secret/registry.go +++ b/pkg/registry/secret/registry.go @@ -19,14 +19,13 @@ package secret import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface implemented by things that know how to store Secret objects. type Registry interface { - ListSecrets(ctx api.Context, options *unversioned.ListOptions) (*api.SecretList, error) - WatchSecrets(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) + ListSecrets(ctx api.Context, options *api.ListOptions) (*api.SecretList, error) + WatchSecrets(ctx api.Context, options *api.ListOptions) (watch.Interface, error) GetSecret(ctx api.Context, name string) (*api.Secret, error) CreateSecret(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} } -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) if err != nil { return nil, err @@ -52,7 +51,7 @@ func (s *storage) ListSecrets(ctx api.Context, options *unversioned.ListOptions) 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) } diff --git a/pkg/registry/service/ipallocator/controller/repair.go b/pkg/registry/service/ipallocator/controller/repair.go index fde97ca11e412..cc95a5762384d 100644 --- a/pkg/registry/service/ipallocator/controller/repair.go +++ b/pkg/registry/service/ipallocator/controller/repair.go @@ -22,7 +22,6 @@ import ( "time" "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/registry/service" "k8s.io/kubernetes/pkg/registry/service/ipallocator" "k8s.io/kubernetes/pkg/util" @@ -93,7 +92,7 @@ func (c *Repair) RunOnce() error { } 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) if err != nil { return fmt.Errorf("unable to refresh the service IP block: %v", err) diff --git a/pkg/registry/service/portallocator/controller/repair.go b/pkg/registry/service/portallocator/controller/repair.go index 7fe6dcd416620..c388a8dc95508 100644 --- a/pkg/registry/service/portallocator/controller/repair.go +++ b/pkg/registry/service/portallocator/controller/repair.go @@ -21,7 +21,6 @@ import ( "time" "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/registry/service" "k8s.io/kubernetes/pkg/registry/service/portallocator" "k8s.io/kubernetes/pkg/util" @@ -80,7 +79,7 @@ func (c *Repair) RunOnce() error { } 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) if err != nil { return fmt.Errorf("unable to refresh the port block: %v", err) diff --git a/pkg/registry/service/registry.go b/pkg/registry/service/registry.go index c0589c1558f85..154dcb9d19213 100644 --- a/pkg/registry/service/registry.go +++ b/pkg/registry/service/registry.go @@ -19,18 +19,17 @@ package service import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface for things that know how to store services. 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) GetService(ctx api.Context, name string) (*api.Service, error) DeleteService(ctx api.Context, name string) 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 @@ -44,7 +43,7 @@ func NewRegistry(s rest.StandardStorage) Registry { 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) if err != nil { return nil, err @@ -81,7 +80,7 @@ func (s *storage) UpdateService(ctx api.Context, svc *api.Service) (*api.Service 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) } diff --git a/pkg/registry/service/rest.go b/pkg/registry/service/rest.go index f971d1d9304d8..9d070545f8ece 100644 --- a/pkg/registry/service/rest.go +++ b/pkg/registry/service/rest.go @@ -178,13 +178,13 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) { 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) } // Watch returns Services events via a watch.Interface. // 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) } diff --git a/pkg/registry/serviceaccount/registry.go b/pkg/registry/serviceaccount/registry.go index 278648bb9bc0c..4dad500bc61ef 100644 --- a/pkg/registry/serviceaccount/registry.go +++ b/pkg/registry/serviceaccount/registry.go @@ -19,14 +19,13 @@ package serviceaccount import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface implemented by things that know how to store ServiceAccount objects. type Registry interface { - ListServiceAccounts(ctx api.Context, options *unversioned.ListOptions) (*api.ServiceAccountList, error) - WatchServiceAccounts(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) + ListServiceAccounts(ctx api.Context, options *api.ListOptions) (*api.ServiceAccountList, error) + WatchServiceAccounts(ctx api.Context, options *api.ListOptions) (watch.Interface, error) GetServiceAccount(ctx api.Context, name string) (*api.ServiceAccount, error) CreateServiceAccount(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} } -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) if err != nil { return nil, err @@ -52,7 +51,7 @@ func (s *storage) ListServiceAccounts(ctx api.Context, options *unversioned.List 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) } diff --git a/pkg/registry/thirdpartyresourcedata/codec.go b/pkg/registry/thirdpartyresourcedata/codec.go index 33002775eb858..e85ebfc830986 100644 --- a/pkg/registry/thirdpartyresourcedata/codec.go +++ b/pkg/registry/thirdpartyresourcedata/codec.go @@ -302,6 +302,13 @@ func (t *thirdPartyResourceDataCreator) New(kind unversioned.GroupVersionKind) ( return nil, fmt.Errorf("unknown kind %v", kind) } 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: return t.delegate.New(kind) } diff --git a/pkg/registry/thirdpartyresourcedata/registry.go b/pkg/registry/thirdpartyresourcedata/registry.go index 09600e38d757c..5e560dede2d40 100644 --- a/pkg/registry/thirdpartyresourcedata/registry.go +++ b/pkg/registry/thirdpartyresourcedata/registry.go @@ -19,15 +19,14 @@ package thirdpartyresourcedata import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/rest" - "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/watch" ) // Registry is an interface implemented by things that know how to store ThirdPartyResourceData objects. type Registry interface { - ListThirdPartyResourceData(ctx api.Context, options *unversioned.ListOptions) (*extensions.ThirdPartyResourceDataList, error) - WatchThirdPartyResourceData(ctx api.Context, options *unversioned.ListOptions) (watch.Interface, error) + ListThirdPartyResourceData(ctx api.Context, options *api.ListOptions) (*extensions.ThirdPartyResourceDataList, error) + WatchThirdPartyResourceData(ctx api.Context, options *api.ListOptions) (watch.Interface, error) GetThirdPartyResourceData(ctx api.Context, name string) (*extensions.ThirdPartyResourceData, error) CreateThirdPartyResourceData(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} } -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) if err != nil { return nil, err @@ -53,7 +52,7 @@ func (s *storage) ListThirdPartyResourceData(ctx api.Context, options *unversion 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) }