Skip to content

Commit

Permalink
make translator public
Browse files Browse the repository at this point in the history
  • Loading branch information
freehan committed Oct 11, 2017
1 parent db8666f commit 7da4efe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type LoadBalancerController struct {
recorder record.EventRecorder
nodeQueue *taskQueue
ingQueue *taskQueue
tr *GCETranslator
Translator *GCETranslator
stopCh chan struct{}
// stopLock is used to enforce only a single call to Stop is active.
// Needed because we allow stopping through an http endpoint and
Expand Down Expand Up @@ -167,7 +167,7 @@ func NewLoadBalancerController(kubeClient kubernetes.Interface, ctx *context.Con
// Nodes are updated every 10s and we don't care, so no update handler.
})

lbc.tr = &GCETranslator{&lbc}
lbc.Translator = &GCETranslator{&lbc}
lbc.tlsLoader = &apiServerTLSLoader{client: lbc.client}
glog.V(3).Infof("Created new loadbalancer controller")

Expand Down Expand Up @@ -256,8 +256,8 @@ func (lbc *LoadBalancerController) sync(key string) (err error) {
return err
}

allNodePorts := lbc.tr.toNodePorts(&allIngresses)
gceNodePorts := lbc.tr.toNodePorts(&gceIngresses)
allNodePorts := lbc.Translator.toNodePorts(&allIngresses)
gceNodePorts := lbc.Translator.toNodePorts(&gceIngresses)
lbNames := lbc.ingLister.Store.ListKeys()
lbs, err := lbc.toRuntimeInfo(gceIngresses)
if err != nil {
Expand Down Expand Up @@ -339,7 +339,7 @@ func (lbc *LoadBalancerController) sync(key string) (err error) {
return syncError
}

if urlMap, err := lbc.tr.toURLMap(&ing); err != nil {
if urlMap, err := lbc.Translator.toURLMap(&ing); err != nil {
syncError = fmt.Errorf("%v, convert to url map error %v", syncError, err)
} else if err := l7.UpdateUrlMap(urlMap); err != nil {
lbc.recorder.Eventf(&ing, apiv1.EventTypeWarning, "UrlMap", err.Error())
Expand Down
10 changes: 5 additions & 5 deletions pkg/controller/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestZoneListing(t *testing.T) {
"zone-2": {"n2"},
}
addNodes(lbc, zoneToNode)
zones, err := lbc.tr.ListZones()
zones, err := lbc.Translator.ListZones()
if err != nil {
t.Errorf("Failed to list zones: %v", err)
}
Expand Down Expand Up @@ -99,7 +99,7 @@ func TestProbeGetter(t *testing.T) {
}
addPods(lbc, nodePortToHealthCheck, api_v1.NamespaceDefault)
for p, exp := range nodePortToHealthCheck {
got, err := lbc.tr.GetProbe(p)
got, err := lbc.Translator.GetProbe(p)
if err != nil || got == nil {
t.Errorf("Failed to get probe for node port %v: %v", p, err)
} else if getProbePath(got) != exp {
Expand All @@ -121,7 +121,7 @@ func TestProbeGetterNamedPort(t *testing.T) {
pod.Spec.Containers[0].ReadinessProbe.Handler.HTTPGet.Port = intstr.IntOrString{Type: intstr.String, StrVal: "test"}
}
for p, exp := range nodePortToHealthCheck {
got, err := lbc.tr.GetProbe(p)
got, err := lbc.Translator.GetProbe(p)
if err != nil || got == nil {
t.Errorf("Failed to get probe for node port %v: %v", p, err)
} else if getProbePath(got) != exp {
Expand Down Expand Up @@ -172,7 +172,7 @@ func TestProbeGetterCrossNamespace(t *testing.T) {
addPods(lbc, nodePortToHealthCheck, api_v1.NamespaceDefault)

for p, exp := range nodePortToHealthCheck {
got, err := lbc.tr.GetProbe(p)
got, err := lbc.Translator.GetProbe(p)
if err != nil || got == nil {
t.Errorf("Failed to get probe for node port %v: %v", p, err)
} else if getProbePath(got) != exp {
Expand Down Expand Up @@ -254,7 +254,7 @@ func addNodes(lbc *LoadBalancerController, zoneToNode map[string][]string) {
lbc.nodeLister.Indexer.Add(n)
}
}
lbc.CloudClusterManager.instancePool.Init(lbc.tr)
lbc.CloudClusterManager.instancePool.Init(lbc.Translator)
}

func getProbePath(p *api_v1.Probe) string {
Expand Down

0 comments on commit 7da4efe

Please sign in to comment.