Unverified Commit e430a8a9 authored by Kenyon Ralph's avatar Kenyon Ralph Committed by GitHub
Browse files

Merge pull request #317 from kenyon/regexp-map-type

map: handle regexp type
parents b9b9011a 0d4e6ad4
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -29,11 +29,11 @@
#
define postfix::map (
  Enum['present', 'absent'] $ensure = 'present',
  Variant[Array[String], String, Undef] $source = undef,
  Optional[Variant[Array[String], String]] $source = undef,
  Optional[Variant[Sensitive[String], String]] $content = undef,
  String                                $type = 'hash',
  String[1] $type = 'hash',
  Optional[Stdlib::Absolutepath] $path = undef,
  String[4,4]                           $mode = '0640'
  String[4,4] $mode = '0640',
) {
  include postfix
  include postfix::params
@@ -49,7 +49,7 @@ define postfix::map (
  }

  # CIDR and PCRE maps need a postfix reload, but not a postmap
  if $type =~ /^(cidr|pcre)$/ {
  if $type =~ /^(cidr|pcre|regexp)$/ {
    $manage_notify = Service['postfix']
  } else {
    if $ensure == 'present' {
@@ -71,7 +71,7 @@ define postfix::map (
    notify  => $manage_notify,
  }

  if $type !~ /^(cidr|pcre)$/ {
  if $type !~ /^(cidr|pcre|regexp)$/ {
    file { "postfix map ${name}.db":
      ensure  => $ensure,
      path    => "${_path}.db",
+11 −0
Original line number Diff line number Diff line
@@ -141,6 +141,17 @@ describe 'postfix::map' do
        it { is_expected.to contain_file('postfix map foo').with_ensure('present') }
        it { is_expected.not_to contain_file('postfix map foo.db') }
      end

      context 'when using regexp type' do
        let(:params) do
          {
            type: 'regexp',
          }
        end

        it { is_expected.to contain_file('postfix map foo').with_ensure('present') }
        it { is_expected.not_to contain_file('postfix map foo.db') }
      end
    end
  end
end