diff --git a/manifests/proxy/symlink.pp b/manifests/proxy/symlink.pp new file mode 100644 index 00000000..5c30526c --- /dev/null +++ b/manifests/proxy/symlink.pp @@ -0,0 +1,42 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Configure swift symlink middleware. +# +# == Example +# +# include ::swift::proxy::symlink +# +# == Parameters +# +# [*symloop_max*] +# Symlinks can point to other symlinks provided the number of symlinks in a +# chain does not exceed the symloop_max value. If the number of chained +# symlinks exceeds the limit symloop_max a 409 (HTTPConflict) error +# response will be produced. +# Default to $::os_service_default +# +# == Authors +# +# shi.yan@ardc.edu.au +# +class swift::proxy::symlink( + $symloop_max = $::os_service_default, +) { + + include swift::deps + + swift_proxy_config { + 'filter:symlink/use': value => 'egg:swift#symlink'; + 'filter:symlink/symloop_max': value => $symloop_max; + } +} diff --git a/releasenotes/notes/add-swift-proxy-symlink-4864e7c1755567d4.yaml b/releasenotes/notes/add-swift-proxy-symlink-4864e7c1755567d4.yaml new file mode 100644 index 00000000..f8a42f98 --- /dev/null +++ b/releasenotes/notes/add-swift-proxy-symlink-4864e7c1755567d4.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Add swift::proxy::symlink class to configure symlink middleware for swift proxy. diff --git a/spec/classes/swift_proxy_symlink_spec.rb b/spec/classes/swift_proxy_symlink_spec.rb new file mode 100644 index 00000000..275277eb --- /dev/null +++ b/spec/classes/swift_proxy_symlink_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe 'swift::proxy::symlink' do + shared_examples 'swift::proxy::symlink' do + context 'when using default parameters' do + it { is_expected.to contain_swift_proxy_config('filter:symlink/use').with_value('egg:swift#symlink') } + it { is_expected.to contain_swift_proxy_config('filter:symlink/symloop_max').with_value('') } + end + + context 'when overriding default parameters' do + let :params do + { + :symloop_max => '3' + } + end + + it { is_expected.to contain_swift_proxy_config('filter:symlink/use').with_value('egg:swift#symlink') } + it { is_expected.to contain_swift_proxy_config('filter:symlink/symloop_max').with_value('3') } + 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::symlink' + end + end +end