Skip to content

Commit 92d125b

Browse files
f
1 parent 62792fb commit 92d125b

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

manifests/haproxy/autoload.pp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
replace => false,
3333
}
3434

35-
$http_edge_services.each | $service | {
35+
$http_edge_rules_all_placeholder = $http_edge_services.map | $service | {
3636
$http_edge_rules = flatten($http_edge_domains_envs.map |$domain, $options| {
3737
$match_type = pick($options['match_type'], 'str')
3838
$hdr_match = $match_type ? {
@@ -80,43 +80,47 @@
8080
}
8181
})
8282

83-
case $service {
84-
'redirects': { $http_edge_redirect_rules = $http_edge_rules }
85-
'nofollow': { $http_edge_nofollow_rules = $http_edge_rules }
86-
'status410': { $http_edge_status410_rules = $http_edge_rules }
87-
'canonicals': { $http_edge_canonicals_rules = $http_edge_rules }
88-
}
83+
#case $service {
84+
# 'redirects': { $http_edge_redirect_rules = $http_edge_rules }
85+
# 'nofollow': { $http_edge_nofollow_rules = $http_edge_rules }
86+
# 'status410': { $http_edge_status410_rules = $http_edge_rules }
87+
# 'canonicals': { $http_edge_canonicals_rules = $http_edge_rules }
88+
#}
89+
[$service, $http_edge_rules]
8990
}
9091

92+
$http_edge_rules_all = Hash($http_edge_rules_all_placeholder)
93+
$http_edge_rules_all_real = $http_edge_rules_all.filter |$key $value| { $value != "" }
94+
9195
if 'canonicals' in $http_edge_services {
92-
$http_edge_canonicals_rules_real = flatten($http_edge_canonicals_rules, 'set-var(txn.canonical_custom) hdr(X-Canonical-Custom) if { hdr(X-Canonical-Custom) -m found }', 'del-header X-Canonical-Custom if { hdr(X-Canonical-Custom) -m found }')
96+
$http_edge_canonicals_rules_real = flatten($http_edge_rules_all_real['canonicals'], 'set-var(txn.canonical_custom) hdr(X-Canonical-Custom) if { hdr(X-Canonical-Custom) -m found }', 'del-header X-Canonical-Custom if { hdr(X-Canonical-Custom) -m found }')
9397
$http_response_rules = $ducktape::haproxy::frontends[$http_edge_frontend]['options']['http-response']
9498
$http_response_rules_real = concat($http_response_rules, 'set-header link %[var(txn.canonical_custom)] if { var(txn.canonical_custom) -m found }')
9599
$http_response_rules_hash = {$http_edge_frontend => {'options' => {'http-response' => $http_response_rules_real}}}
96-
$frontends_real = deep_merge($ducktape::haproxy::frontends, $http_request_rules_hash)
100+
#$frontends_real = deep_merge($ducktape::haproxy::frontends, $http_request_rules_hash)
97101
}
98102

99103
# Insert http-edge redirect rules at the marker position, or at the end if no marker
100104
$http_request_rules = $ducktape::haproxy::frontends[$http_edge_frontend]['options']['http-request']
101105
if grep($http_request_rules, $http_edge_redirect_marker) == [] {
102-
$http_request_rules_with_redirects = concat($http_request_rules, $http_edge_redirect_rules)
106+
$http_request_rules_with_redirects = concat($http_request_rules, $http_edge_rules_all_real['redirects'])
103107
}
104108
else {
105-
$http_request_rules_with_redirects = split(regsubst(join($http_request_rules, "\n"), $http_edge_redirect_marker, join($http_edge_redirect_rules, "\n")), "\n")
109+
$http_request_rules_with_redirects = split(regsubst(join($http_request_rules, "\n"), $http_edge_redirect_marker, join($http_edge_rules_all_real['redirects'], "\n")), "\n")
106110
}
107111

108112
if grep($http_request_rules_with_redirects, $http_edge_status410_marker) == [] {
109-
$http_request_rules_with_status410 = concat($http_request_rules_with_redirects, $http_edge_status410_rules)
113+
$http_request_rules_with_status410 = concat($http_request_rules_with_redirects, $http_edge_rules_all_real['status410'])
110114
}
111115
else {
112-
$http_request_rules_with_status410 = split(regsubst(join($http_request_rules_with_redirects, "\n"), $http_edge_status410_marker, join($http_edge_status410_rules, "\n")), "\n")
116+
$http_request_rules_with_status410 = split(regsubst(join($http_request_rules_with_redirects, "\n"), $http_edge_status410_marker, join($http_edge_rules_all_real['status410'], "\n")), "\n")
113117
}
114118

115119
if grep($http_request_rules_with_status410, $http_edge_nofollow_marker) == [] {
116-
$http_request_rules_with_nofollow = concat($http_request_rules_with_status410, $http_edge_nofollow_rules)
120+
$http_request_rules_with_nofollow = concat($http_request_rules_with_status410, $http_edge_rules_all_real['nofollow'])
117121
}
118122
else {
119-
$http_request_rules_with_nofollow = split(regsubst(join($http_request_rules_with_status410, "\n"), $http_edge_nofollow_marker, join($http_edge_nofollow_rules, "\n")), "\n")
123+
$http_request_rules_with_nofollow = split(regsubst(join($http_request_rules_with_status410, "\n"), $http_edge_nofollow_marker, join($http_edge_rules_all_real['nofollow'], "\n")), "\n")
120124
}
121125

122126
if grep($http_request_rules_with_nofollow, $http_edge_canonical_marker) == [] {

0 commit comments

Comments
 (0)