From e8c418575de8a3721a5204543454fe7d2c77b148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 5 Jul 2023 11:11:14 -1000 Subject: [PATCH] Fix incorrect data types Some parameter data types are not great and deserve to be changed. Use Variant to allow both the old and new data types, but emit a deprecation warning if the legacy data type is used. A future backward-incompatible PR will remove these legacy data-types and the deprecation warnings. --- REFERENCE.md | 8 ++++---- manifests/init.pp | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index ff104ab7f..8188c1057 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -805,11 +805,11 @@ Default value: `20` ##### `gzip_http_version` -Data type: `Float` +Data type: `Variant[Enum['1.0','1.1'], Float]` -Default value: `1.1` +Default value: `'1.1'` ##### `gzip_proxied` @@ -901,11 +901,11 @@ Default value: `'65s'` ##### `keepalive_requests` -Data type: `String` +Data type: `Variant[Integer, String]` -Default value: `'100'` +Default value: `100` ##### `log_format` diff --git a/manifests/init.pp b/manifests/init.pp index 94d10fb87..f78afd2e5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -111,7 +111,7 @@ Integer $gzip_comp_level = 1, String $gzip_disable = 'msie6', Integer $gzip_min_length = 20, - Float $gzip_http_version = 1.1, + Variant[Enum['1.0','1.1'], Float] $gzip_http_version = '1.1', Nginx::GzipProxied $gzip_proxied = 'off', Optional[Variant[String[1],Array[String[1]]]] $gzip_types = undef, Enum['on', 'off'] $gzip_vary = 'off', @@ -123,7 +123,7 @@ Enum['on', 'off'] $http_tcp_nodelay = 'on', Enum['on', 'off'] $http_tcp_nopush = 'off', Nginx::Time $keepalive_timeout = '65s', - String $keepalive_requests = '100', + Variant[Integer, String] $keepalive_requests = 100, Hash[String[1], Nginx::LogFormat] $log_format = {}, Hash[String[1], Nginx::LogFormat] $stream_log_format = {}, Boolean $mail = false, @@ -244,6 +244,13 @@ ### END Hiera Lookups ### ) inherits nginx::params { + if $gzip_http_version =~ Float { + deprecation('gzip_http_version', 'Passing a Float is deprecated, please pass a String') + } + if $keepalive_requests =~ String { + deprecation('keepalive_requests', 'Passing a String is deprecated, please pass a Integer') + } + contain 'nginx::package' contain 'nginx::config' contain 'nginx::service'