Skip to content

Commit

Permalink
style(parser): replace a C-style for with a range
Browse files Browse the repository at this point in the history
  • Loading branch information
mflendrich committed Sep 11, 2020
1 parent aaae35c commit 285c7cb
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions internal/ingress/controller/parser/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@ func fromIngressV1beta1(log logrus.FieldLogger, ingressList []*networkingv1beta1
&ingressList[j].CreationTimestamp)
})

for i := 0; i < len(ingressList); i++ {
ingress := *ingressList[i]
for _, ingress := range ingressList {
ingressSpec := ingress.Spec
log = log.WithFields(logrus.Fields{
"ingress_namespace": ingress.Namespace,
"ingress_name": ingress.Name,
})

if ingressSpec.Backend != nil {
allDefaultBackends = append(allDefaultBackends, ingress)

allDefaultBackends = append(allDefaultBackends, *ingress)
}

result.SecretNameToSNIs.addFromIngressV1beta1TLS(ingressSpec.TLS, ingress.Namespace)
Expand All @@ -57,7 +55,7 @@ func fromIngressV1beta1(log logrus.FieldLogger, ingressList []*networkingv1beta1
path = "/"
}
r := kongstate.Route{
Ingress: util.FromK8sObject(&ingress),
Ingress: util.FromK8sObject(ingress),
Route: kong.Route{
// TODO (#834) Figure out a way to name the routes
// This is not a stable scheme
Expand Down Expand Up @@ -171,16 +169,15 @@ func fromIngressV1(log logrus.FieldLogger, ingressList []*networkingv1.Ingress)
&ingressList[j].CreationTimestamp)
})

for i := 0; i < len(ingressList); i++ {
ingress := *ingressList[i]
for _, ingress := range ingressList {
ingressSpec := ingress.Spec
log = log.WithFields(logrus.Fields{
"ingress_namespace": ingress.Namespace,
"ingress_name": ingress.Name,
})

if ingressSpec.DefaultBackend != nil {
allDefaultBackends = append(allDefaultBackends, ingress)
allDefaultBackends = append(allDefaultBackends, *ingress)
}

result.SecretNameToSNIs.addFromIngressV1TLS(ingressSpec.TLS, ingress.Namespace)
Expand All @@ -201,7 +198,7 @@ func fromIngressV1(log logrus.FieldLogger, ingressList []*networkingv1.Ingress)
}

r := kongstate.Route{
Ingress: util.FromK8sObject(&ingress),
Ingress: util.FromK8sObject(ingress),
Route: kong.Route{
// TODO (#834) Figure out a way to name the routes
// This is not a stable scheme
Expand Down Expand Up @@ -310,8 +307,7 @@ func fromTCPIngressV1beta1(log logrus.FieldLogger, tcpIngressList []*configurati
&tcpIngressList[j].CreationTimestamp)
})

for i := 0; i < len(tcpIngressList); i++ {
ingress := *tcpIngressList[i]
for _, ingress := range tcpIngressList {
ingressSpec := ingress.Spec

log = log.WithFields(logrus.Fields{
Expand All @@ -328,7 +324,7 @@ func fromTCPIngressV1beta1(log logrus.FieldLogger, tcpIngressList []*configurati
continue
}
r := kongstate.Route{
Ingress: util.FromK8sObject(&ingress),
Ingress: util.FromK8sObject(ingress),
Route: kong.Route{
// TODO (#834) Figure out a way to name the routes
// This is not a stable scheme
Expand Down Expand Up @@ -400,8 +396,7 @@ func fromKnativeIngress(ingressList []*knative.Ingress) ingressRules {
services := map[string]kongstate.Service{}
secretToSNIs := newSecretNameToSNIs()

for i := 0; i < len(ingressList); i++ {
ingress := *ingressList[i]
for _, ingress := range ingressList {
ingressSpec := ingress.Spec

secretToSNIs.addFromIngressV1beta1TLS(knativeIngressToNetworkingTLS(ingress.Spec.TLS), ingress.Namespace)
Expand Down

0 comments on commit 285c7cb

Please sign in to comment.