Remove pointers to labels.Selector and pass normally instead (#1422)

This commit is contained in:
Ilya Galimyanov 2018-01-24 23:44:18 +03:00 committed by Miek Gieben
parent a0ad2ff0af
commit 1e75061aec
2 changed files with 15 additions and 15 deletions

View file

@ -46,7 +46,7 @@ type dnsController interface {
type dnsControl struct { type dnsControl struct {
client *kubernetes.Clientset client *kubernetes.Clientset
selector *labels.Selector selector labels.Selector
svcController cache.Controller svcController cache.Controller
podController cache.Controller podController cache.Controller
@ -69,7 +69,7 @@ type dnsControlOpts struct {
resyncPeriod time.Duration resyncPeriod time.Duration
// Label handling. // Label handling.
labelSelector *meta.LabelSelector labelSelector *meta.LabelSelector
selector *labels.Selector selector labels.Selector
} }
// newDNSController creates a controller for CoreDNS. // newDNSController creates a controller for CoreDNS.
@ -159,10 +159,10 @@ func epIPIndexFunc(obj interface{}) ([]string, error) {
return idx, nil return idx, nil
} }
func serviceListFunc(c *kubernetes.Clientset, ns string, s *labels.Selector) func(meta.ListOptions) (runtime.Object, error) { func serviceListFunc(c *kubernetes.Clientset, ns string, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) {
return func(opts meta.ListOptions) (runtime.Object, error) { return func(opts meta.ListOptions) (runtime.Object, error) {
if s != nil { if s != nil {
opts.LabelSelector = (*s).String() opts.LabelSelector = s.String()
} }
listV1, err := c.CoreV1().Services(ns).List(opts) listV1, err := c.CoreV1().Services(ns).List(opts)
if err != nil { if err != nil {
@ -172,10 +172,10 @@ func serviceListFunc(c *kubernetes.Clientset, ns string, s *labels.Selector) fun
} }
} }
func podListFunc(c *kubernetes.Clientset, ns string, s *labels.Selector) func(meta.ListOptions) (runtime.Object, error) { func podListFunc(c *kubernetes.Clientset, ns string, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) {
return func(opts meta.ListOptions) (runtime.Object, error) { return func(opts meta.ListOptions) (runtime.Object, error) {
if s != nil { if s != nil {
opts.LabelSelector = (*s).String() opts.LabelSelector = s.String()
} }
listV1, err := c.CoreV1().Pods(ns).List(opts) listV1, err := c.CoreV1().Pods(ns).List(opts)
if err != nil { if err != nil {
@ -185,10 +185,10 @@ func podListFunc(c *kubernetes.Clientset, ns string, s *labels.Selector) func(me
} }
} }
func serviceWatchFunc(c *kubernetes.Clientset, ns string, s *labels.Selector) func(options meta.ListOptions) (watch.Interface, error) { func serviceWatchFunc(c *kubernetes.Clientset, ns string, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) {
return func(options meta.ListOptions) (watch.Interface, error) { return func(options meta.ListOptions) (watch.Interface, error) {
if s != nil { if s != nil {
options.LabelSelector = (*s).String() options.LabelSelector = s.String()
} }
w, err := c.CoreV1().Services(ns).Watch(options) w, err := c.CoreV1().Services(ns).Watch(options)
if err != nil { if err != nil {
@ -198,10 +198,10 @@ func serviceWatchFunc(c *kubernetes.Clientset, ns string, s *labels.Selector) fu
} }
} }
func podWatchFunc(c *kubernetes.Clientset, ns string, s *labels.Selector) func(options meta.ListOptions) (watch.Interface, error) { func podWatchFunc(c *kubernetes.Clientset, ns string, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) {
return func(options meta.ListOptions) (watch.Interface, error) { return func(options meta.ListOptions) (watch.Interface, error) {
if s != nil { if s != nil {
options.LabelSelector = (*s).String() options.LabelSelector = s.String()
} }
w, err := c.CoreV1().Pods(ns).Watch(options) w, err := c.CoreV1().Pods(ns).Watch(options)
if err != nil { if err != nil {
@ -211,10 +211,10 @@ func podWatchFunc(c *kubernetes.Clientset, ns string, s *labels.Selector) func(o
} }
} }
func endpointsListFunc(c *kubernetes.Clientset, ns string, s *labels.Selector) func(meta.ListOptions) (runtime.Object, error) { func endpointsListFunc(c *kubernetes.Clientset, ns string, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) {
return func(opts meta.ListOptions) (runtime.Object, error) { return func(opts meta.ListOptions) (runtime.Object, error) {
if s != nil { if s != nil {
opts.LabelSelector = (*s).String() opts.LabelSelector = s.String()
} }
listV1, err := c.CoreV1().Endpoints(ns).List(opts) listV1, err := c.CoreV1().Endpoints(ns).List(opts)
if err != nil { if err != nil {
@ -224,10 +224,10 @@ func endpointsListFunc(c *kubernetes.Clientset, ns string, s *labels.Selector) f
} }
} }
func endpointsWatchFunc(c *kubernetes.Clientset, ns string, s *labels.Selector) func(options meta.ListOptions) (watch.Interface, error) { func endpointsWatchFunc(c *kubernetes.Clientset, ns string, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) {
return func(options meta.ListOptions) (watch.Interface, error) { return func(options meta.ListOptions) (watch.Interface, error) {
if s != nil { if s != nil {
options.LabelSelector = (*s).String() options.LabelSelector = s.String()
} }
w, err := c.CoreV1().Endpoints(ns).Watch(options) w, err := c.CoreV1().Endpoints(ns).Watch(options)
if err != nil { if err != nil {

View file

@ -256,7 +256,7 @@ func (k *Kubernetes) initKubeCache(opts dnsControlOpts) (err error) {
if err != nil { if err != nil {
return fmt.Errorf("unable to create Selector for LabelSelector '%s': %q", opts.labelSelector, err) return fmt.Errorf("unable to create Selector for LabelSelector '%s': %q", opts.labelSelector, err)
} }
opts.selector = &selector opts.selector = selector
} }
opts.initPodCache = k.podMode == podModeVerified opts.initPodCache = k.podMode == podModeVerified