manual changes to let client-gen use versioned options

This commit is contained in:
Chao Xu
2016-09-02 11:57:44 -07:00
parent d26b4ca285
commit 75cc05de82
34 changed files with 401 additions and 317 deletions

View File

@@ -102,10 +102,12 @@ func NewNamespaceController(client federationclientset.Interface) *NamespaceCont
nc.namespaceInformerStore, nc.namespaceInformerController = cache.NewInformer(
&cache.ListWatch{
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
return client.Core().Namespaces().List(options)
versionedOptions := util.VersionizeV1ListOptions(options)
return client.Core().Namespaces().List(versionedOptions)
},
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return client.Core().Namespaces().Watch(options)
versionedOptions := util.VersionizeV1ListOptions(options)
return client.Core().Namespaces().Watch(versionedOptions)
},
},
&api_v1.Namespace{},
@@ -119,10 +121,12 @@ func NewNamespaceController(client federationclientset.Interface) *NamespaceCont
return cache.NewInformer(
&cache.ListWatch{
ListFunc: func(options api.ListOptions) (pkg_runtime.Object, error) {
return targetClient.Core().Namespaces().List(options)
versionedOptions := util.VersionizeV1ListOptions(options)
return targetClient.Core().Namespaces().List(versionedOptions)
},
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return targetClient.Core().Namespaces().Watch(options)
versionedOptions := util.VersionizeV1ListOptions(options)
return targetClient.Core().Namespaces().Watch(versionedOptions)
},
},
&api_v1.Namespace{},
@@ -156,7 +160,7 @@ func NewNamespaceController(client federationclientset.Interface) *NamespaceCont
},
func(client kubeclientset.Interface, obj pkg_runtime.Object) error {
namespace := obj.(*api_v1.Namespace)
err := client.Core().Namespaces().Delete(namespace.Name, &api.DeleteOptions{})
err := client.Core().Namespaces().Delete(namespace.Name, &api_v1.DeleteOptions{})
return err
})
return nc
@@ -345,23 +349,23 @@ func (nc *NamespaceController) delete(namespace *api_v1.Namespace) error {
// Right now there is just 5 types of objects: ReplicaSet, Secret, Ingress, Events and Service.
// Temporarly these items are simply deleted one by one to squeeze this code into 1.4.
// TODO: Make it generic (like in the regular namespace controller) and parallel.
err := nc.federatedApiClient.Core().Services(namespace.Name).DeleteCollection(&api.DeleteOptions{}, api.ListOptions{})
err := nc.federatedApiClient.Core().Services(namespace.Name).DeleteCollection(&api_v1.DeleteOptions{}, api_v1.ListOptions{})
if err != nil {
return fmt.Errorf("failed to delete service list: %v", err)
}
err = nc.federatedApiClient.Extensions().ReplicaSets(namespace.Name).DeleteCollection(&api.DeleteOptions{}, api.ListOptions{})
err = nc.federatedApiClient.Extensions().ReplicaSets(namespace.Name).DeleteCollection(&api_v1.DeleteOptions{}, api_v1.ListOptions{})
if err != nil {
return fmt.Errorf("failed to delete replicaset list from namespace: %v", err)
}
err = nc.federatedApiClient.Core().Secrets(namespace.Name).DeleteCollection(&api.DeleteOptions{}, api.ListOptions{})
err = nc.federatedApiClient.Core().Secrets(namespace.Name).DeleteCollection(&api_v1.DeleteOptions{}, api_v1.ListOptions{})
if err != nil {
return fmt.Errorf("failed to delete secret list from namespace: %v", err)
}
err = nc.federatedApiClient.Extensions().Ingresses(namespace.Name).DeleteCollection(&api.DeleteOptions{}, api.ListOptions{})
err = nc.federatedApiClient.Extensions().Ingresses(namespace.Name).DeleteCollection(&api_v1.DeleteOptions{}, api_v1.ListOptions{})
if err != nil {
return fmt.Errorf("failed to delete ingresses list from namespace: %v", err)
}
err = nc.federatedApiClient.Core().Events(namespace.Name).DeleteCollection(&api.DeleteOptions{}, api.ListOptions{})
err = nc.federatedApiClient.Core().Events(namespace.Name).DeleteCollection(&api_v1.DeleteOptions{}, api_v1.ListOptions{})
if err != nil {
return fmt.Errorf("failed to delete events list from namespace: %v", err)
}
@@ -385,7 +389,7 @@ func (nc *NamespaceController) delete(namespace *api_v1.Namespace) error {
}
// TODO: What about namespaces in subclusters ???
err = nc.federatedApiClient.Core().Namespaces().Delete(updatedNamespace.Name, &api.DeleteOptions{})
err = nc.federatedApiClient.Core().Namespaces().Delete(updatedNamespace.Name, &api_v1.DeleteOptions{})
if err != nil {
// Its all good if the error is not found error. That means it is deleted already and we do not have to do anything.
// This is expected when we are processing an update as a result of namespace finalizer deletion.