Only set mirror source when a target is configured (#5055)

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-02-11 13:48:42 -03:00 committed by GitHub
parent 77586dd83b
commit 281139d1a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 2 deletions

View file

@ -82,6 +82,7 @@ func (a mirror) Parse(ing *networking.Ingress) (interface{}, error) {
config.Target, err = parser.GetStringAnnotation("mirror-target", ing)
if err != nil {
config.Target = ""
config.Source = ""
}
return config, nil

View file

@ -47,7 +47,7 @@ func TestParse(t *testing.T) {
Target: "https://test.env.com/$request_uri",
}},
{map[string]string{requestBody: "off"}, &Config{
Source: ngxURI,
Source: "",
RequestBody: "off",
Target: "",
}},

View file

@ -69,7 +69,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Mirror", func() {
It("should disable mirror-request-body", func() {
annotations := map[string]string{
"nginx.ingress.kubernetes.io/mirror-uri": "http://localhost/mirror",
"nginx.ingress.kubernetes.io/mirror-target": "http://localhost/mirror",
"nginx.ingress.kubernetes.io/mirror-request-body": "off",
}