Switch to versioned ListOptions in client.

This commit is contained in:
Wojciech Tyczynski
2015-12-10 10:39:03 +01:00
parent 4ef062c22f
commit 960808bf08
167 changed files with 602 additions and 671 deletions

View File

@@ -23,7 +23,6 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/record"
@@ -96,10 +95,10 @@ func NewDaemonSetsController(kubeClient client.Interface, resyncPeriod controlle
// Manage addition/update of daemon sets.
dsc.dsStore.Store, dsc.dsController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return dsc.kubeClient.Extensions().DaemonSets(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return dsc.kubeClient.Extensions().DaemonSets(api.NamespaceAll).Watch(options)
},
},
@@ -128,10 +127,10 @@ func NewDaemonSetsController(kubeClient client.Interface, resyncPeriod controlle
// more pods until all the effects (expectations) of a daemon set's create/delete have been observed.
dsc.podStore.Store, dsc.podController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return dsc.kubeClient.Pods(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return dsc.kubeClient.Pods(api.NamespaceAll).Watch(options)
},
},
@@ -146,10 +145,10 @@ func NewDaemonSetsController(kubeClient client.Interface, resyncPeriod controlle
// Watch for new nodes or updates to nodes - daemon pods are launched on new nodes, and possibly when labels on nodes change,
dsc.nodeStore.Store, dsc.nodeController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return dsc.kubeClient.Nodes().List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return dsc.kubeClient.Nodes().Watch(options)
},
},

View File

