mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 04:52:08 +00:00
Make listing deployment rcStore namespaced
This commit is contained in:
parent
1e68e719c3
commit
14f4f1b065
19
pkg/client/cache/listers.go
vendored
19
pkg/client/cache/listers.go
vendored
@ -161,6 +161,25 @@ func (s *StoreToReplicationControllerLister) List() (controllers []api.Replicati
|
|||||||
return controllers, nil
|
return controllers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *StoreToReplicationControllerLister) ReplicationControllers(namespace string) storeReplicationControllersNamespacer {
|
||||||
|
return storeReplicationControllersNamespacer{s.Store, namespace}
|
||||||
|
}
|
||||||
|
|
||||||
|
type storeReplicationControllersNamespacer struct {
|
||||||
|
store Store
|
||||||
|
namespace string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s storeReplicationControllersNamespacer) List() (controllers []api.ReplicationController, err error) {
|
||||||
|
for _, c := range s.store.List() {
|
||||||
|
rc := *(c.(*api.ReplicationController))
|
||||||
|
if s.namespace == api.NamespaceAll || s.namespace == rc.Namespace {
|
||||||
|
controllers = append(controllers, rc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// GetPodControllers returns a list of replication controllers managing a pod. Returns an error only if no matching controllers are found.
|
// GetPodControllers returns a list of replication controllers managing a pod. Returns an error only if no matching controllers are found.
|
||||||
func (s *StoreToReplicationControllerLister) GetPodControllers(pod *api.Pod) (controllers []api.ReplicationController, err error) {
|
func (s *StoreToReplicationControllerLister) GetPodControllers(pod *api.Pod) (controllers []api.ReplicationController, err error) {
|
||||||
var selector labels.Selector
|
var selector labels.Selector
|
||||||
|
@ -514,7 +514,7 @@ func (dc *DeploymentController) getOldRCs(deployment extensions.Deployment) ([]*
|
|||||||
return &podList, err
|
return &podList, err
|
||||||
},
|
},
|
||||||
func(namespace string, options api.ListOptions) ([]api.ReplicationController, error) {
|
func(namespace string, options api.ListOptions) ([]api.ReplicationController, error) {
|
||||||
return dc.rcStore.List()
|
return dc.rcStore.ReplicationControllers(namespace).List()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,7 +523,7 @@ func (dc *DeploymentController) getOldRCs(deployment extensions.Deployment) ([]*
|
|||||||
func (dc *DeploymentController) getNewRC(deployment extensions.Deployment) (*api.ReplicationController, error) {
|
func (dc *DeploymentController) getNewRC(deployment extensions.Deployment) (*api.ReplicationController, error) {
|
||||||
existingNewRC, err := deploymentutil.GetNewRCFromList(deployment, dc.client,
|
existingNewRC, err := deploymentutil.GetNewRCFromList(deployment, dc.client,
|
||||||
func(namespace string, options api.ListOptions) ([]api.ReplicationController, error) {
|
func(namespace string, options api.ListOptions) ([]api.ReplicationController, error) {
|
||||||
return dc.rcStore.List()
|
return dc.rcStore.ReplicationControllers(namespace).List()
|
||||||
})
|
})
|
||||||
if err != nil || existingNewRC != nil {
|
if err != nil || existingNewRC != nil {
|
||||||
return existingNewRC, err
|
return existingNewRC, err
|
||||||
|
Loading…
Reference in New Issue
Block a user