@@ -1568,6 +1568,9 @@ func (appMgr *Manager) createRSConfigFromIngress(
15681568 }
15691569 cfg .MetaData .ingName = ing .ObjectMeta .Name
15701570
1571+ sslRedirect := getBooleanAnnotation (ing .ObjectMeta .Annotations ,
1572+ ingressSslRedirect , true )
1573+
15711574 resources .Lock ()
15721575 defer resources .Unlock ()
15731576 // Check to see if we already have any Ingresses for this IP:Port
@@ -1614,7 +1617,7 @@ func (appMgr *Manager) createRSConfigFromIngress(
16141617 }
16151618 }
16161619 } else if len (cfg .Policies ) == 0 && plcy != nil {
1617- cfg .SetPolicy (* plcy )
1620+ cfg .IngSetPolicy (* plcy , sslRedirect , pStruct . protocol )
16181621 }
16191622 } else { // This is a new VS for an Ingress
16201623 cfg .MetaData .ResourceType = "ingress"
@@ -1624,7 +1627,7 @@ func (appMgr *Manager) createRSConfigFromIngress(
16241627 cfg .Virtual .SetVirtualAddress (bindAddr , pStruct .port )
16251628 cfg .Pools = append (cfg .Pools , pools ... )
16261629 if plcy != nil {
1627- cfg .SetPolicy (* plcy )
1630+ cfg .IngSetPolicy (* plcy , sslRedirect , pStruct . protocol )
16281631 }
16291632 }
16301633
@@ -2204,6 +2207,36 @@ func (rc *ResourceConfig) SetPolicy(policy Policy) {
22042207 rc .Policies = append (rc .Policies , policy )
22052208}
22062209
2210+ func (rc * ResourceConfig ) IngSetPolicy (policy Policy , sslRedirect bool , pProtocol string ) {
2211+ toFind := nameRef {
2212+ Name : policy .Name ,
2213+ Partition : policy .Partition ,
2214+ }
2215+ found := false
2216+ for _ , polName := range rc .Virtual .Policies {
2217+ if reflect .DeepEqual (toFind , polName ) {
2218+ found = true
2219+ break
2220+ }
2221+ }
2222+ if ! found {
2223+ if sslRedirect {
2224+ if pProtocol == "https" {
2225+ rc .Virtual .Policies = append (rc .Virtual .Policies , toFind )
2226+ }
2227+ } else {
2228+ rc .Virtual .Policies = append (rc .Virtual .Policies , toFind )
2229+ }
2230+ }
2231+ for i , pol := range rc .Policies {
2232+ if pol .Name == policy .Name && pol .Partition == policy .Partition {
2233+ rc .Policies [i ] = policy
2234+ return
2235+ }
2236+ }
2237+ rc .Policies = append (rc .Policies , policy )
2238+ }
2239+
22072240func (rc * ResourceConfig ) RemovePolicy (policy Policy ) {
22082241 toFind := nameRef {
22092242 Name : policy .Name ,
0 commit comments