@@ -23,7 +23,6 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/record"
client "k8s.io/kubernetes/pkg/client/unversioned"
@@ -59,7 +58,7 @@ func (d *DeploymentController) Run(syncPeriod time.Duration) {
}
func (d *DeploymentController) reconcileDeployments() []error {
list, err := d.expClient.Deployments(api.NamespaceAll).List(unversioned.ListOptions{})
list, err := d.expClient.Deployments(api.NamespaceAll).List(api.ListOptions{})
if err != nil {
return []error{fmt.Errorf("error listing deployments: %v", err)}
}

View File

@@ -26,7 +26,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/endpoints"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/cache"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/controller"
@@ -62,10 +61,10 @@ func NewEndpointController(client *client.Client, resyncPeriod controller.Resync
e.serviceStore.Store, e.serviceController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return e.client.Services(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return e.client.Services(api.NamespaceAll).Watch(options)
},
},
@@ -83,10 +82,10 @@ func NewEndpointController(client *client.Client, resyncPeriod controller.Resync
e.podStore.Store, e.podController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return e.client.Pods(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return e.client.Pods(api.NamespaceAll).Watch(options)
},
},
@@ -385,7 +384,7 @@ func (e *EndpointController) syncService(key string) {
// some stragglers could have been left behind if the endpoint controller
// reboots).
func (e *EndpointController) checkLeftoverEndpoints() {
list, err := e.client.Endpoints(api.NamespaceAll).List(unversioned.ListOptions{})
list, err := e.client.Endpoints(api.NamespaceAll).List(api.ListOptions{})
if err != nil {
glog.Errorf("Unable to list endpoints (%v); orphaned endpoints will not be cleaned up. (They're pretty harmless, but you can restart this component if you want another attempt made.)", err)
return

View File

@@ -24,7 +24,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/watch"
@@ -122,7 +121,7 @@ func (f *FakeControllerSource) Change(e watch.Event, watchProbability float64) {
}
// List returns a list object, with its resource version set.
func (f *FakeControllerSource) List(options unversioned.ListOptions) (runtime.Object, error) {
func (f *FakeControllerSource) List(options api.ListOptions) (runtime.Object, error) {
f.lock.RLock()
defer f.lock.RUnlock()
list := make([]runtime.Object, 0, len(f.items))
@@ -152,7 +151,7 @@ func (f *FakeControllerSource) List(options unversioned.ListOptions) (runtime.Ob
// Watch returns a watch, which will be pre-populated with all changes
// after resourceVersion.
func (f *FakeControllerSource) Watch(options unversioned.ListOptions) (watch.Interface, error) {
func (f *FakeControllerSource) Watch(options api.ListOptions) (watch.Interface, error) {
f.lock.RLock()
defer f.lock.RUnlock()
rc, err := strconv.Atoi(options.ResourceVersion)

View File

@@ -21,7 +21,6 @@ import (
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
@@ -65,13 +64,13 @@ func TestRCNumber(t *testing.T) {
source.Modify(pod("foo"))
source.Modify(pod("foo"))
w, err := source.Watch(unversioned.ListOptions{ResourceVersion: "1"})
w, err := source.Watch(api.ListOptions{ResourceVersion: "1"})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
go consume(t, w, []string{"2", "3"}, wg)
list, err := source.List(unversioned.ListOptions{})
list, err := source.List(api.ListOptions{})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
@@ -79,13 +78,13 @@ func TestRCNumber(t *testing.T) {
t.Errorf("wanted %v, got %v", e, a)
}
w2, err := source.Watch(unversioned.ListOptions{ResourceVersion: "2"})
w2, err := source.Watch(api.ListOptions{ResourceVersion: "2"})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
go consume(t, w2, []string{"3"}, wg)
w3, err := source.Watch(unversioned.ListOptions{ResourceVersion: "3"})
w3, err := source.Watch(api.ListOptions{ResourceVersion: "3"})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}

View File

@@ -22,7 +22,6 @@ import (
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/record"
client "k8s.io/kubernetes/pkg/client/unversioned"
@@ -66,12 +65,12 @@ func New(kubeClient client.Interface, resyncPeriod controller.ResyncPeriodFunc,
gcc.podStore.Store, gcc.podStoreSyncer = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
options.FieldSelector.Selector = terminatedSelector
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
options.FieldSelector = terminatedSelector
return gcc.kubeClient.Pods(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
options.FieldSelector.Selector = terminatedSelector
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
options.FieldSelector = terminatedSelector
return gcc.kubeClient.Pods(api.NamespaceAll).Watch(options)
},
},

View File

@@ -83,10 +83,10 @@ func NewJobController(kubeClient client.Interface, resyncPeriod controller.Resyn
jm.jobStore.Store, jm.jobController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return jm.kubeClient.Extensions().Jobs(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return jm.kubeClient.Extensions().Jobs(api.NamespaceAll).Watch(options)
},
},
@@ -106,10 +106,10 @@ func NewJobController(kubeClient client.Interface, resyncPeriod controller.Resyn
jm.podStore.Store, jm.podController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return jm.kubeClient.Pods(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return jm.kubeClient.Pods(api.NamespaceAll).Watch(options)
},
},

View File

@@ -45,10 +45,10 @@ func NewNamespaceController(kubeClient client.Interface, versions *unversioned.A
var controller *framework.Controller
_, controller = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return kubeClient.Namespaces().List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return kubeClient.Namespaces().Watch(options)
},
},
@@ -337,7 +337,7 @@ func syncNamespace(kubeClient client.Interface, versions *unversioned.APIVersion
}
func deleteLimitRanges(kubeClient client.Interface, ns string) error {
items, err := kubeClient.LimitRanges(ns).List(unversioned.ListOptions{})
items, err := kubeClient.LimitRanges(ns).List(api.ListOptions{})
if err != nil {
return err
}
@@ -351,7 +351,7 @@ func deleteLimitRanges(kubeClient client.Interface, ns string) error {
}
func deleteResourceQuotas(kubeClient client.Interface, ns string) error {
resourceQuotas, err := kubeClient.ResourceQuotas(ns).List(unversioned.ListOptions{})
resourceQuotas, err := kubeClient.ResourceQuotas(ns).List(api.ListOptions{})
if err != nil {
return err
}
@@ -365,7 +365,7 @@ func deleteResourceQuotas(kubeClient client.Interface, ns string) error {
}
func deleteServiceAccounts(kubeClient client.Interface, ns string) error {
items, err := kubeClient.ServiceAccounts(ns).List(unversioned.ListOptions{})
items, err := kubeClient.ServiceAccounts(ns).List(api.ListOptions{})
if err != nil {
return err
}
@@ -379,7 +379,7 @@ func deleteServiceAccounts(kubeClient client.Interface, ns string) error {
}
func deleteServices(kubeClient client.Interface, ns string) error {
items, err := kubeClient.Services(ns).List(unversioned.ListOptions{})
items, err := kubeClient.Services(ns).List(api.ListOptions{})
if err != nil {
return err
}
@@ -393,7 +393,7 @@ func deleteServices(kubeClient client.Interface, ns string) error {
}
func deleteReplicationControllers(kubeClient client.Interface, ns string) error {
items, err := kubeClient.ReplicationControllers(ns).List(unversioned.ListOptions{})
items, err := kubeClient.ReplicationControllers(ns).List(api.ListOptions{})
if err != nil {
return err
}
@@ -407,7 +407,7 @@ func deleteReplicationControllers(kubeClient client.Interface, ns string) error
}
func deletePods(kubeClient client.Interface, ns string, before unversioned.Time) (int64, error) {
items, err := kubeClient.Pods(ns).List(unversioned.ListOptions{})
items, err := kubeClient.Pods(ns).List(api.ListOptions{})
if err != nil {
return 0, err
}
@@ -436,11 +436,11 @@ func deletePods(kubeClient client.Interface, ns string, before unversioned.Time)
}
func deleteEvents(kubeClient client.Interface, ns string) error {
return kubeClient.Events(ns).DeleteCollection(nil, unversioned.ListOptions{})
return kubeClient.Events(ns).DeleteCollection(nil, api.ListOptions{})
}
func deleteSecrets(kubeClient client.Interface, ns string) error {
items, err := kubeClient.Secrets(ns).List(unversioned.ListOptions{})
items, err := kubeClient.Secrets(ns).List(api.ListOptions{})
if err != nil {
return err
}
@@ -454,7 +454,7 @@ func deleteSecrets(kubeClient client.Interface, ns string) error {
}
func deletePersistentVolumeClaims(kubeClient client.Interface, ns string) error {
items, err := kubeClient.PersistentVolumeClaims(ns).List(unversioned.ListOptions{})
items, err := kubeClient.PersistentVolumeClaims(ns).List(api.ListOptions{})
if err != nil {
return err
}
@@ -468,7 +468,7 @@ func deletePersistentVolumeClaims(kubeClient client.Interface, ns string) error
}
func deleteHorizontalPodAutoscalers(expClient client.ExtensionsInterface, ns string) error {
items, err := expClient.HorizontalPodAutoscalers(ns).List(unversioned.ListOptions{})
items, err := expClient.HorizontalPodAutoscalers(ns).List(api.ListOptions{})
if err != nil {
return err
}
@@ -482,7 +482,7 @@ func deleteHorizontalPodAutoscalers(expClient client.ExtensionsInterface, ns str
}
func deleteDaemonSets(expClient client.ExtensionsInterface, ns string) error {
items, err := expClient.DaemonSets(ns).List(unversioned.ListOptions{})
items, err := expClient.DaemonSets(ns).List(api.ListOptions{})
if err != nil {
return err
}
@@ -496,7 +496,7 @@ func deleteDaemonSets(expClient client.ExtensionsInterface, ns string) error {
}
func deleteJobs(expClient client.ExtensionsInterface, ns string) error {
items, err := expClient.Jobs(ns).List(unversioned.ListOptions{})
items, err := expClient.Jobs(ns).List(api.ListOptions{})
if err != nil {
return err
}
@@ -510,7 +510,7 @@ func deleteJobs(expClient client.ExtensionsInterface, ns string) error {
}
func deleteDeployments(expClient client.ExtensionsInterface, ns string) error {
items, err := expClient.Deployments(ns).List(unversioned.ListOptions{})
items, err := expClient.Deployments(ns).List(api.ListOptions{})
if err != nil {
return err
}
@@ -524,7 +524,7 @@ func deleteDeployments(expClient client.ExtensionsInterface, ns string) error {
}
func deleteIngress(expClient client.ExtensionsInterface, ns string) error {
items, err := expClient.Ingress(ns).List(unversioned.ListOptions{})
items, err := expClient.Ingress(ns).List(api.ListOptions{})
if err != nil {
return err
}

View File

@@ -162,10 +162,10 @@ func NewNodeController(
nc.podStore.Store, nc.podController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return nc.kubeClient.Pods(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return nc.kubeClient.Pods(api.NamespaceAll).Watch(options)
},
},
@@ -178,10 +178,10 @@ func NewNodeController(
)
nc.nodeStore.Store, nc.nodeController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return nc.kubeClient.Nodes().List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return nc.kubeClient.Nodes().Watch(options)
},
},
@@ -354,7 +354,7 @@ func forcefullyDeletePod(c client.Interface, pod *api.Pod) {
// post "NodeReady==ConditionUnknown". It also evicts all pods if node is not ready or
// not reachable for a long period of time.
func (nc *NodeController) monitorNodeStatus() error {
nodes, err := nc.kubeClient.Nodes().List(unversioned.ListOptions{})
nodes, err := nc.kubeClient.Nodes().List(api.ListOptions{})
if err != nil {
return err
}
@@ -692,7 +692,7 @@ func (nc *NodeController) tryUpdateNodeStatus(node *api.Node) (time.Duration, ap
// the server could not be contacted.
func (nc *NodeController) hasPods(nodeName string) (bool, error) {
selector := fields.OneTermEqualSelector(client.PodHost, nodeName)
options := unversioned.ListOptions{FieldSelector: unversioned.FieldSelector{selector}}
options := api.ListOptions{FieldSelector: selector}
pods, err := nc.kubeClient.Pods(api.NamespaceAll).List(options)
if err != nil {
return false, err
@@ -727,7 +727,7 @@ func (nc *NodeController) cancelPodEviction(nodeName string) bool {
func (nc *NodeController) deletePods(nodeName string) (bool, error) {
remaining := false
selector := fields.OneTermEqualSelector(client.PodHost, nodeName)
options := unversioned.ListOptions{FieldSelector: unversioned.FieldSelector{selector}}
options := api.ListOptions{FieldSelector: selector}
pods, err := nc.kubeClient.Pods(api.NamespaceAll).List(options)
if err != nil {
return remaining, err
@@ -767,7 +767,7 @@ func (nc *NodeController) terminatePods(nodeName string, since time.Time) (bool,
complete := true
selector := fields.OneTermEqualSelector(client.PodHost, nodeName)
options := unversioned.ListOptions{FieldSelector: unversioned.FieldSelector{selector}}
options := api.ListOptions{FieldSelector: selector}
pods, err := nc.kubeClient.Pods(api.NamespaceAll).List(options)
if err != nil {
return false, nextAttempt, err

View File

@@ -89,7 +89,7 @@ func (m *FakeNodeHandler) Get(name string) (*api.Node, error) {
return nil, nil
}
func (m *FakeNodeHandler) List(opts unversioned.ListOptions) (*api.NodeList, error) {
func (m *FakeNodeHandler) List(opts api.ListOptions) (*api.NodeList, error) {
defer func() { m.RequestCount++ }()
var nodes []*api.Node
for i := 0; i < len(m.UpdatedNodes); i++ {
@@ -134,7 +134,7 @@ func (m *FakeNodeHandler) UpdateStatus(node *api.Node) (*api.Node, error) {
return node, nil
}
func (m *FakeNodeHandler) Watch(opts unversioned.ListOptions) (watch.Interface, error) {
func (m *FakeNodeHandler) Watch(opts api.ListOptions) (watch.Interface, error) {
return nil, nil
}

View File

@@ -23,7 +23,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/cache"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/controller/framework"
@@ -55,10 +54,10 @@ func NewPersistentVolumeClaimBinder(kubeClient client.Interface, syncPeriod time
_, volumeController := framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return kubeClient.PersistentVolumes().List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return kubeClient.PersistentVolumes().Watch(options)
},
},
@@ -73,10 +72,10 @@ func NewPersistentVolumeClaimBinder(kubeClient client.Interface, syncPeriod time
)
_, claimController := framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return kubeClient.PersistentVolumeClaims(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return kubeClient.PersistentVolumeClaims(api.NamespaceAll).Watch(options)
},
},

View File

@@ -22,7 +22,6 @@ import (
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/cache"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/cloudprovider"
@@ -74,10 +73,10 @@ func NewPersistentVolumeProvisionerController(client controllerClient, syncPerio
controller.volumeStore, controller.volumeController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return client.ListPersistentVolumes(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return client.WatchPersistentVolumes(options)
},
},
@@ -92,10 +91,10 @@ func NewPersistentVolumeProvisionerController(client controllerClient, syncPerio
)
controller.claimStore, controller.claimController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return client.ListPersistentVolumeClaims(api.NamespaceAll, options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return client.WatchPersistentVolumeClaims(api.NamespaceAll, options)
},
},
@@ -345,16 +344,16 @@ func newProvisioner(plugin volume.ProvisionableVolumePlugin, claim *api.Persiste
// controllerClient abstracts access to PVs and PVCs. Easy to mock for testing and wrap for real client.
type controllerClient interface {
CreatePersistentVolume(pv *api.PersistentVolume) (*api.PersistentVolume, error)
ListPersistentVolumes(options unversioned.ListOptions) (*api.PersistentVolumeList, error)
WatchPersistentVolumes(options unversioned.ListOptions) (watch.Interface, error)
ListPersistentVolumes(options api.ListOptions) (*api.PersistentVolumeList, error)
WatchPersistentVolumes(options api.ListOptions) (watch.Interface, error)
GetPersistentVolume(name string) (*api.PersistentVolume, error)
UpdatePersistentVolume(volume *api.PersistentVolume) (*api.PersistentVolume, error)
DeletePersistentVolume(volume *api.PersistentVolume) error
UpdatePersistentVolumeStatus(volume *api.PersistentVolume) (*api.PersistentVolume, error)
GetPersistentVolumeClaim(namespace, name string) (*api.PersistentVolumeClaim, error)
ListPersistentVolumeClaims(namespace string, options unversioned.ListOptions) (*api.PersistentVolumeClaimList, error)
WatchPersistentVolumeClaims(namespace string, options unversioned.ListOptions) (watch.Interface, error)
ListPersistentVolumeClaims(namespace string, options api.ListOptions) (*api.PersistentVolumeClaimList, error)
WatchPersistentVolumeClaims(namespace string, options api.ListOptions) (watch.Interface, error)
UpdatePersistentVolumeClaim(claim *api.PersistentVolumeClaim) (*api.PersistentVolumeClaim, error)
UpdatePersistentVolumeClaimStatus(claim *api.PersistentVolumeClaim) (*api.PersistentVolumeClaim, error)
@@ -376,11 +375,11 @@ func (c *realControllerClient) GetPersistentVolume(name string) (*api.Persistent
return c.client.PersistentVolumes().Get(name)
}
func (c *realControllerClient) ListPersistentVolumes(options unversioned.ListOptions) (*api.PersistentVolumeList, error) {
func (c *realControllerClient) ListPersistentVolumes(options api.ListOptions) (*api.PersistentVolumeList, error) {
return c.client.PersistentVolumes().List(options)
}
func (c *realControllerClient) WatchPersistentVolumes(options unversioned.ListOptions) (watch.Interface, error) {
func (c *realControllerClient) WatchPersistentVolumes(options api.ListOptions) (watch.Interface, error) {
return c.client.PersistentVolumes().Watch(options)
}
@@ -404,11 +403,11 @@ func (c *realControllerClient) GetPersistentVolumeClaim(namespace, name string)
return c.client.PersistentVolumeClaims(namespace).Get(name)
}
func (c *realControllerClient) ListPersistentVolumeClaims(namespace string, options unversioned.ListOptions) (*api.PersistentVolumeClaimList, error) {
func (c *realControllerClient) ListPersistentVolumeClaims(namespace string, options api.ListOptions) (*api.PersistentVolumeClaimList, error) {
return c.client.PersistentVolumeClaims(namespace).List(options)
}
func (c *realControllerClient) WatchPersistentVolumeClaims(namespace string, options unversioned.ListOptions) (watch.Interface, error) {
func (c *realControllerClient) WatchPersistentVolumeClaims(namespace string, options api.ListOptions) (watch.Interface, error) {
return c.client.PersistentVolumeClaims(namespace).Watch(options)
}

View File

@@ -25,7 +25,6 @@ import (
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
client "k8s.io/kubernetes/pkg/client/unversioned"
fake_cloud "k8s.io/kubernetes/pkg/cloudprovider/providers/fake"
"k8s.io/kubernetes/pkg/util"
@@ -185,13 +184,13 @@ func (c *mockControllerClient) CreatePersistentVolume(pv *api.PersistentVolume)
return c.volume, nil
}
func (c *mockControllerClient) ListPersistentVolumes(options unversioned.ListOptions) (*api.PersistentVolumeList, error) {
func (c *mockControllerClient) ListPersistentVolumes(options api.ListOptions) (*api.PersistentVolumeList, error) {
return &api.PersistentVolumeList{
Items: []api.PersistentVolume{*c.volume},
}, nil
}
func (c *mockControllerClient) WatchPersistentVolumes(options unversioned.ListOptions) (watch.Interface, error) {
func (c *mockControllerClient) WatchPersistentVolumes(options api.ListOptions) (watch.Interface, error) {
return watch.NewFake(), nil
}
@@ -216,13 +215,13 @@ func (c *mockControllerClient) GetPersistentVolumeClaim(namespace, name string)
}
}
func (c *mockControllerClient) ListPersistentVolumeClaims(namespace string, options unversioned.ListOptions) (*api.PersistentVolumeClaimList, error) {
func (c *mockControllerClient) ListPersistentVolumeClaims(namespace string, options api.ListOptions) (*api.PersistentVolumeClaimList, error) {
return &api.PersistentVolumeClaimList{
Items: []api.PersistentVolumeClaim{*c.claim},
}, nil
}
func (c *mockControllerClient) WatchPersistentVolumeClaims(namespace string, options unversioned.ListOptions) (watch.Interface, error) {
func (c *mockControllerClient) WatchPersistentVolumeClaims(namespace string, options api.ListOptions) (watch.Interface, error) {
return watch.NewFake(), nil
}

View File

@@ -22,7 +22,6 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/cache"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/cloudprovider"
@@ -64,10 +63,10 @@ func NewPersistentVolumeRecycler(kubeClient client.Interface, syncPeriod time.Du
_, volumeController := framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return kubeClient.PersistentVolumes().List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return kubeClient.PersistentVolumes().Watch(options)
},
},

View File

@@ -173,7 +173,7 @@ func (a *HorizontalController) reconcileAutoscaler(hpa extensions.HorizontalPodA
func (a *HorizontalController) reconcileAutoscalers() error {
ns := api.NamespaceAll
list, err := a.client.Extensions().HorizontalPodAutoscalers(ns).List(unversioned.ListOptions{})
list, err := a.client.Extensions().HorizontalPodAutoscalers(ns).List(api.ListOptions{})
if err != nil {
return fmt.Errorf("error listing nodes: %v", err)
}

View File

@@ -25,7 +25,6 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/unversioned"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/labels"
@@ -120,7 +119,7 @@ func (h *HeapsterMetricsClient) GetCPUUtilization(namespace string, selector map
func (h *HeapsterMetricsClient) GetResourceConsumptionAndRequest(resourceName api.ResourceName, namespace string, selector map[string]string) (consumption *ResourceConsumption, request *resource.Quantity, timestamp time.Time, err error) {
labelSelector := labels.SelectorFromSet(labels.Set(selector))
podList, err := h.client.Pods(namespace).
List(unversioned.ListOptions{LabelSelector: unversioned.LabelSelector{labelSelector}})
List(api.ListOptions{LabelSelector: labelSelector})
if err != nil {
return nil, nil, time.Time{}, fmt.Errorf("failed to get pod list: %v", err)

View File

@@ -24,7 +24,6 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/record"
client "k8s.io/kubernetes/pkg/client/unversioned"
@@ -107,10 +106,10 @@ func NewReplicationManager(kubeClient client.Interface, resyncPeriod controller.
rm.rcStore.Store, rm.rcController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return rm.kubeClient.ReplicationControllers(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return rm.kubeClient.ReplicationControllers(api.NamespaceAll).Watch(options)
},
},
@@ -148,10 +147,10 @@ func NewReplicationManager(kubeClient client.Interface, resyncPeriod controller.
rm.podStore.Store, rm.podController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return rm.kubeClient.Pods(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return rm.kubeClient.Pods(api.NamespaceAll).Watch(options)
},
},

View File

@@ -23,7 +23,6 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/cache"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/controller"
@@ -65,10 +64,10 @@ func NewResourceQuotaController(kubeClient client.Interface, resyncPeriod contro
rq.rqIndexer, rq.rqController = framework.NewIndexerInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return rq.kubeClient.ResourceQuotas(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return rq.kubeClient.ResourceQuotas(api.NamespaceAll).Watch(options)
},
},
@@ -105,10 +104,10 @@ func NewResourceQuotaController(kubeClient client.Interface, resyncPeriod contro
// release compute resources from any associated quota.
rq.podStore.Store, rq.podController = framework.NewInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return rq.kubeClient.Pods(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return rq.kubeClient.Pods(api.NamespaceAll).Watch(options)
},
},
@@ -265,7 +264,7 @@ func (rq *ResourceQuotaController) syncResourceQuota(quota api.ResourceQuota) (e
pods := &api.PodList{}
if set[api.ResourcePods] || set[api.ResourceMemory] || set[api.ResourceCPU] {
pods, err = rq.kubeClient.Pods(usage.Namespace).List(unversioned.ListOptions{})
pods, err = rq.kubeClient.Pods(usage.Namespace).List(api.ListOptions{})
if err != nil {
return err
}
@@ -288,31 +287,31 @@ func (rq *ResourceQuotaController) syncResourceQuota(quota api.ResourceQuota) (e
case api.ResourcePods:
value = resource.NewQuantity(int64(len(filteredPods)), resource.DecimalSI)
case api.ResourceServices:
items, err := rq.kubeClient.Services(usage.Namespace).List(unversioned.ListOptions{})
items, err := rq.kubeClient.Services(usage.Namespace).List(api.ListOptions{})
if err != nil {
return err
}
value = resource.NewQuantity(int64(len(items.Items)), resource.DecimalSI)
case api.ResourceReplicationControllers:
items, err := rq.kubeClient.ReplicationControllers(usage.Namespace).List(unversioned.ListOptions{})
items, err := rq.kubeClient.ReplicationControllers(usage.Namespace).List(api.ListOptions{})
if err != nil {
return err
}
value = resource.NewQuantity(int64(len(items.Items)), resource.DecimalSI)
case api.ResourceQuotas:
items, err := rq.kubeClient.ResourceQuotas(usage.Namespace).List(unversioned.ListOptions{})
items, err := rq.kubeClient.ResourceQuotas(usage.Namespace).List(api.ListOptions{})
if err != nil {
return err
}
value = resource.NewQuantity(int64(len(items.Items)), resource.DecimalSI)
case api.ResourceSecrets:
items, err := rq.kubeClient.Secrets(usage.Namespace).List(unversioned.ListOptions{})
items, err := rq.kubeClient.Secrets(usage.Namespace).List(api.ListOptions{})
if err != nil {
return err
}
value = resource.NewQuantity(int64(len(items.Items)), resource.DecimalSI)
case api.ResourcePersistentVolumeClaims:
items, err := rq.kubeClient.PersistentVolumeClaims(usage.Namespace).List(unversioned.ListOptions{})
items, err := rq.kubeClient.PersistentVolumeClaims(usage.Namespace).List(api.ListOptions{})
if err != nil {
return err
}

View File

@@ -23,7 +23,6 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/cloudprovider"
"k8s.io/kubernetes/pkg/util"
@@ -60,7 +59,7 @@ func (rc *RouteController) reconcileNodeRoutes() error {
}
// TODO (cjcullen): use pkg/controller/framework.NewInformer to watch this
// and reduce the number of lists needed.
nodeList, err := rc.kubeClient.Nodes().List(unversioned.ListOptions{})
nodeList, err := rc.kubeClient.Nodes().List(api.ListOptions{})
if err != nil {
return fmt.Errorf("error listing nodes: %v", err)
}

View File

@@ -24,7 +24,6 @@ import (
"k8s.io/kubernetes/pkg/api"
apierrs "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/cache"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/controller/framework"
@@ -80,12 +79,12 @@ func NewServiceAccountsController(cl client.Interface, options ServiceAccountsCo
}
e.serviceAccounts, e.serviceAccountController = framework.NewIndexerInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
options.FieldSelector.Selector = accountSelector
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
options.FieldSelector = accountSelector
return e.client.ServiceAccounts(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
options.FieldSelector.Selector = accountSelector
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
options.FieldSelector = accountSelector
return e.client.ServiceAccounts(api.NamespaceAll).Watch(options)
},
},
@@ -99,10 +98,10 @@ func NewServiceAccountsController(cl client.Interface, options ServiceAccountsCo
e.namespaces, e.namespaceController = framework.NewIndexerInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return e.client.Namespaces().List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return e.client.Namespaces().Watch(options)
},
},

View File

@@ -24,7 +24,6 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
apierrors "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/cache"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/controller/framework"
@@ -62,10 +61,10 @@ func NewTokensController(cl client.Interface, options TokensControllerOptions) *
e.serviceAccounts, e.serviceAccountController = framework.NewIndexerInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return e.client.ServiceAccounts(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return e.client.ServiceAccounts(api.NamespaceAll).Watch(options)
},
},
@@ -82,12 +81,12 @@ func NewTokensController(cl client.Interface, options TokensControllerOptions) *
tokenSelector := fields.SelectorFromSet(map[string]string{client.SecretType: string(api.SecretTypeServiceAccountToken)})
e.secrets, e.secretController = framework.NewIndexerInformer(
&cache.ListWatch{
ListFunc: func(options unversioned.ListOptions) (runtime.Object, error) {
options.FieldSelector.Selector = tokenSelector
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
options.FieldSelector = tokenSelector
return e.client.Secrets(api.NamespaceAll).List(options)
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
options.FieldSelector.Selector = tokenSelector
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
options.FieldSelector = tokenSelector
return e.client.Secrets(api.NamespaceAll).Watch(options)
},
},