Fix mirror-target values without path separator and port (#9889)

* Remove variables with $ before feeding into url.Parse

Signed-off-by: Gerald Pape <gerald@giantswarm.io>

* Do not render invalid request mirroring config

Signed-off-by: Gerald Pape <gerald@giantswarm.io>

* Remove additional note from docs again

Signed-off-by: Gerald Pape <gerald@giantswarm.io>

* Include quotes in e2e test for mirror proxy_pass

---------

Signed-off-by: Gerald Pape <gerald@giantswarm.io>
This commit is contained in:
Gerald Pape 2023-06-11 20:59:47 +02:00 committed by GitHub
parent 4d3e64258c
commit db49b9da6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 7 deletions

View file

@ -93,12 +93,13 @@ func (a mirror) Parse(ing *networking.Ingress) (interface{}, error) {
config.Host, err = parser.GetStringAnnotation("mirror-host", ing)
if err != nil {
if config.Target != "" {
url, err := parser.StringToURL(config.Target)
target := strings.Split(config.Target, "$")
url, err := parser.StringToURL(target[0])
if err != nil {
config.Host = ""
} else {
hostname := strings.Split(url.Hostname(), "$")
config.Host = hostname[0]
config.Host = url.Hostname()
}
}
}