Skip to content

Commit

Permalink
Allow to set log_format's "escape" parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
smortex committed Aug 19, 2022
1 parent 6d59c0e commit 2f6e201
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
Enum['on', 'off'] $http_tcp_nopush = 'off',
$keepalive_timeout = '65s',
$keepalive_requests = '100',
$log_format = {},
Hash[String[1], Nginx::Log_format] $log_format = {},
Boolean $mail = false,
Variant[String, Boolean] $mime_types_path = 'mime.types',
Boolean $stream = false,
Expand Down
6 changes: 5 additions & 1 deletion templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ http {
default_type application/octet-stream;
<% if @log_format -%>
<% @log_format.sort_by{|k,v| k}.each do |key,value| -%>
log_format <%= key %> '<%= value %>';
<%- if value.is_a?(String) -%>
log_format <%= key %> <%= Puppet::Pops::Types::StringConverter.convert(value, '%#p') %>;
<%- else -%>
log_format <%= key %> <%= "escape=#{value['escape']} " if value['escape'] %><%= Puppet::Pops::Types::StringConverter.convert(value['format'], '%#p') %>;
<%- end -%>
<% end -%>
<% end -%>

Expand Down
7 changes: 7 additions & 0 deletions types/log_format.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type Nginx::Log_format = Variant[
String[1],
Struct[{
Optional[escape] => Enum['default', 'json', 'none'],
format => String[1],
}],
]

0 comments on commit 2f6e201

Please sign in to comment.