Skip to content

Commit

Permalink
typo
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaezon committed Jan 11, 2022
1 parent cce62de commit 59bffaf
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (
)

const (
defaultResyncPeriod = 0
ingressHostnameIndex = "ingressHostname"
serviceHostnameIndex = "serviceHostname"
virtualServiceHostnameIndex = "virtualServiceHostname"
hostnameAnnotationKey = "coredns.io/hostname"
defaultResyncPeriod = 0
ingressHostnameIndex = "ingressHostname"
serviceHostnameIndex = "serviceHostname"
virtualServerHostnameIndex = "virtualServerHostname"
hostnameAnnotationKey = "coredns.io/hostname"
)

// KubeController stores the current runtime configuration and cache
Expand Down Expand Up @@ -71,18 +71,18 @@ func newKubeController(ctx context.Context, c *kubernetes.Clientset) *KubeContro
ctrl.controllers = append(ctrl.controllers, serviceController)
}

if resource := lookupResource("VirtualService"); resource != nil {
virtualServiceController := cache.NewSharedIndexInformer(
if resource := lookupResource("VirtualServer"); resource != nil {
virtualServerController := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: virtualServiceLister(ctx, nginxV1Client, core.NamespaceAll),
WatchFunc: virtualServiceWatcher(ctx, nginxV1Client, core.NamespaceAll),
ListFunc: virtualServerLister(ctx, nginxV1Client, core.NamespaceAll),
WatchFunc: virtualServerWatcher(ctx, nginxV1Client, core.NamespaceAll),
},
&nginx_v1.VirtualServer{},
defaultResyncPeriod,
cache.Indexers{virtualServiceHostnameIndex: virtualServiceHostnameIndexFunc},
cache.Indexers{virtualServerHostnameIndex: virtualServerHostnameIndexFunc},
)
resource.lookup = lookupVirtualServiceIndex(virtualServiceController)
ctrl.controllers = append(ctrl.controllers, virtualServiceController)
resource.lookup = lookupVirtualServerIndex(virtualServerController)
ctrl.controllers = append(ctrl.controllers, virtualServerController)
}

return ctrl
Expand Down Expand Up @@ -160,7 +160,7 @@ func serviceLister(ctx context.Context, c kubernetes.Interface, ns string) func(
}
}

func virtualServiceLister(ctx context.Context, c k8s_nginx.Interface, ns string) func(meta.ListOptions) (runtime.Object, error) {
func virtualServerLister(ctx context.Context, c k8s_nginx.Interface, ns string) func(meta.ListOptions) (runtime.Object, error) {
return func(opts meta.ListOptions) (runtime.Object, error) {
return c.K8sV1().VirtualServers(ns).List(ctx, opts)
}
Expand All @@ -178,7 +178,7 @@ func serviceWatcher(ctx context.Context, c kubernetes.Interface, ns string) func
}
}

func virtualServiceWatcher(ctx context.Context, c k8s_nginx.Interface, ns string) func(meta.ListOptions) (watch.Interface, error) {
func virtualServerWatcher(ctx context.Context, c k8s_nginx.Interface, ns string) func(meta.ListOptions) (watch.Interface, error) {
return func(opts meta.ListOptions) (watch.Interface, error) {
return c.K8sV1().VirtualServers(ns).Watch(ctx, opts)
}
Expand Down Expand Up @@ -218,12 +218,14 @@ func serviceHostnameIndexFunc(obj interface{}) ([]string, error) {
return []string{hostname}, nil
}

func virtualServiceHostnameIndexFunc(obj interface{}) ([]string, error) {
func virtualServerHostnameIndexFunc(obj interface{}) ([]string, error) {
virtualServer, ok := obj.(*nginx_v1.VirtualServer)
if !ok {
return []string{}, nil
}

log.Debugf("Adding index %s for VirtualServer %s", virtualServer.Spec.Host, virtualServer.Name)

return []string{virtualServer.Spec.Host}, nil
}

Expand All @@ -244,14 +246,14 @@ func lookupServiceIndex(ctrl cache.SharedIndexInformer) func([]string) []net.IP
}
}

func lookupVirtualServiceIndex(ctrl cache.SharedIndexInformer) func([]string) []net.IP {
func lookupVirtualServerIndex(ctrl cache.SharedIndexInformer) func([]string) []net.IP {
return func(indexKeys []string) (result []net.IP) {
var objs []interface{}
for _, key := range indexKeys {
obj, _ := ctrl.GetIndexer().ByIndex(virtualServiceHostnameIndex, strings.ToLower(key))
obj, _ := ctrl.GetIndexer().ByIndex(virtualServerHostnameIndex, strings.ToLower(key))
objs = append(objs, obj...)
}
log.Debugf("Found %d matching VirtualService objects", len(objs))
log.Debugf("Found %d matching VirtualServer objects", len(objs))
for _, obj := range objs {
virtualServer, _ := obj.(*nginx_v1.VirtualServer)

Expand Down

0 comments on commit 59bffaf

Please sign in to comment.