Refactor mistral::notifier

Change-Id: I3438cc6d9b473ff774fc8e68a3f9df65c792bfc6
This commit is contained in:
Takashi Kajinami
2022-03-24 13:21:21 +09:00
parent d62e674d47
commit 1766928671
2 changed files with 24 additions and 22 deletions

View File

@@ -5,42 +5,44 @@
# === Parameters # === Parameters
# #
# [*type*] # [*type*]
# Type of notifier. Use local to run the notifier within the # (Optional) Type of notifier. Use local to run the notifier within
# engine server. Use remote if the notifier is launched as # the engine server. Use remote if the notifier is launched as a separate
# a separate server to process events. # server to process events.
# (string value) # (string value)
# Defaults to $::os_service_default. # Defaults to $::os_service_default.
#
# [*host*] # [*host*]
# Name of the notifier node. This can be an opaque # (Optional) Name of the notifier node. This can be an opaque identifier.
# identifier. It is not necessarily a hostname, # It is not necessarily a hostname, FQDN, or IP address.
# FQDN, or IP address.
# (string value) # (string value)
# Defaults to $::os_service_default. # Defaults to $::os_service_default.
#
# [*topic*] # [*topic*]
# The message topic that the notifier server listens on. # (Optional) The message topic that the notifier server listens on.
# (string value) # (string value)
# Defaults to $::os_service_default. # Defaults to $::os_service_default.
#
# [*notify_publishers*] # [*notify_publishers*]
# List of publishers to publish notification. # (Optional) List of publishers to publish notification.
# Note: This maps to the mistral config option `notify` but this is reserved # Note: This maps to the mistral config option `notify` but this is reserved
# in Puppet. # in Puppet.
# (list of dicts) # (list of dicts)
# Defaults to $::os_service_default. # Defaults to $::os_service_default.
#
class mistral::notifier( class mistral::notifier(
$type = $::os_service_default, $type = $::os_service_default,
$host = $::os_service_default, $host = $::os_service_default,
$topic = $::os_service_default, $topic = $::os_service_default,
$notify_publishers = $::os_service_default, $notify_publishers = $::os_service_default,
) { ) {
include mistral::deps include mistral::deps
include mistral::params include mistral::params
mistral_config { mistral_config {
'notifier/type': value => $type; 'notifier/type': value => $type;
'notifier/host': value => $host; 'notifier/host': value => $host;
'notifier/topic': value => $topic; 'notifier/topic': value => $topic;
'notifier/notify': value => $notify_publishers; 'notifier/notify': value => $notify_publishers;
} }
} }

View File

@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'mistral::notifier' do describe 'mistral::notifier' do
shared_examples_for 'mistral notifier' do shared_examples_for 'mistral::notifier' do
it 'configure notifier default params' do it 'configure notifier default params' do
is_expected.to contain_mistral_config('notifier/type').with_value('<SERVICE DEFAULT>') is_expected.to contain_mistral_config('notifier/type').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('notifier/host').with_value('<SERVICE DEFAULT>') is_expected.to contain_mistral_config('notifier/host').with_value('<SERVICE DEFAULT>')
@@ -12,9 +12,9 @@ describe 'mistral::notifier' do
context 'with specific parameters' do context 'with specific parameters' do
let :params do let :params do
{ :type => "remote", { :type => "remote",
:host => "localhost", :host => "localhost",
:topic => "mistral-event-stream", :topic => "mistral-event-stream",
:notify_publishers => "[{'type': 'noop'}]", :notify_publishers => "[{'type': 'noop'}]",
} }
end end
@@ -36,7 +36,7 @@ describe 'mistral::notifier' do
facts.merge!(OSDefaults.get_facts()) facts.merge!(OSDefaults.get_facts())
end end
it_configures 'mistral notifier' it_configures 'mistral::notifier'
end end
end end