Skip to content

Commit

Permalink
Moved constants to remove cyclic dependency.
Browse files Browse the repository at this point in the history
translator imports loadbalancer which imports firewalls,
which again depends on translator. Removed the translator
-> loadbalancer dependency.
  • Loading branch information
prameshj committed Jan 17, 2020
1 parent 15326f4 commit d37b8e0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
24 changes: 19 additions & 5 deletions pkg/controller/translator/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,20 @@ import (
"k8s.io/ingress-gce/pkg/backendconfig"
"k8s.io/ingress-gce/pkg/context"
"k8s.io/ingress-gce/pkg/controller/errors"
"k8s.io/ingress-gce/pkg/loadbalancers"
"k8s.io/ingress-gce/pkg/utils"
namer_util "k8s.io/ingress-gce/pkg/utils/namer"
)

const (
// DefaultHost is the host used if none is specified. It is a valid value
// for the "Host" field recognized by GCE.
DefaultHost = "*"

// DefaultPath is the path used if none is specified. It is a valid path
// recognized by GCE.
DefaultPath = "/*"
)

// getServicePortParams allows for passing parameters to getServicePort()
type getServicePortParams struct {
isL7ILB bool
Expand Down Expand Up @@ -206,14 +215,14 @@ func (t *Translator) TranslateIngress(ing *v1beta1.Ingress, systemDefaultBackend
// sent to one of the last backend in the rules list.
path := p.Path
if path == "" {
path = loadbalancers.DefaultPath
path = DefaultPath
}
pathRules = append(pathRules, utils.PathRule{Path: path, Backend: *svcPort})
}
}
host := rule.Host
if host == "" {
host = loadbalancers.DefaultHost
host = DefaultHost
}
urlMap.PutPathRulesForHost(host, pathRules)
}
Expand Down Expand Up @@ -266,16 +275,21 @@ func (t *Translator) GetZoneForNode(name string) (string, error) {

// ListZones returns a list of zones this Kubernetes cluster spans.
func (t *Translator) ListZones() ([]string, error) {
zones := sets.String{}
nodeLister := t.ctx.NodeInformer.GetIndexer()
readyNodes, err := listers.NewNodeLister(nodeLister).ListWithPredicate(utils.GetNodeConditionPredicate())
return t.ListZonesWithLister(listers.NewNodeLister(nodeLister))
}

func (t *Translator) ListZonesWithLister(lister listers.NodeLister) ([]string, error) {
zones := sets.String{}
readyNodes, err := lister.ListWithPredicate(utils.GetNodeConditionPredicate())
if err != nil {
return zones.List(), err
}
for _, n := range readyNodes {
zones.Insert(getZone(n))
}
return zones.List(), nil

}

// geHTTPProbe returns the http readiness probe from the first container
Expand Down
8 changes: 0 additions & 8 deletions pkg/loadbalancers/l7.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ import (
)

const (
// DefaultHost is the host used if none is specified. It is a valid value
// for the "Host" field recognized by GCE.
DefaultHost = "*"

// DefaultPath is the path used if none is specified. It is a valid path
// recognized by GCE.
DefaultPath = "/*"

invalidConfigErrorMessage = "invalid ingress frontend configuration, please check your usage of the 'kubernetes.io/ingress.allow-http' annotation."
)

Expand Down

0 comments on commit d37b8e0

Please sign in to comment.