-
Notifications
You must be signed in to change notification settings - Fork 154
Add SnippetsPolicy for Gateway level #4461
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
base: main
Are you sure you want to change the base?
Conversation
|
Hi @fabian4! Thanks for opening this pull request! |
ebe3381 to
8e5feb3
Compare
8e5feb3 to
63897e7
Compare
sjberman
left a comment
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.
Thanks for taking this on! It's not easy work.
internal/controller/nginx/config/policies/snippetspolicy/validator.go
Outdated
Show resolved
Hide resolved
e11ed2f to
a155e01
Compare
sjberman
left a comment
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.
When submitting changes, if you could avoid squashing, it makes it easier to review what changed between commits. TIA
| content = fmt.Sprintf(mainTemplate, policyNsName, gwNsName, snippet.Value) | ||
| filename = filepath.Join( | ||
| "includes", "policy", gwNsName, | ||
| fmt.Sprintf("SnippetsPolicy_main_%s.conf", sp.GetName()), |
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.
Can't we just name the file SnippetsPolicy_main_namespace_name.conf and then createIncludesFromPolicyGenerateResult will generate the full path with directory?
bjee19
left a comment
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.
nice work and thanks for taking this on!
If you could also rebase your fork/branch off of upstream main, it will fix some issues we were having from the pipeline not working on forks. We'll then be able to run the pipeline and have the functional test run.
| Expect(err).ToNot(HaveOccurred()) | ||
| Expect(nginxPodNames).To(HaveLen(1)) | ||
|
|
||
| nginxPodName = nginxPodNames[0] |
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 pretty sure because we apply two separate gateways, this'll fail since two nginx pods are created.
a155e01 to
4e1423e
Compare
| // gwNsName := fmt.Sprintf("%s-%s", namespace, "gateway") | ||
| // mainContext := fmt.Sprintf("%s%s/SnippetsPolicy_main_", snippetsPolicyFilePrefix, gwNsName) | ||
| // httpContext := fmt.Sprintf("%s%s/SnippetsPolicy_http_", snippetsPolicyFilePrefix, gwNsName) | ||
| // serverContext := fmt.Sprintf("%s%s/http:80/SnippetsPolicy_server_", snippetsPolicyFilePrefix, gwNsName) |
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.
Not needed?
Problem: Users need a mechanism to inject raw NGINX configuration snippets into the generated configuration to leverage advanced NGINX features or directives that are not yet exposed via the Gateway API or existing NGINX Gateway Fabric policies.
Solution: Implemented the SnippetsPolicy Custom Resource Definition (CRD).
Testing:
Please focus on (optional): The validation logic in internal/controller/nginx/config/policies/snippetspolicy/validator.go, specifically the size limits and context checks.
Closes #4071
Checklist
Before creating a PR, run through this checklist and mark each as complete.
Release notes