Class: Kite::Module
Instance Method Summary
collapse
Methods included from Helpers
#check_cloud_config, #cloud_path, #cloud_valid?, #parse_cloud_config, #run!
Methods inherited from Base
exit_on_failure?, source_root
Instance Method Details
#fetch(path) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/kite/module.rb', line 18
def fetch(path)
@env = options[:env]
@module_name = path.gsub(/(.*:|.git)/, '').split('/').last
@module_path = "modules/#{ @module_name }"
if File.exist?(@module_path)
overwrite = ask "#{ @module_path } already exists! Overwrite? (y/N)"
if overwrite.downcase == 'y'
say "Remove existing files"
run! "git rm -f #{ @module_path }"
remove_dir(".git/modules/#{ @module_path }")
else
say "Skipping module init"
return
end
end
case options[:method]
when"submodule"
clone_module(path, @module_path, options[:version])
when "copy"
FileUtils.mkdir_p("modules")
FileUtils.cp_r(path, @module_path)
else
raise "Unsupported method #{ method }"
end
end
|
#init(path) ⇒ Object
9
10
11
|
# File 'lib/kite/module.rb', line 9
def init(path)
say "Kite module init is deprecated. Use kite module fetch and kite module vars instead", :yellow
end
|
#render(path) ⇒ Object
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/kite/module.rb', line 60
def render(path)
@path = File.expand_path(path)
@name = @path.split('/').last
@env = options[:env]
@vars = load_vars
@cloud = parse_cloud_config(@env)
say "Rendering files"
render_templates
end
|
#vars(path) ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'lib/kite/module.rb', line 48
def vars(path)
@env = options[:env]
@module_name = path.gsub(/(.*:|.git)/, '').split('/').last
@module_path = "modules/#{ @module_name }"
@cloud = parse_cloud_config(@env)
vars_output = render_vars(@module_name, @module_path)
say "Rendered successfully #{ vars_output }, please edit this file with correct values", :green
end
|