Skip to content

Commit 055a7d0

Browse files
authored
Merge pull request #573 from application-stacks/edge
Allow insecureEdgeTerminationPolicy to be set independently
2 parents 3ea3c11 + 0ac2c04 commit 055a7d0

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

utils/utils.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,31 +133,19 @@ func CustomizeRoute(route *routev1.Route, ba common.BaseComponent, key string, c
133133
route.Spec.TLS.CACertificate = ca
134134
route.Spec.TLS.Key = key
135135
route.Spec.TLS.DestinationCACertificate = destCACert
136-
if rt.GetInsecureEdgeTerminationPolicy() != nil {
137-
route.Spec.TLS.InsecureEdgeTerminationPolicy = *rt.GetInsecureEdgeTerminationPolicy()
138-
}
139136
} else if route.Spec.TLS.Termination == routev1.TLSTerminationPassthrough {
140137
route.Spec.TLS.Certificate = ""
141138
route.Spec.TLS.CACertificate = ""
142139
route.Spec.TLS.Key = ""
143140
route.Spec.TLS.DestinationCACertificate = ""
144-
if rt.GetInsecureEdgeTerminationPolicy() != nil {
145-
route.Spec.TLS.InsecureEdgeTerminationPolicy = *rt.GetInsecureEdgeTerminationPolicy()
146-
}
147141
} else if route.Spec.TLS.Termination == routev1.TLSTerminationEdge {
148142
route.Spec.TLS.Certificate = crt
149143
route.Spec.TLS.CACertificate = ca
150144
route.Spec.TLS.Key = key
151145
route.Spec.TLS.DestinationCACertificate = ""
152-
if rt.GetInsecureEdgeTerminationPolicy() != nil {
153-
route.Spec.TLS.InsecureEdgeTerminationPolicy = *rt.GetInsecureEdgeTerminationPolicy()
154-
}
155146
}
156147
}
157148
}
158-
if ba.GetRoute() == nil {
159-
route.Spec.Path = ""
160-
}
161149
if ba.GetRoute() == nil || ba.GetRoute().GetTermination() == nil {
162150
route.Spec.TLS = nil
163151
}
@@ -172,6 +160,18 @@ func CustomizeRoute(route *routev1.Route, ba common.BaseComponent, key string, c
172160
}
173161
}
174162

163+
// insecureEdgeTerminationPolicy can be set independently of the other TLS config
164+
// so route.Spec.TLS may be nil at this point.
165+
if rt := ba.GetRoute(); rt != nil && rt.GetInsecureEdgeTerminationPolicy() != nil {
166+
if route.Spec.TLS == nil {
167+
route.Spec.TLS = &routev1.TLSConfig{}
168+
}
169+
route.Spec.TLS.InsecureEdgeTerminationPolicy = *rt.GetInsecureEdgeTerminationPolicy()
170+
}
171+
172+
if ba.GetRoute() == nil {
173+
route.Spec.Path = ""
174+
}
175175
route.Spec.To.Kind = "Service"
176176
route.Spec.To.Name = obj.GetName()
177177
weight := int32(100)

0 commit comments

Comments
 (0)