-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
router test: config template: don't match against the whole file #311
router test: config template: don't match against the whole file #311
Conversation
044c3fc
to
52e34df
Compare
/retest |
edgeBePrefix = "be_edge_http" | ||
) | ||
|
||
// ConfigParser is a primitive HAProxy config parser. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering whether you looked at https://github.com/haproxytech/config-parser and if that would do what we need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I didn't, I wasn't expecting any golang libs from HAProxy community. But this one is even from the upstream! Thanks a lot for the advice. This module looks very promising:
$ cat config.cfg | grep -A 15 be_edge_http:test-route:hello-openshift2
backend be_edge_http:test-route:hello-openshift2
mode http
option redispatch
option forwardfor
balance
timeout check 5000ms
http-request add-header X-Forwarded-Host %[req.hdr(host)]
http-request add-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto http if !{ ssl_fc }
http-request add-header X-Forwarded-Proto https if { ssl_fc }
http-request add-header X-Forwarded-Proto-Version h2 if { ssl_fc_alpn -i h2 }
http-request add-header Forwarded for=%[src];host=%[req.hdr(host)];proto=%[req.hdr(X-Forwarded-Proto)]
http-response set-header Strict-Transport-Security 'max-age=99999;includesubdomain'
cookie f7e936ebe97cd64e8c888d1eba08cb29 insert indirect nocache httponly secure attr SameSite=None
server pod:hello-openshift-7b8c68587c-mtck6:hello-openshift:8080-tcp:10.217.0.24:8080 10.217.0.24:8080 cookie 97ddca1460eca46376928fd7bcf8c89c weight 256 check inter 5000ms
$ cat main.go
package main
import (
"fmt"
"github.com/haproxytech/config-parser/v4"
"github.com/haproxytech/config-parser/v4/options"
"github.com/haproxytech/config-parser/v4/types"
)
func main() {
p, err := parser.New(options.Path("config.cfg"))
if err != nil {
fmt.Println("failed to parse the config:", err)
}
data, err := p.Get(parser.Backends, "be_edge_http:test-route:hello-openshift2", "http-response", false)
if err != nil {
fmt.Println("failed to get backend:", err)
}
responses := data.([]types.HTTPAction)
for _, r := range responses {
fmt.Println(r)
}
}
$ go run main.go
set-header Strict-Transport-Security 'max-age=99999;includesubdomain'
Let me try to integrate it into my PR.
/hold I will try to integrate https://github.com/haproxytech/config-parser module instead of the home made parser. |
/retest |
d3a5989
to
68ec9dc
Compare
/hold cancel |
/assign @frobware |
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great that the upstream config parser slips in so easily.
68ec9dc
to
a4f8427
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alebedev87, frobware The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
4 similar comments
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
27 similar comments
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/skip |
Improvement to the test introduced in #307.
The check for the presence of config snippets is not made against the whole config file anymore.
It now searches only the backend part of the config corresponding to the route.
This helps to avoid the false positives and negatives.
Note the usage of https://github.com/haproxytech/config-parser