From b32c18a02aef7ae0654e981b78eb3d044f59d4c9 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Mon, 11 Apr 2022 14:55:44 +0200 Subject: [PATCH] config: add support for s3 binary store Since this supports a lot of config options, I chose to allow specifying them as a Hash option instead of handling them individually. Signed-off-by: Frank Lichtenheld --- manifests/config.pp | 5 ++++- manifests/init.pp | 3 ++- spec/classes/artifactory_spec.rb | 23 +++++++++++++++++++++++ templates/binarystore.xml.epp | 9 ++++++++- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index f5de1cf..803cd6a 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -38,6 +38,7 @@ 'fullDb' => 'full-db', 'cachedFS' => 'cache-fs', 'fullDbDirect' => 'full-db-direct', + 's3' => 's3-storage-v3' } # Check if a value was provided that need to be replaced. @@ -53,7 +54,8 @@ case $_types[$::artifactory::binary_provider_type] { 'file-system', 'full-db', - 'cache-fs': { + 'cache-fs', + 's3': { $binary_provider_type = $_binary_provider_type } 'full-db-direct': { @@ -248,6 +250,7 @@ binary_provider_base_data_dir => $::artifactory::binary_provider_base_data_dir, binary_provider_filesystem_dir => $binary_provider_filesystem_dir, binary_provider_cache_dir => $::artifactory::binary_provider_cache_dir, + binary_provider_config_hash => $::artifactory::binary_provider_config_hash, } ), notify => Class['artifactory::service'], diff --git a/manifests/init.pp b/manifests/init.pp index 92ac5ba..0db55f5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -22,13 +22,14 @@ Optional[String] $db_username = undef, Optional[String] $db_password = undef, Optional[Boolean] $db_automate = false, - Optional[Enum['filesystem', 'fullDb', 'cachedFS', 'fullDbDirect']] $binary_provider_type = undef, + Optional[Enum['filesystem', 'fullDb', 'cachedFS', 'fullDbDirect', 's3']] $binary_provider_type = undef, Optional[Integer] $pool_max_active = undef, Optional[Integer] $pool_max_idle = undef, Optional[Integer] $binary_provider_cache_maxsize = undef, Optional[String] $binary_provider_base_data_dir = undef, Optional[String] $binary_provider_filesystem_dir = undef, Optional[String] $binary_provider_cache_dir = undef, + Optional[Hash] $binary_provider_config_hash = undef, Optional[String] $master_key = undef, Optional[String] $license_key = undef, ) { diff --git a/spec/classes/artifactory_spec.rb b/spec/classes/artifactory_spec.rb index 3226de1..73ed020 100644 --- a/spec/classes/artifactory_spec.rb +++ b/spec/classes/artifactory_spec.rb @@ -241,6 +241,29 @@ is_expected.to contain_file('/var/opt/jfrog/artifactory/etc/artifactory/binarystore.xml').with_content(%r{/opt/artifactory-data/filestore}) } end + + context 'running a current version with s3 storage provider' do + let(:params) do + { + 'package_version' => '7.4.3', + 'binary_provider_type' => 's3', + 'binary_provider_config_hash' => { + 'endpoint' => 's3.amazonaws.com', + 'useInstanceCredentials' => true, + 'bucketName' => 'art-bucket', + 'region' => 'eu-central-1', + } + } + 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{art-bucket}) + is_expected.to contain_file('/var/opt/jfrog/artifactory/etc/artifactory/binarystore.xml').with_content(%r{true}) + } + end + end end end diff --git a/templates/binarystore.xml.epp b/templates/binarystore.xml.epp index a2401a2..39db7e7 100644 --- a/templates/binarystore.xml.epp +++ b/templates/binarystore.xml.epp @@ -2,7 +2,8 @@ Optional[Integer] $binary_provider_cache_maxsize = undef, Optional[String] $binary_provider_base_data_dir = undef, Optional[String] $binary_provider_filesystem_dir = undef, - Optional[String] $binary_provider_cache_dir = undef + Optional[String] $binary_provider_cache_dir = undef, + Optional[Hash] $binary_provider_config_hash = undef | -%>