Skip to content

Commit

Permalink
Merge pull request #1531 from jplindquist/temp_path_depth
Browse files Browse the repository at this point in the history
Enable subdirectory hierarchy for client_body and proxy temp paths
  • Loading branch information
bastelfreak authored Jan 3, 2023
2 parents 26f6285 + 492f1a5 commit 5b294a2
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 13 deletions.
8 changes: 4 additions & 4 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ Default value: `{}`

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

Data type: `Optional[Stdlib::Absolutepath]`

Data type: `Optional[Variant[Stdlib::Absolutepath, Tuple[Stdlib::Absolutepath, Integer, 1, 4]]]`

Can be used to define a directory for storing temporary files holding client request bodies, and up to a three-level subdirectory hierarchy can be used under the specified directory.

Default value: `undef`

Expand Down Expand Up @@ -523,9 +523,9 @@ Default value: `$nginx::params::pid`

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

Data type: `Optional[Stdlib::Absolutepath]`

Data type: `Optional[Variant[Stdlib::Absolutepath, Tuple[Stdlib::Absolutepath, Integer, 1, 4]]]`

Can be used to define a directory for storing temporary files with data received from proxied servers, and up to a three-level subdirectory hierarchy can be used under the specified directory.

Default value: `undef`

Expand Down
17 changes: 15 additions & 2 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,28 @@
}

if $client_body_temp_path {
file { $client_body_temp_path:
if $client_body_temp_path.is_a(String) {
$_client_body_temp_path = [$client_body_temp_path]
} else {
$_client_body_temp_path = $client_body_temp_path
}

file { $_client_body_temp_path[0]:
ensure => directory,
owner => $daemon_user,
mode => '0700',
}
}

if $proxy_temp_path {
file { $proxy_temp_path:
if $proxy_temp_path.is_a(String) {
$_proxy_temp_path = [$proxy_temp_path]
}
else {
$_proxy_temp_path = $proxy_temp_path
}

file { $_proxy_temp_path[0]:
ensure => directory,
owner => $daemon_user,
mode => '0700',
Expand Down
4 changes: 2 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#
class nginx (
### START Nginx Configuration ###
Optional[Stdlib::Absolutepath] $client_body_temp_path = undef,
Optional[Variant[Stdlib::Absolutepath, Tuple[Stdlib::Absolutepath, Integer, 1, 4]]] $client_body_temp_path = undef,
Boolean $confd_only = false,
Boolean $confd_purge = false,
$conf_dir = $nginx::params::conf_dir,
Expand All @@ -70,7 +70,7 @@
Variant[String, Array[String]] $nginx_error_log = "${log_dir}/${nginx::params::nginx_error_log_file}",
Nginx::ErrorLogSeverity $nginx_error_log_severity = 'error',
$pid = $nginx::params::pid,
Optional[Stdlib::Absolutepath] $proxy_temp_path = undef,
Optional[Variant[Stdlib::Absolutepath, Tuple[Stdlib::Absolutepath, Integer, 1, 4]]] $proxy_temp_path = undef,
$root_group = $nginx::params::root_group,
$sites_available_owner = $nginx::params::sites_available_owner,
$sites_available_group = $nginx::params::sites_available_group,
Expand Down
26 changes: 25 additions & 1 deletion spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -917,12 +917,34 @@
value: '/path/to/body_temp',
match: ' client_body_temp_path /path/to/body_temp;'
},
{
title: 'should set client_body_temp_path with subdirectory hierarchy',
attr: 'client_body_temp_path',
value: [
'/path/to/body_temp',
1,
2,
3
],
match: ' client_body_temp_path /path/to/body_temp 1 2 3;'
},
{
title: 'should set proxy_temp_path',
attr: 'proxy_temp_path',
value: '/path/to/proxy_temp',
match: ' proxy_temp_path /path/to/proxy_temp;'
},
{
title: 'should set proxy_temp_path with subdirectory hierarchy',
attr: 'proxy_temp_path',
value: [
'/path/to/proxy_temp',
1,
2,
3
],
match: ' proxy_temp_path /path/to/proxy_temp 1 2 3;'
},
{
title: 'should set proxy_max_temp_file_size',
attr: 'proxy_max_temp_file_size',
Expand Down Expand Up @@ -1124,7 +1146,9 @@

# if we have a _path attribute make sure we create the path
if param[:attr].end_with?('_path')
if param[:value].is_a?(Hash)
if %w[client_body_temp_path proxy_temp_path].include?(param[:attr]) && param[:value].is_a?(Array)
is_expected.to contain_file(param[:value][0]).with_ensure('directory')
elsif param[:value].is_a?(Hash)
param[:value].each_key do |path|
is_expected.to contain_file(path).with_ensure('directory')
end
Expand Down
8 changes: 4 additions & 4 deletions templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ http {
gzip_vary <%= @gzip_vary %>;
<% end -%>

<% if @client_body_temp_path -%>
client_body_temp_path <%= @client_body_temp_path %>;
<% if @_client_body_temp_path -%>
client_body_temp_path <%= @_client_body_temp_path.join(' ') %>;
<% end -%>
<% if @client_max_body_size -%>
client_max_body_size <%= @client_max_body_size %>;
Expand All @@ -179,8 +179,8 @@ http {
<% if @proxy_redirect -%>
proxy_redirect <%= @proxy_redirect %>;
<% end -%>
<% if @proxy_temp_path -%>
proxy_temp_path <%= @proxy_temp_path %>;
<% if @_proxy_temp_path -%>
proxy_temp_path <%= @_proxy_temp_path.join(' ') %>;
<% end -%>
<% if @proxy_connect_timeout -%>
proxy_connect_timeout <%= @proxy_connect_timeout %>;
Expand Down

0 comments on commit 5b294a2

Please sign in to comment.