summaryrefslogtreecommitdiff
path: root/lib/leap_cli/config/manager.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2012-11-15 01:54:31 -0800
committerelijah <elijah@riseup.net>2012-11-15 01:54:31 -0800
commit088b4f047f3d4b8e075e10277bfe5f94cb0b9af1 (patch)
treeab5debbef5c47c6ec615bb5719bc62f020889e3e /lib/leap_cli/config/manager.rb
parent359c0b757f1dd52b63e08f8b67fa7fe7f1c0ba00 (diff)
auto remove files/nodes/x when nodes/x.json doesn't exist anymore.
Diffstat (limited to 'lib/leap_cli/config/manager.rb')
-rw-r--r--lib/leap_cli/config/manager.rb20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/leap_cli/config/manager.rb b/lib/leap_cli/config/manager.rb
index e90b589..3d09e09 100644
--- a/lib/leap_cli/config/manager.rb
+++ b/lib/leap_cli/config/manager.rb
@@ -53,18 +53,24 @@ module LeapCli
#
# save compiled hiera .yaml files
#
- def export_nodes(destination_directory = nil)
- dir = destination_directory || Path.named_path(:hiera_dir, @provider_dir)
- existing_files = Dir.glob(dir + '/*.yaml')
+ def export_nodes
+ existing_hiera = Dir.glob(Path.named_path([:hiera, '*'], @provider_dir))
+ existing_files = Dir.glob(Path.named_path([:node_files_dir, '*'], @provider_dir))
+ updated_hiera = []
updated_files = []
- @nodes.each do |name, node|
- filepath = "#{dir}/#{name}.yaml"
+ self.each_node do |node|
+ filepath = Path.named_path([:node_files_dir, node.name], @provider_dir)
updated_files << filepath
- Util::write_file!(filepath, node.dump)
+ hierapath = Path.named_path([:hiera, node.name], @provider_dir)
+ updated_hiera << hierapath
+ Util::write_file!(hierapath, node.dump)
end
- (existing_files - updated_files).each do |filepath|
+ (existing_hiera - updated_hiera).each do |filepath|
Util::remove_file!(filepath)
end
+ (existing_files - updated_files).each do |filepath|
+ Util::remove_directory!(filepath)
+ end
end
def export_secrets(destination_file = nil)