Projet

Général

Profil

Révision 9f0498e3

ID9f0498e3fd950071f486ac673fc0b091f815ea0b
Parent 0cf43fdf
Enfant 7bb485c5

Ajouté par Nacho Barrientos il y a plus de 4 ans

Relax nftables::set::type making it optional

This is needed in case nftables::set is passed raw configuration via
source or content.

Voir les différences:

manifests/set.pp
1 1
# manage a named set
2 2
define nftables::set(
3
  Enum['ipv4_addr', 'ipv6_addr', 'ether_addr', 'inet_proto', 'inet_service', 'mark']
4
    $type,
5 3
  Enum['present','absent']
6 4
    $ensure = 'present',
7 5
  Pattern[/^[a-zA-Z0-9_]+$/]
8 6
    $setname = $title,
9 7
  Pattern[/^\d\d$/]
10 8
    $order = '10',
9
  Optional[Enum['ipv4_addr', 'ipv6_addr', 'ether_addr', 'inet_proto', 'inet_service', 'mark']]
10
    $type = undef,
11 11
  String
12 12
    $table = 'inet-filter',
13 13
  Array[Enum['constant', 'dynamic', 'interval', 'timeout'], 0, 4]
......
52 52
        source => $source,
53 53
      }
54 54
    } else {
55
      if $type == undef {
56
        fail('The way the resource is configured must have a type set')
57
      }
55 58
      Concat::Fragment["nftables-${table}-set-${setname}"]{
56 59
        content => epp('nftables/set.epp',
57 60
          {
spec/defines/set_spec.rb
115 115
          )
116 116
        }
117 117
      end
118

  
119
      describe 'using raw content' do
120
        let(:params) do
121
          {
122
            content: 'set my_set { }',
123
          }
124
        end
125

  
126
        it { is_expected.to compile }
127
        it {
128
          is_expected.to contain_concat__fragment('nftables-inet-filter-set-my_set').with(
129
            target:  'nftables-inet-filter',
130
            content: '  set my_set { }',
131
            order:   '10',
132
          )
133
        }
134
      end
135

  
136
      describe 'fails without a type and not source/content' do
137
        it { is_expected.not_to compile }
138
      end
118 139
    end
119 140
  end
120 141
end

Formats disponibles : Unified diff