Skip to content

Commit c11ab1f

Browse files
committed
Allow vhosts to have a string priority again
In f41251e the type was narrowed to no longer allow strings, but this can cause problems. Sorting is alphabetical and you need to format it for the correct sorting. So to make sure 2 loads before 10 you need to format it as 02. While the vhost can do some printf style magic to change 2 to 02, it must then also know what the highest number is. Otherwise 100 is sorted before 20. By allowing strings, you allow the caller to fix this. A type alias is introduced to reduce duplication and make it easier to track. Fixes: f41251e
1 parent 922c95e commit c11ab1f

File tree

6 files changed

+29
-4
lines changed

6 files changed

+29
-4
lines changed

manifests/vhost.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1730,7 +1730,7 @@
17301730
Optional[Integer] $ssl_stapling_timeout = undef,
17311731
Optional[Enum['on', 'off']] $ssl_stapling_return_errors = undef,
17321732
Optional[String] $ssl_user_name = undef,
1733-
Optional[Variant[Integer, Boolean]] $priority = undef,
1733+
Optional[Apache::Vhost::Priority] $priority = undef,
17341734
Boolean $default_vhost = false,
17351735
Optional[String] $servername = $name,
17361736
Variant[Array[String], String] $serveraliases = [],

manifests/vhost/custom.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
define apache::vhost::custom (
1919
String $content,
2020
String $ensure = 'present',
21-
Variant[Integer, Boolean] $priority = 25,
21+
Apache::Vhost::Priority $priority = 25,
2222
Boolean $verify_config = true,
2323
) {
2424
include apache

manifests/vhost/fragment.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
define apache::vhost::fragment (
6060
String[1] $vhost,
6161
Optional[Stdlib::Port] $port = undef,
62-
Optional[Variant[Integer, Boolean]] $priority = undef,
62+
Optional[Apache::Vhost::Priority] $priority = undef,
6363
Optional[String] $content = undef,
6464
Integer[0] $order = 900,
6565
) {

manifests/vhost/proxy.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
#
107107
define apache::vhost::proxy (
108108
String[1] $vhost,
109-
Optional[Variant[Integer, Boolean]] $priority = undef,
109+
Optional[Apache::Vhost::Priority] $priority = undef,
110110
Integer[0] $order = 170,
111111
Optional[Stdlib::Port] $port = undef,
112112
Optional[String[1]] $proxy_dest = undef,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'Apache::Vhost::Priority' do
6+
# Pattern
7+
it { is_expected.to allow_value('10') }
8+
it { is_expected.to allow_value('010') }
9+
it { is_expected.not_to allow_value('') }
10+
it { is_expected.not_to allow_value('a') }
11+
it { is_expected.not_to allow_value('a1') }
12+
it { is_expected.not_to allow_value('1a') }
13+
14+
# Integer
15+
it { is_expected.to allow_value(0) }
16+
it { is_expected.to allow_value(1) }
17+
18+
# Boolean
19+
it { is_expected.to allow_value(true) } # Technically an illegal value
20+
it { is_expected.to allow_value(false) }
21+
22+
it { is_expected.not_to allow_value(nil) }
23+
end

types/vhost/priority.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# @summary The priority on vhost
2+
type Apache::Vhost::Priority = Variant[Pattern[/^\d+$/], Integer, Boolean]

0 commit comments

Comments
 (0)