Refactor the swift::proxy::tempurl class
- Use $::os_service_default as the default value instead of undef. - Use any2array to generate raw value rendered into proxy-server.conf. This removes warnings about undefined variables. Change-Id: Idc3a2afc591e6a5025b6cc529ae7f10637cd2a64
This commit is contained in:
parent
0d583ffeb8
commit
a353ef8c75
|
@ -6,27 +6,27 @@
|
||||||
# [*methods*]
|
# [*methods*]
|
||||||
# Methods allowed with Temp URLs.
|
# Methods allowed with Temp URLs.
|
||||||
# Example: ['GET','HEAD','PUT','POST','DELETE'] or 'GET HEAD PUT POST DELETE'
|
# Example: ['GET','HEAD','PUT','POST','DELETE'] or 'GET HEAD PUT POST DELETE'
|
||||||
# Optional. Defaults to undef.
|
# Optional. Defaults to $::os_service_default.
|
||||||
#
|
#
|
||||||
# [*incoming_remove_headers*]
|
# [*incoming_remove_headers*]
|
||||||
# The headers to remove from incoming requests.
|
# The headers to remove from incoming requests.
|
||||||
# Example: ['x-timestamp'] or 'x-timestamp'
|
# Example: ['x-timestamp'] or 'x-timestamp'
|
||||||
# Optional. Defaults to undef.
|
# Optional. Defaults to $::os_service_default.
|
||||||
#
|
#
|
||||||
# [*incoming_allow_headers*]
|
# [*incoming_allow_headers*]
|
||||||
# The headers allowed as exceptions to incoming_remove_headers
|
# The headers allowed as exceptions to incoming_remove_headers
|
||||||
# Example: ['*'] or '*'
|
# Example: ['*'] or '*'
|
||||||
# Optional. Defaults to undef.
|
# Optional. Defaults to $::os_service_default.
|
||||||
#
|
#
|
||||||
# [*outgoing_remove_headers*]
|
# [*outgoing_remove_headers*]
|
||||||
# The headers to remove from outgoing responses
|
# The headers to remove from outgoing responses
|
||||||
# Example: ['x-object-meta-*'] or 'x-object-meta-*'
|
# Example: ['x-object-meta-*'] or 'x-object-meta-*'
|
||||||
# Optional. Defaults to undef.
|
# Optional. Defaults to $::os_service_default.
|
||||||
#
|
#
|
||||||
# [*outgoing_allow_headers*]
|
# [*outgoing_allow_headers*]
|
||||||
# The headers allowed as exceptions to outgoing_remove_headers
|
# The headers allowed as exceptions to outgoing_remove_headers
|
||||||
# Example: ['x-object-meta-public-*'] or 'x-object-meta-public-*'
|
# Example: ['x-object-meta-public-*'] or 'x-object-meta-public-*'
|
||||||
# Optional. Defaults to undef.
|
# Optional. Defaults to $::os_service_default.
|
||||||
#
|
#
|
||||||
# == Examples
|
# == Examples
|
||||||
#
|
#
|
||||||
|
@ -45,55 +45,20 @@
|
||||||
# Copyright 2012 eNovance licensing@enovance.com
|
# Copyright 2012 eNovance licensing@enovance.com
|
||||||
#
|
#
|
||||||
class swift::proxy::tempurl (
|
class swift::proxy::tempurl (
|
||||||
$methods = undef,
|
$methods = $::os_service_default,
|
||||||
$incoming_remove_headers = undef,
|
$incoming_remove_headers = $::os_service_default,
|
||||||
$incoming_allow_headers = undef,
|
$incoming_allow_headers = $::os_service_default,
|
||||||
$outgoing_remove_headers = undef,
|
$outgoing_remove_headers = $::os_service_default,
|
||||||
$outgoing_allow_headers = undef,
|
$outgoing_allow_headers = $::os_service_default,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include swift::deps
|
include swift::deps
|
||||||
|
|
||||||
if($methods) {
|
$methods_real = join(any2array($methods), ' ')
|
||||||
if is_array($methods) {
|
$incoming_remove_headers_real = join(any2array($incoming_remove_headers), ' ')
|
||||||
$methods_real = join($methods,' ')
|
$incoming_allow_headers_real = join(any2array($incoming_allow_headers), ' ')
|
||||||
} elsif is_string($methods) {
|
$outgoing_remove_headers_real = join(any2array($outgoing_remove_headers), ' ')
|
||||||
$methods_real = $methods
|
$outgoing_allow_headers_real = join(any2array($outgoing_allow_headers), ' ')
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($incoming_remove_headers) {
|
|
||||||
if is_array($incoming_remove_headers) {
|
|
||||||
$incoming_remove_headers_real = join($incoming_remove_headers,' ')
|
|
||||||
} elsif is_string($incoming_remove_headers) {
|
|
||||||
$incoming_remove_headers_real = $incoming_remove_headers
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($incoming_allow_headers) {
|
|
||||||
if is_array($incoming_allow_headers) {
|
|
||||||
$incoming_allow_headers_real = join($incoming_allow_headers,' ')
|
|
||||||
} elsif is_string($incoming_allow_headers) {
|
|
||||||
$incoming_allow_headers_real = $incoming_allow_headers
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($outgoing_remove_headers) {
|
|
||||||
if is_array($outgoing_remove_headers) {
|
|
||||||
$outgoing_remove_headers_real = join($outgoing_remove_headers,' ')
|
|
||||||
} elsif is_string($outgoing_remove_headers) {
|
|
||||||
$outgoing_remove_headers_real = $outgoing_remove_headers
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($outgoing_allow_headers) {
|
|
||||||
if is_array($outgoing_allow_headers) {
|
|
||||||
$outgoing_allow_headers_real = join($outgoing_allow_headers,' ')
|
|
||||||
} elsif is_string($outgoing_allow_headers) {
|
|
||||||
$outgoing_allow_headers_real = $outgoing_allow_headers
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
swift_proxy_config {
|
swift_proxy_config {
|
||||||
'filter:tempurl/use': value => 'egg:swift#tempurl';
|
'filter:tempurl/use': value => 'egg:swift#tempurl';
|
||||||
|
|
|
@ -9,7 +9,7 @@ describe 'swift::proxy::tempurl' do
|
||||||
'incoming_allow_headers',
|
'incoming_allow_headers',
|
||||||
'outgoing_remove_headers',
|
'outgoing_remove_headers',
|
||||||
'outgoing_allow_headers' ].each do |h|
|
'outgoing_allow_headers' ].each do |h|
|
||||||
it { is_expected.to_not contain_swift_proxy_config("filter:tempurl/#{h}").with_value('') }
|
it { is_expected.to contain_swift_proxy_config("filter:tempurl/#{h}").with_value('<SERVICE DEFAULT>') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when params are set" do
|
context "when params are set" do
|
||||||
|
|
Loading…
Reference in New Issue