11
12
13
14
15
16
17
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
45
|
# File 'lib/charmkit/cli.rb', line 11
def generate(name)
pn = Pathname(name)
if pn.directory?
puts "#{name} directory exists, please choose a different charm name."
exit 1
else
pn.mkpath
pn.join('hooks').mkpath
end
Helpers.inline_template 'config.yaml', pn/'config.yaml'
Helpers.inline_template 'metadata.yaml', pn/'metadata.yaml', name: name
Helpers.inline_template 'README.md', pn/'README.md', name: name
Helpers.inline_template 'Gemfile', pn/'Gemfile'
hook_path = pn.join('hooks/install')
Helpers.inline_template 'install-hook', hook_path
hook_path.chmod 0755
hooks = ['config-changed',
'upgrade-charm',
'start',
'stop',
'leader-elected',
'leader-settings-changed',
'update-status']
hooks.each do |hook|
hook_path = pn.join("hooks/#{hook}")
Helpers.inline_template 'generic-hook', hook_path, hook: hook.underscore
hook_path.chmod 0755
end
Helpers.inline_template 'Rakefile', pn/'Rakefile'
end
|