Skip to content

Commit

Permalink
Allow multiple values in gzip_proxied parameter
Browse files Browse the repository at this point in the history
According to the official NGINX documentation the parameter gzip_proxied
allows multiple parameters.

Closes #1567
  • Loading branch information
jay7x committed Oct 15, 2023
1 parent d4cb417 commit 36d7338
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ Default value: `'1.1'`

##### <a name="-nginx--gzip_proxied"></a>`gzip_proxied`

Data type: `Nginx::GzipProxied`
Data type: `Variant[Nginx::GzipProxied, Array[Nginx::GzipProxied]]`



Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
String $gzip_disable = 'msie6',
Integer $gzip_min_length = 20,
Variant[Enum['1.0','1.1'], Float] $gzip_http_version = '1.1',
Nginx::GzipProxied $gzip_proxied = 'off',
Variant[Nginx::GzipProxied, Array[Nginx::GzipProxied]] $gzip_proxied = 'off',
Optional[Variant[String[1],Array[String[1]]]] $gzip_types = undef,
Enum['on', 'off'] $gzip_vary = 'off',
Optional[Enum['on', 'off', 'always']] $gzip_static = undef,
Expand Down
16 changes: 16 additions & 0 deletions spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,22 @@
end
end

context 'when gzip is non-default (on) set gzip_proxied' do
let(:params) { { gzip: 'on' } }

context 'set gzip_proxied to a single value' do
let(:params) { super().merge({ gzip_proxied: 'any' }) }

it { is_expected.to contain_file('/etc/nginx/nginx.conf').with_content(%r{ gzip_proxied any;}) }
end

context 'set gzip_proxied to multiple values' do
let(:params) { super().merge({ gzip_proxied: %w[no-cache expired] }) }

it { is_expected.to contain_file('/etc/nginx/nginx.conf').with_content(%r{ gzip_proxied no-cache expired;}) }
end
end

context 'when gzip_static is non-default set gzip_static' do
let(:params) do
{
Expand Down
2 changes: 1 addition & 1 deletion templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ http {
gzip_min_length <%= @gzip_min_length %>;
gzip_http_version <%= @gzip_http_version %>;
<% if @gzip_proxied -%>
gzip_proxied <%= @gzip_proxied %>;
gzip_proxied <%= Array(@gzip_proxied).uniq.join(' ') %>;
<% end -%>
<% if @gzip_types -%>
gzip_types <%= @gzip_types.kind_of?(Array) ? @gzip_types.join(' ') : @gzip_types %>;
Expand Down

0 comments on commit 36d7338

Please sign in to comment.