aboutsummaryrefslogtreecommitdiff
path: root/lib/leap_cli/config/manager.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2012-10-14 03:02:06 -0700
committerelijah <elijah@riseup.net>2012-10-14 03:02:06 -0700
commitc6d2272ddb370b9731e17b06fa08971e6cda5202 (patch)
tree492931f6b62088062ae070814ec714bcbd1f0707 /lib/leap_cli/config/manager.rb
parentcde5fc17fe235405703c67184c81d85643b257a2 (diff)
downloadleap_cli-c6d2272ddb370b9731e17b06fa08971e6cda5202.tar.gz
leap_cli-c6d2272ddb370b9731e17b06fa08971e6cda5202.tar.bz2
added add-user command
Diffstat (limited to 'lib/leap_cli/config/manager.rb')
-rw-r--r--lib/leap_cli/config/manager.rb18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/leap_cli/config/manager.rb b/lib/leap_cli/config/manager.rb
index 55575cf..b35251a 100644
--- a/lib/leap_cli/config/manager.rb
+++ b/lib/leap_cli/config/manager.rb
@@ -3,6 +3,7 @@ require 'yaml'
module LeapCli
module Config
+
#
# A class to manage all the objects in all the configuration files.
#
@@ -32,15 +33,16 @@ module LeapCli
# save compiled hiera .yaml files
#
def export(dir)
- Dir.glob(dir + '/*.yaml').each do |f|
- File.unlink(f)
- end
+ existing_files = Dir.glob(dir + '/*.yaml')
+ updated_files = []
@nodes.each do |name, node|
# not sure if people will approve of this change:
- # File.open("#{dir}/#{name}.#{node.domain_internal}.yaml", 'w') do |f|
- File.open("#{dir}/#{name}.yaml", 'w') do |f|
- f.write node.to_yaml
- end
+ filepath = "#{dir}/#{name}.yaml"
+ updated_files << filepath
+ Util::write_file!(filepath, node.to_yaml)
+ end
+ (existing_files - updated_files).each do |filepath|
+ Util::remove_file!(filepath)
end
end
@@ -99,7 +101,7 @@ module LeapCli
end
def load_json(filename, config_type)
- log2 { filename.sub(/^#{Regexp.escape(Path.root)}/,'') }
+ #log2 { filename.sub(/^#{Regexp.escape(Path.root)}/,'') }
#
# read file, strip out comments