Unverified Commit 5467a484 authored by Steve Traylen's avatar Steve Traylen Committed by GitHub
Browse files

Merge pull request #435 from traylenator/canon

New `canonicals` parameter of `postfix::canonical` types
parents 60f2cba8 b75fa1f8
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -148,6 +148,7 @@ The following parameters are available in the `postfix` class:
* [`use_schleuder`](#-postfix--use_schleuder)
* [`use_sympa`](#-postfix--use_sympa)
* [`virtuals`](#-postfix--virtuals)
* [`canonicals`](#-postfix--canonicals)

##### <a name="-postfix--alias_maps"></a>`alias_maps`

@@ -657,6 +658,14 @@ A hash of postfix::virtual resources

Default value: `{}`

##### <a name="-postfix--canonicals"></a>`canonicals`

Data type: `Hash[String[1], Hash[String[1], Any]]`

A hash of postfix::canonical resources

Default value: `{}`

## Defined types

### <a name="postfix--canonical"></a>`postfix::canonical`
+10 −0
Original line number Diff line number Diff line
@@ -260,6 +260,9 @@
# @param virtuals
#   A hash of postfix::virtual resources
#
# @param canonicals
#   A hash of postfix::canonical resources
#
class postfix (
  String $alias_maps = 'hash:/etc/aliases',
  Integer $amavis_procs = 2,
@@ -318,6 +321,7 @@ class postfix (
  Variant[Integer[2, 3], Boolean] $use_schleuder = false, # postfix_use_schleuder
  Boolean $use_sympa = false, # postfix_use_sympa
  Hash $virtuals = {},
  Hash[String[1], Hash[String[1], Any]] $canonicals = {},
) inherits postfix::params {
  if (
    ($mastercf_source and $mastercf_content) or
@@ -362,6 +366,12 @@ class postfix (
    }
  }

  $canonicals.each |$key, $value| {
    postfix::canonical { $key:
      * => $value,
    }
  }

  $hashes.each |$key, $value| {
    postfix::hash { $key:
      * => $value,
+25 −0
Original line number Diff line number Diff line
@@ -756,6 +756,31 @@ describe 'postfix' do
        end
      end

      context 'when canonicals hash is used' do # rubocop:disable RSpec/MultipleMemoizedHelpers
        let :pre_condition do
          "postfix::hash{'/etc/postfix/sender_canonical': ensure => present }"
        end
        let(:params) do
          {
            canonicals: {
              'root' => {
                'destination' => 'root_special@example.org',
                'file'        => '/etc/postfix/sender_canonical',
              },
              'adm' => {
                'destination' => 'adm_special@example.org',
                'file'        => '/etc/postfix/sender_canonical',
              },
            },
          }
        end

        it 'updates the cannonical map' do
          is_expected.to contain_postfix__canonical('root').with_destination('root_special@example.org')
          is_expected.to contain_postfix__canonical('adm').with_file('/etc/postfix/sender_canonical')
        end
      end

      context 'when conffiles hash is used' do # rubocop:disable RSpec/MultipleMemoizedHelpers
        let(:params) do
          {