diff --git a/manifests/config.pp b/manifests/config.pp index 579cc1c..16c243a 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -66,12 +66,13 @@ # Determine the directory for the chosen binary provider. if ($binary_provider_type == 'file-system') and ! $::artifactory::binary_provider_filesystem_dir { - $mapped_provider_filesystem_dir = 'filestore' - } else { - $mapped_provider_filesystem_dir = $::artifactory::binary_provider_filesystem_dir - } - if $::artifactory::binary_provider_base_data_dir { - $binary_provider_filesystem_dir = "${::artifactory::binary_provider_base_data_dir}/${mapped_provider_filesystem_dir}" + if $::artifactory::binary_provider_base_data_dir { + $binary_provider_filesystem_dir = "${::artifactory::binary_provider_base_data_dir}/filestore" + } else { + $binary_provider_filesystem_dir = undef + } + } elsif ($binary_provider_type == 'file-system') and $::artifactory::binary_provider_filesystem_dir { + $binary_provider_filesystem_dir = $::artifactory::binary_provider_filesystem_dir } else { $binary_provider_filesystem_dir = undef } diff --git a/spec/classes/artifactory_spec.rb b/spec/classes/artifactory_spec.rb index fdd6d32..3226de1 100644 --- a/spec/classes/artifactory_spec.rb +++ b/spec/classes/artifactory_spec.rb @@ -169,19 +169,77 @@ } end - context 'artifactory class with version specified' do + context 'running a legacy version (pre v7)' do let(:params) do { - 'package_version' => '5.9.1', + 'package_version' => '6.0.0', } end it { is_expected.to compile.with_all_deps } it { is_expected.to contain_package('jfrog-artifactory-oss').with( - 'ensure' => '5.9.1', + 'ensure' => '6.0.0', ) } + it { + is_expected.to contain_file('/var/opt/jfrog/artifactory/etc/binarystore.xml').with_content(%r{chain template="file-system"}) + is_expected.to contain_file('/var/opt/jfrog/artifactory/etc/binarystore.xml').without_content(%r{}) + is_expected.to contain_file('/var/opt/jfrog/artifactory/etc/binarystore.xml').without_content(%r{}) + is_expected.to contain_file('/var/opt/jfrog/artifactory/etc/binarystore.xml').without_content(%r{}) + } + end + + context 'running a current version' do + let(:params) do + { + 'package_version' => '7.4.3', + } + end + + it { is_expected.to compile.with_all_deps } + it { + is_expected.to contain_package('jfrog-artifactory-oss').with( + 'ensure' => '7.4.3', + ) + } + it { + is_expected.to contain_file('/var/opt/jfrog/artifactory/etc/artifactory/binarystore.xml').with_content(%r{chain template="file-system"}) + is_expected.to contain_file('/var/opt/jfrog/artifactory/etc/artifactory/binarystore.xml').without_content(%r{}) + is_expected.to contain_file('/var/opt/jfrog/artifactory/etc/artifactory/binarystore.xml').without_content(%r{}) + is_expected.to contain_file('/var/opt/jfrog/artifactory/etc/artifactory/binarystore.xml').without_content(%r{}) + } + end + + context 'running a current version with a custom binary filesystem dir' do + let(:params) do + { + 'package_version' => '7.4.3', + 'binary_provider_filesystem_dir' => '/opt/artifactory-filestore', + } + end + + it { is_expected.to compile.with_all_deps } + it { + is_expected.to contain_file('/var/opt/jfrog/artifactory/etc/artifactory/binarystore.xml').with_content(%r{}) + is_expected.to contain_file('/var/opt/jfrog/artifactory/etc/artifactory/binarystore.xml').with_content(%r{/opt/artifactory-filestore}) + is_expected.to contain_file('/var/opt/jfrog/artifactory/etc/artifactory/binarystore.xml').without_content(%r{}) + } + end + + context 'running a current version with a custom binary base data dir' do + let(:params) do + { + 'package_version' => '7.4.3', + 'binary_provider_base_data_dir' => '/opt/artifactory-data', + } + end + + it { is_expected.to compile.with_all_deps } + it { + is_expected.to contain_file('/var/opt/jfrog/artifactory/etc/artifactory/binarystore.xml').with_content(%r{/opt/artifactory-data}) + is_expected.to contain_file('/var/opt/jfrog/artifactory/etc/artifactory/binarystore.xml').with_content(%r{/opt/artifactory-data/filestore}) + } end end end diff --git a/templates/binarystore.xml.epp b/templates/binarystore.xml.epp index 56b9f65..a2401a2 100644 --- a/templates/binarystore.xml.epp +++ b/templates/binarystore.xml.epp @@ -33,33 +33,33 @@ -<% if $binary_provider_type == 'filesystem' +<% if $binary_provider_type == 'file-system' and ($binary_provider_base_data_dir or $binary_provider_filesystem_dir) - or $binary_provider_type == 'cachedFS' + or $binary_provider_type == 'cache-fs' and ($binary_provider_cache_dir or $binary_provider_cache_maxsize) { -%> -<% if $binary_provider_type == 'filesystem' +<% if $binary_provider_type == 'file-system' and $binary_provider_base_data_dir { -%> <%= $binary_provider_base_data_dir %> <% } -%> -<% if $binary_provider_type == 'filesystem' +<% if $binary_provider_type == 'file-system' and $binary_provider_filesystem_dir { -%> <%= $binary_provider_filesystem_dir %> <% } -%> -<% if $binary_provider_type == 'cachedFS' +<% if $binary_provider_type == 'cache-fs' and $binary_provider_cache_maxsize { -%> <%= $binary_provider_cache_maxsize %> <% } -%> -<% if $binary_provider_type == 'cachedFS' +<% if $binary_provider_type == 'cache-fs' and $binary_provider_cache_dir { -%> <%= $binary_provider_cache_dir %> <% } -%> -<% } elsif $binary_provider_type == 'fullDb' { -%> +<% } elsif $binary_provider_type == 'full-db' { -%> -<% } elsif $binary_provider_type == 'fullDbDirect' { -%> +<% } elsif $binary_provider_type == 'full-db-direct' { -%> <% } -%>