-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
refactor(nginx-templates): reduce redundancy #11354
Conversation
de175a4
to
6f135a0
Compare
f3a7103
to
4bb916c
Compare
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 only find 1 use of spec/fixtures/1.2_custom_nginx.template
. Could we eliminate that file too?
Also, could we use a unified template instead of with a separate file called "custom_nginx.template"?
e68eb19
to
e72ce3a
Compare
0b3a3f6
to
505902c
Compare
505902c
to
2dae3a5
Compare
As discussed, let's postpone any additional changes to a separate PR if needed. We are also leaving the |
2dae3a5
to
372f12d
Compare
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 we try to move this into own template, render it and then Nginx include it?
fe7cb7d
to
b7b4c9c
Compare
0a09167
to
640fad5
Compare
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.
Just something to think about, not must.
2930641
to
e0c4e17
Compare
This commit tries to unify as much of the configuration as possible in a single place to reduce duplication and consequently the chances of forgetting to update one of the files. * nginx_kong.lua is compiled into nginx-kong.conf: chunks that are only meant for the test environment are rendered, if needed. * When the template is rendered, nginx-kong.conf is dynamically loaded in the http section using the include directive. refactor(templates): apply PR suggestions - use nginx include instead of rendering files in the templates using inline lua expressions - rename test-flags to nginx-conf-flags - cleanup of non needed changes - adapt tests Co-authored-by: Aapo Talvensaari <aapo.talvensaari@gmail.com>
e0c4e17
to
d37f96f
Compare
Looks good! Merge on green! |
15c5163
to
16feece
Compare
Summary
Currently integration tests use dedicated templates that are manually kept in sync with the base nginx_kong.lua and nginx_kong_stream.lua configurations (should a change be made to those files it has to be manually replicated in custom_nginx.template and default_nginx.template). This is error prone and can lead to inconsistencies between the standard config and the one used in tests.
This PR tries to unify as much of the configuration as possible in a single place to reduce duplication and consequently the chances of forgetting to update one of the files, which may result in running tests with a configuration that differs from the "production" one.
Implementation
nginx_kong.lua
is compiled intonginx-kong.conf
, while all the.lua
files infixtures/template_inject
are compiled into.test.conf
configuration files in the prefix folder. During compilation, chunks that are only meant for the tests are rendered, if needed (this is controlled by thetest
flag in the template environment). Config flags are set in the template rendering environment based on the --conf-template-flags input of the start cmd.When the template is rendered,
nginx-kong.conf
and the other partial configs are loaded in thehttp
section using theinclude
directive. A similar approach is followed for the stream configuration.Checklist
Full changelog
Issue reference
KAG-1962