K8s remove string ops (#2119)
* plugin/kubernetes: remove bunch a string ops This removes a bunch of appends to where not needed, makes dnsutil.Join take variadic args which removes the need to wrap in a new string slice. Signed-off-by: Miek Gieben <miek@miek.nl> * Fix calls to dnsutil.Join Signed-off-by: Miek Gieben <miek@miek.nl> * Revert these Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
parent
b3d69f1c7f
commit
9546b606cb
11 changed files with 31 additions and 44 deletions
|
@ -72,7 +72,7 @@ type dnsControl struct {
|
|||
svcLister cache.Indexer
|
||||
podLister cache.Indexer
|
||||
epLister cache.Indexer
|
||||
nsLister storeToNamespaceLister
|
||||
nsLister cache.Store
|
||||
|
||||
// stopLock is used to enforce only a single call to Stop is active.
|
||||
// Needed because we allow stopping through an http endpoint and
|
||||
|
@ -146,7 +146,7 @@ func newdnsController(kubeClient *kubernetes.Clientset, opts dnsControlOpts) *dn
|
|||
cache.Indexers{epNameNamespaceIndex: epNameNamespaceIndexFunc, epIPIndex: epIPIndexFunc})
|
||||
}
|
||||
|
||||
dns.nsLister.Store, dns.nsController = cache.NewInformer(
|
||||
dns.nsLister, dns.nsController = cache.NewInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: namespaceListFunc(dns.client, dns.selector),
|
||||
WatchFunc: namespaceWatchFunc(dns.client, dns.selector),
|
||||
|
@ -156,11 +156,6 @@ func newdnsController(kubeClient *kubernetes.Clientset, opts dnsControlOpts) *dn
|
|||
return &dns
|
||||
}
|
||||
|
||||
// storeToNamespaceLister makes a Store that lists Namespaces.
|
||||
type storeToNamespaceLister struct {
|
||||
cache.Store
|
||||
}
|
||||
|
||||
func podIPIndexFunc(obj interface{}) ([]string, error) {
|
||||
p, ok := obj.(*api.Pod)
|
||||
if !ok {
|
||||
|
@ -311,9 +306,8 @@ func namespaceWatchFunc(c *kubernetes.Clientset, s labels.Selector) func(options
|
|||
}
|
||||
}
|
||||
|
||||
func (dns *dnsControl) SetWatchChan(c dnswatch.Chan) {
|
||||
dns.watchChan = c
|
||||
}
|
||||
func (dns *dnsControl) SetWatchChan(c dnswatch.Chan) { dns.watchChan = c }
|
||||
func (dns *dnsControl) StopWatching(qname string) { delete(dns.watched, qname) }
|
||||
|
||||
func (dns *dnsControl) Watch(qname string) error {
|
||||
if dns.watchChan == nil {
|
||||
|
@ -323,10 +317,6 @@ func (dns *dnsControl) Watch(qname string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (dns *dnsControl) StopWatching(qname string) {
|
||||
delete(dns.watched, qname)
|
||||
}
|
||||
|
||||
// Stop stops the controller.
|
||||
func (dns *dnsControl) Stop() error {
|
||||
dns.stopLock.Lock()
|
||||
|
@ -621,15 +611,9 @@ func (dns *dnsControl) sendUpdates(oldObj, newObj interface{}) {
|
|||
}
|
||||
}
|
||||
|
||||
func (dns *dnsControl) Add(obj interface{}) {
|
||||
dns.sendUpdates(nil, obj)
|
||||
}
|
||||
func (dns *dnsControl) Delete(obj interface{}) {
|
||||
dns.sendUpdates(obj, nil)
|
||||
}
|
||||
func (dns *dnsControl) Update(oldObj, newObj interface{}) {
|
||||
dns.sendUpdates(oldObj, newObj)
|
||||
}
|
||||
func (dns *dnsControl) Add(obj interface{}) { dns.sendUpdates(nil, obj) }
|
||||
func (dns *dnsControl) Delete(obj interface{}) { dns.sendUpdates(obj, nil) }
|
||||
func (dns *dnsControl) Update(oldObj, newObj interface{}) { dns.sendUpdates(oldObj, newObj) }
|
||||
|
||||
// subsetsEquivalent checks if two endpoint subsets are significantly equivalent
|
||||
// I.e. that they have the same ready addresses, host names, ports (including protocol
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue