summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2015-01-22 14:12:14 -0800
committerelijah <elijah@riseup.net>2015-01-22 14:12:14 -0800
commit0bb30766e6f6fe1832343132b3433533e7b314a0 (patch)
tree587114d6fee2c8f4b74df5d06015397c0d5e3dcd /lib
parent5dbbc5ba6d4e83f11bf4787dc020865001ad8ef4 (diff)
added support for custom tests in files/tests
Diffstat (limited to 'lib')
-rw-r--r--lib/leap_cli/commands/deploy.rb29
-rw-r--r--lib/leap_cli/util.rb44
2 files changed, 49 insertions, 24 deletions
diff --git a/lib/leap_cli/commands/deploy.rb b/lib/leap_cli/commands/deploy.rb
index e413807..dbbaaba 100644
--- a/lib/leap_cli/commands/deploy.rb
+++ b/lib/leap_cli/commands/deploy.rb
@@ -177,17 +177,11 @@ module LeapCli
#
def sync_support_files(ssh)
dest_dir = Leap::Platform.files_dir
- source_files = []
- if Path.defined?(:custom_puppet_dir) && file_exists?(:custom_puppet_dir)
- source_files += [:custom_puppet_dir, :custom_puppet_modules_dir, :custom_puppet_manifests_dir].collect{|path|
- Path.relative_path(path, Path.provider) + '/' # rsync needs trailing slash
- }
- ensure_dir :custom_puppet_modules_dir
- end
+ custom_files = build_custom_file_list
ssh.rsync.update do |server|
node = manager.node(server.host)
files_to_sync = node.file_paths.collect {|path| Path.relative_path(path, Path.provider) }
- files_to_sync += source_files
+ files_to_sync += custom_files
if files_to_sync.any?
ssh.leap.log(files_to_sync.join(', ') + ' -> ' + node.name + ':' + dest_dir)
{
@@ -282,5 +276,24 @@ module LeapCli
tags.join(',')
end
+ #
+ # a provider might have various customization files that should be sync'ed to the server.
+ # this method builds that list of files to sync.
+ #
+ def build_custom_file_list
+ custom_files = []
+ Leap::Platform.paths.keys.grep(/^custom_/).each do |path|
+ if file_exists?(path)
+ relative_path = Path.relative_path(path, Path.provider)
+ if dir_exists?(path)
+ custom_files << relative_path + '/' # rsync needs trailing slash
+ else
+ custom_files << relative_path
+ end
+ end
+ end
+ return custom_files
+ end
+
end
end
diff --git a/lib/leap_cli/util.rb b/lib/leap_cli/util.rb
index ce5471c..9edb150 100644
--- a/lib/leap_cli/util.rb
+++ b/lib/leap_cli/util.rb
@@ -97,6 +97,23 @@ module LeapCli
return output
end
+ def assert_config!(conf_path)
+ value = nil
+ begin
+ value = manager.instance_eval(conf_path)
+ #rescue NoMethodError
+ #rescue NameError
+ ensure
+ assert! !value.nil? && value != "REQUIRED" do
+ log :missing, "required configuration value for #{conf_path}"
+ end
+ end
+ end
+
+ ##
+ ## FILES AND DIRECTORIES
+ ##
+
def assert_files_missing!(*files)
options = files.last.is_a?(Hash) ? files.pop : {}
base = options[:base] || Path.provider
@@ -117,19 +134,6 @@ module LeapCli
end
end
- def assert_config!(conf_path)
- value = nil
- begin
- value = manager.instance_eval(conf_path)
- #rescue NoMethodError
- #rescue NameError
- ensure
- assert! !value.nil? && value != "REQUIRED" do
- log :missing, "required configuration value for #{conf_path}"
- end
- end
- end
-
def assert_files_exist!(*files)
options = files.last.is_a?(Hash) ? files.pop : {}
file_list = files.collect { |file_path|
@@ -149,6 +153,7 @@ module LeapCli
end
end
+ # takes a list of symbolic paths. returns true if all files exist or are directories.
def file_exists?(*files)
files.each do |file_path|
file_path = Path.named_path(file_path)
@@ -159,9 +164,16 @@ module LeapCli
return true
end
- ##
- ## FILES AND DIRECTORIES
- ##
+ # takes a list of symbolic paths. returns true if all are directories.
+ def dir_exists?(*dirs)
+ dirs.each do |dir_path|
+ dir_path = Path.named_path(dir_path)
+ if !Dir.exists?(dir_path)
+ return false
+ end
+ end
+ return true
+ end
#
# creates a directory if it doesn't already exist