summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorJohn Duarte <john.duarte@puppetlabs.com>2014-05-27 11:04:40 -0700
committerJohn Duarte <john.duarte@puppetlabs.com>2014-05-27 11:15:55 -0700
commitb3b253f2432e5cda15c04b11b89bb3d47e84dc76 (patch)
tree03e346fb18739122d0f2c6e89aadee15d98733fe /Rakefile
parentd98e0083f33f76e1ad13b650df81bdb18e4b59fe (diff)
Add optional keyfile argument to rake tasks
This addition walks over any extra arguments provided to the rake task. If the file is a key file, it is used to set the BEAKER_keyfile ENVIRONMENT variable for beaker-rspec and/or the `--keyfile` command line argument for beaker as needed. Example: BEAKER_setfile=../vcenterhost.cfg rake beaker:rspec:test[foo,pe,'/home/myuser/.ssh/id_rsa-secret']
Diffstat (limited to 'Rakefile')
-rwxr-xr-xRakefile14
1 files changed, 14 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile
index 36a7998..b1e0e14 100755
--- a/Rakefile
+++ b/Rakefile
@@ -43,6 +43,9 @@ task :set_beaker_variables do |t,args|
if ENV['BEAKER_setfile']
@hosts_config = ENV['BEAKER_setfile']
end
+ if File.exists?(check_args_for_keyfile(args.extras))
+ ENV['BEAKER_keyfile'] = check_args_for_keyfile(args.extras)
+ end
end
def build_beaker_command(args)
@@ -60,5 +63,16 @@ def build_beaker_command(args)
if File.exists?("./spec/acceptance/beaker")
cmd << "--tests ./spec/acceptance/beaker"
end
+ if File.exists?(check_args_for_keyfile(args.extras))
+ cmd << "--keyfile #{check_args_for_keyfile(args.extras)}"
+ end
cmd.join(" ")
end
+
+def check_args_for_keyfile(extra_args)
+ keyfile = ''
+ extra_args.each do |a|
+ keyfile = a if (`file -b #{a}`.gsub(/\n/,"").match(/ key/))
+ end
+ return keyfile
+end