Add support for read_only middleware

Change-Id: I82726ab76587a134f9267521821b48e8a1a05936
This commit is contained in:
Takashi Kajinami 2024-02-18 14:08:44 +09:00
parent 0e3f254347
commit 1b5eceeb36
3 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,27 @@
# == Class: swift::proxy::read_only
#
# Configure read_only middleware
#
# === Parameters
#
# [*read_only*]
# (optional) Turn on global read only.
# Defauls to $facts['os_service_default']
#
# [*allow_deletes*]
# (optional) Allow deletes.
# Defauls to $facts['os_service_default']
#
class swift::proxy::read_only(
$read_only = $facts['os_service_default'],
$allow_deletes = $facts['os_service_default']
) {
include swift::deps
swift_proxy_config {
'filter:read_only/use': value => 'egg:swift#read_only';
'filter:read_only/read_only': value => $read_only;
'filter:read_only/allow_deletes': value => $allow_deletes;
}
}

View File

@ -0,0 +1,4 @@
---
features:
- |
The new ``swift::proxy::read_only`` class has been added.

View File

@ -0,0 +1,36 @@
require 'spec_helper'
describe 'swift::proxy::read_only' do
shared_examples 'swift::proxy::read_only' do
context 'when using default parameters' do
it { is_expected.to contain_swift_proxy_config('filter:read_only/use').with_value('egg:swift#read_only') }
it { is_expected.to contain_swift_proxy_config('filter:read_only/read_only').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_swift_proxy_config('filter:read_only/allow_deletes').with_value('<SERVICE DEFAULT>') }
end
context 'when overriding default parameters' do
let :params do
{
:read_only => true,
:allow_deletes => false,
}
end
it { is_expected.to contain_swift_proxy_config('filter:read_only/use').with_value('egg:swift#read_only') }
it { is_expected.to contain_swift_proxy_config('filter:read_only/read_only').with_value(true) }
it { is_expected.to contain_swift_proxy_config('filter:read_only/allow_deletes').with_value(false) }
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge(OSDefaults.get_facts())
end
it_behaves_like 'swift::proxy::read_only'
end
end
end