Skip to content

Commit

Permalink
use undef instead of '' for borgbackup::archive::stdin_cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
trefzer committed Dec 7, 2024
1 parent 3bc9866 commit 236d193
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions manifests/archive.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# needs to be [] if stdin_cmd is used.
# @param stdin_cmd
# command which is executed, stdout is used as
# input to backup. defaults to ''
# input to backup. defaults to undef
# do not use together with $create_excludes and $create_includes
# @param do_prune
# if true, prune will be run after the create command.
Expand Down Expand Up @@ -80,7 +80,7 @@
Array $create_options = ['verbose', 'list', 'stats', 'show-rc', 'exclude-caches'],
Array $create_excludes = [],
Array $create_includes = [],
String $stdin_cmd = '',
Optional[String[1]] $stdin_cmd = undef,
Boolean $do_prune = true,
Array $prune_options = ['list', 'show-rc'],
Variant[String, Integer] $keep_last = '',
Expand All @@ -90,7 +90,7 @@
Variant[String, Integer] $keep_monthly = 6,
Variant[String, Integer] $keep_yearly = '',
) {
if ($stdin_cmd != '' and $create_includes != []) or ($stdin_cmd != '' and $create_excludes != []) {
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')
}

Expand Down
1 change: 0 additions & 1 deletion spec/defines/archive_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
create_options: ['verbose', 'list', 'stats', 'show-rc', 'exclude-caches'],
create_excludes: [],
create_includes: [],
stdin_cmd: '',
do_prune: true,
prune_options: ['list', 'show-rc'],
keep_last: '',
Expand Down
4 changes: 2 additions & 2 deletions templates/archive_create.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Backup the most important directories into an archive named after
# the machine this script is currently running on:
<% if @stdin_cmd != '' -%>
<% if @stdin_cmd -%>
<%= @stdin_cmd %> | \
<% end -%>
borg create \
Expand All @@ -27,7 +27,7 @@ borg create \
<% @create_includes.each do | include | -%>
<%= include -%> \
<% end -%>
<% if @stdin_cmd != '' -%>
<% if ! @stdin_cmd -%>
-
<% end -%>

Expand Down

0 comments on commit 236d193

Please sign in to comment.