Merge "policy: Raise error when file_path and file_format are inconsistent"
This commit is contained in:
commit
0bd042f047
|
@ -78,6 +78,12 @@ define openstacklib::policy::base (
|
||||||
~> Augeas<| title == "${file_path}-${key}-${value}" |>
|
~> Augeas<| title == "${file_path}-${key}-${value}" |>
|
||||||
}
|
}
|
||||||
'yaml': {
|
'yaml': {
|
||||||
|
if stdlib::extname($file_path) == '.json' {
|
||||||
|
# NOTE(tkajinam): It is likely that user is not aware of migration from
|
||||||
|
# policy.json to policy.yaml
|
||||||
|
fail("file_path: ${file_path} should be a yaml file instead of a json file")
|
||||||
|
}
|
||||||
|
|
||||||
ensure_resource('file', $file_path, {
|
ensure_resource('file', $file_path, {
|
||||||
mode => $file_mode,
|
mode => $file_mode,
|
||||||
owner => $file_user,
|
owner => $file_user,
|
||||||
|
|
|
@ -72,6 +72,26 @@ describe 'openstacklib::policy::base' do
|
||||||
) }
|
) }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with json file_path and yaml file format' do
|
||||||
|
let :title do
|
||||||
|
'nova-contest_is_admin'
|
||||||
|
end
|
||||||
|
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:file_path => '/etc/nova/policy.json',
|
||||||
|
:key => 'context_is_admin or owner',
|
||||||
|
:value => 'foo:bar',
|
||||||
|
:file_mode => '0644',
|
||||||
|
:file_user => 'foo',
|
||||||
|
:file_group => 'bar',
|
||||||
|
:file_format => 'yaml',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it { should raise_error(Puppet::Error) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
on_supported_os({
|
on_supported_os({
|
||||||
|
|
Loading…
Reference in New Issue