Add support for oslo_policy/enforce_new_defaults

Change-Id: Id2f7990cd9743db38b4991f67f2de6b9636cb528
This commit is contained in:
Takashi Kajinami 2021-04-22 11:55:31 +09:00
parent 3d0a2b2cb1
commit 952503a3c2
2 changed files with 19 additions and 10 deletions

View File

@ -8,6 +8,11 @@
# (Optional) Whether or not to enforce scope when evaluating policies.
# Defaults to $::os_service_default.
#
# [*enforce_new_defaults*]
# (Optional) Whether or not to use old deprecated defaults when evaluating
# policies.
# Defaults to $::os_service_default.
#
# [*policies*]
# (Optional) Set of policies to configure for {{cookiecutter.project_name}}
# Example :
@ -28,9 +33,10 @@
# Defaults to /etc/{{cookiecutter.project_name}}/policy.yaml
#
class {{cookiecutter.project_name}}::policy (
$enforce_scope = $::os_service_default,
$policies = {},
$policy_path = '/etc/{{cookiecutter.project_name}}/policy.yaml',
$enforce_scope = $::os_service_default,
$enforce_new_defaults = $::os_service_default,
$policies = {},
$policy_path = '/etc/{{cookiecutter.project_name}}/policy.yaml',
) {
include {{cookiecutter.project_name}}::deps
@ -48,8 +54,9 @@ class {{cookiecutter.project_name}}::policy (
create_resources('openstacklib::policy::base', $policies)
oslo::policy { '{{cookiecutter.project_name}}_config':
enforce_scope => $enforce_scope,
policy_file => $policy_path
enforce_scope => $enforce_scope,
enforce_new_defaults => $enforce_new_defaults,
policy_file => $policy_path
}
}

View File

@ -4,9 +4,10 @@ describe '{{cookiecutter.project_name}}::policy' do
shared_examples '{{cookiecutter.project_name}}::policy' do
let :params do
{
:enforce_scope => false,
:policy_path => '/etc/{{cookiecutter.project_name}}/policy.yaml',
:policies => {
:enforce_scope => false,
:enforce_new_defaults => false,
:policy_path => '/etc/{{cookiecutter.project_name}}/policy.yaml',
:policies => {
'context_is_admin' => {
'key' => 'context_is_admin',
'value' => 'foo:bar'
@ -24,8 +25,9 @@ describe '{{cookiecutter.project_name}}::policy' do
:file_format => 'yaml',
})
is_expected.to contain_oslo__policy('{{cookiecutter.project_name}}_config').with(
:enforce_scope => false,
:policy_file => '/etc/{{cookiecutter.project_name}}/policy.yaml',
:enforce_scope => false,
:enforce_new_defaults => false,
:policy_file => '/etc/{{cookiecutter.project_name}}/policy.yaml',
)
end
end