Refactor mirror feature
This commit is contained in:
parent
b9e944a8a6
commit
b3146354d4
14 changed files with 178 additions and 128 deletions
|
|
@ -180,6 +180,7 @@ var (
|
|||
"buildOpentracingForLocation": buildOpentracingForLocation,
|
||||
"shouldLoadOpentracingModule": shouldLoadOpentracingModule,
|
||||
"buildModSecurityForLocation": buildModSecurityForLocation,
|
||||
"buildMirrorLocations": buildMirrorLocations,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -1377,3 +1378,29 @@ modsecurity_rules_file /etc/nginx/modsecurity/modsecurity.conf;
|
|||
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
func buildMirrorLocations(locs []*ingress.Location) string {
|
||||
var buffer bytes.Buffer
|
||||
|
||||
mapped := sets.String{}
|
||||
|
||||
for _, loc := range locs {
|
||||
if loc.Mirror.Source == "" || loc.Mirror.Target == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
if mapped.Has(loc.Mirror.Source) {
|
||||
continue
|
||||
}
|
||||
|
||||
mapped.Insert(loc.Mirror.Source)
|
||||
buffer.WriteString(fmt.Sprintf(`location = %v {
|
||||
internal;
|
||||
proxy_pass %v;
|
||||
}
|
||||
|
||||
`, loc.Mirror.Source, loc.Mirror.Target))
|
||||
}
|
||||
|
||||
return buffer.String()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue