diff --git a/manifests/archive.pp b/manifests/archive.pp index 599a5b3..2242b39 100644 --- a/manifests/archive.pp +++ b/manifests/archive.pp @@ -47,12 +47,10 @@ # Defaults to ['list', 'show-rc'] # @param keep_last # number of last archives to keep -# Set to '' if this option should not be added -# Defaults to '' +# Defaults to undef # @param keep_hourly # number of hourly archives to keep -# Set to '' if this option should not be added -# Defaults to '' +# Defaults to undef # @param keep_daily # number of daily archives to keep # Set to '' if this option should not be added @@ -67,28 +65,27 @@ # Defaults to 6 # @param keep_yearly # number of yearly archives to keep -# Set to '' if this option should not be added -# Defaults to '' +# Defaults to undef (no yearly is kept) # define borgbackup::archive ( - String $reponame = $facts['networking']['fqdn'], - String $archive_name = $title, - Array $pre_commands = [], - Array $post_commands = [], - String $create_compression = 'lz4', - String $create_filter = 'AME', - Array $create_options = ['verbose', 'list', 'stats', 'show-rc', 'exclude-caches'], - Array $create_excludes = [], - Array $create_includes = [], - Optional[String[1]] $stdin_cmd = undef, - Boolean $do_prune = true, - Array $prune_options = ['list', 'show-rc'], - Variant[String, Integer] $keep_last = '', - Variant[String, Integer] $keep_hourly = '', - Variant[String, Integer] $keep_daily = 7, - Variant[String, Integer] $keep_weekly = 4, - Variant[String, Integer] $keep_monthly = 6, - Variant[String, Integer] $keep_yearly = '', + String $reponame = $facts['networking']['fqdn'], + String $archive_name = $title, + Array $pre_commands = [], + Array $post_commands = [], + String $create_compression = 'lz4', + String $create_filter = 'AME', + Array $create_options = ['verbose', 'list', 'stats', 'show-rc', 'exclude-caches'], + Array $create_excludes = [], + Array $create_includes = [], + Optional[String[1]] $stdin_cmd = undef, + Boolean $do_prune = true, + Array $prune_options = ['list', 'show-rc'], + Optional[Variant[String[1], Integer]] $keep_last = undef, + Optional[Variant[String[1], Integer]] $keep_hourly = undef, + Variant[String, Integer] $keep_daily = 7, + Variant[String, Integer] $keep_weekly = 4, + Variant[String, Integer] $keep_monthly = 6, + Optional[Variant[String[1], Integer]] $keep_yearly = undef, ) { if ( ! $stdin_cmd and $create_includes != []) or ( ! $stdin_cmd and $create_excludes != []) { fail('borgbackup::archive $stdin_cmd cannot be used together with $create_includes or $create_exclude') diff --git a/spec/defines/archive_spec.rb b/spec/defines/archive_spec.rb index e43ab28..b4b58da 100644 --- a/spec/defines/archive_spec.rb +++ b/spec/defines/archive_spec.rb @@ -14,12 +14,9 @@ create_includes: [], do_prune: true, prune_options: ['list', 'show-rc'], - keep_last: '', - keep_hourly: '', keep_daily: 7, keep_weekly: 4, - keep_monthly: 6, - keep_yearly: '' } + keep_monthly: 6, } end shared_examples 'borgbackup::archive shared examples' do diff --git a/templates/archive_prune.erb b/templates/archive_prune.erb index 46b4291..9a12784 100644 --- a/templates/archive_prune.erb +++ b/templates/archive_prune.erb @@ -10,10 +10,10 @@ borg prune \ <% @prune_options.each do |opt| -%> --<%= opt -%> \ <% end -%> -<% if @keep_last != '' -%> +<% if @keep_last -%> --keep-last <%= @keep_last %> \ <% end -%> -<% if @keep_hourly != '' -%> +<% if @keep_hourly -%> --keep-hourly <%= @keep_hourly %> \ <% end -%> <% if @keep_daily != '' -%> @@ -25,7 +25,7 @@ borg prune \ <% if @keep_monthly != '' -%> --keep-monthly <%= @keep_monthly %> \ <% end -%> -<% if @keep_yearly != '' -%> +<% if @keep_yearly -%> --keep-yearly <%= @keep_yearly %> \ <% end -%>