kafo 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e97bd2473d708bd19a6a85e1e4e861420697f58
|
4
|
+
data.tar.gz: c3d5788d32f73a7801f0474338c6916f5ac1c354
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3030707d7cec780ab60a04f7b08c50ec3ae481792ff091d96ab1f823561320ccf8100064aba7583cc561966ea91f0c62dd7c3ccc8cf484aedcfe6f21d7b5695
|
7
|
+
data.tar.gz: 841dc1c57a6332259e51e9e63e5ff065f5159b77416b6264d54b36381177a96e4f76bc9e7102ce9a7f673c8db387c96e0d83b43e32a39828f0b84dd43a9bf1b1
|
data/lib/kafo/configuration.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
require 'yaml'
|
3
|
+
require 'tmpdir'
|
3
4
|
require 'kafo/puppet_module'
|
4
5
|
require 'kafo/password_manager'
|
5
6
|
|
@@ -76,8 +77,11 @@ module Kafo
|
|
76
77
|
|
77
78
|
def params_default_values
|
78
79
|
@params_default_values ||= begin
|
80
|
+
@logger.debug "Creating tmp dir within #{app[:default_values_dir]}..."
|
81
|
+
temp_dir = Dir.mktmpdir(nil, app[:default_values_dir])
|
82
|
+
KafoConfigure.register_cleanup_path temp_dir
|
79
83
|
@logger.info "Parsing default values from puppet modules..."
|
80
|
-
command = PuppetCommand.new("#{includes} dump_values(#{params})").append('2>&1').command
|
84
|
+
command = PuppetCommand.new("$temp_dir=\"#{temp_dir}\" #{includes} dump_values(#{params})").append('2>&1').command
|
81
85
|
@logger.debug `#{command}`
|
82
86
|
unless $?.exitstatus == 0
|
83
87
|
log = app[:log_dir] + '/' + app[:log_name]
|
@@ -86,7 +90,7 @@ module Kafo
|
|
86
90
|
KafoConfigure.exit(:defaults_error)
|
87
91
|
end
|
88
92
|
@logger.info "... finished"
|
89
|
-
YAML.load_file(File.join(
|
93
|
+
YAML.load_file(File.join(temp_dir, 'default_values.yaml'))
|
90
94
|
end
|
91
95
|
end
|
92
96
|
|
data/lib/kafo/kafo_configure.rb
CHANGED
@@ -25,12 +25,15 @@ module Kafo
|
|
25
25
|
class KafoConfigure < Clamp::Command
|
26
26
|
include StringHelper
|
27
27
|
|
28
|
-
|
29
28
|
class << self
|
30
29
|
attr_accessor :config, :root_dir, :config_file, :gem_root, :temp_config_file,
|
31
30
|
:modules_dir, :kafo_modules_dir, :verbose, :app_options, :logger
|
32
31
|
attr_writer :hooking
|
33
32
|
|
33
|
+
def cleanup_paths
|
34
|
+
@cleanup_paths ||= []
|
35
|
+
end
|
36
|
+
|
34
37
|
def hooking
|
35
38
|
@hooking ||= Hooking.new
|
36
39
|
end
|
@@ -121,6 +124,7 @@ module Kafo
|
|
121
124
|
end
|
122
125
|
|
123
126
|
def self.exit(code)
|
127
|
+
cleanup
|
124
128
|
@exit_code = translate_exit_code(code)
|
125
129
|
throw :exit
|
126
130
|
end
|
@@ -144,6 +148,26 @@ module Kafo
|
|
144
148
|
end
|
145
149
|
end
|
146
150
|
|
151
|
+
def self.cleanup
|
152
|
+
# make sure default values are removed from /tmp
|
153
|
+
(self.cleanup_paths + ['/tmp/default_values.yaml']).each do |file|
|
154
|
+
logger.debug "Cleaning #{file}"
|
155
|
+
FileUtils.rm_rf(file)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def self.register_cleanup_path(path)
|
160
|
+
self.cleanup_paths<< path
|
161
|
+
end
|
162
|
+
|
163
|
+
def register_cleanup_path(path)
|
164
|
+
self.class.register_cleanup_path(path)
|
165
|
+
end
|
166
|
+
|
167
|
+
def cleanup_paths
|
168
|
+
self.class.cleanup_paths
|
169
|
+
end
|
170
|
+
|
147
171
|
def help
|
148
172
|
self.class.help(invocation_path, self)
|
149
173
|
end
|
data/lib/kafo/version.rb
CHANGED
@@ -9,7 +9,10 @@ module Puppet::Parser::Functions
|
|
9
9
|
[arg, found_value.nil? ? arg : found_value]
|
10
10
|
end
|
11
11
|
data = Hash[data]
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
dump_dir = lookupvar('temp_dir')
|
14
|
+
file_name = "#{dump_dir}/default_values.yaml"
|
15
|
+
|
16
|
+
File.open(file_name, File::WRONLY|File::CREAT|File::EXCL, 0600) { |file| file.write(YAML.dump(data)) }
|
14
17
|
end
|
15
18
|
end
|