Class: Fhcap::ThorBase
Constant Summary
collapse
- @@shared_options =
{}
- @@fhcap_config =
Fhcap::Config.new(
:config_file => ENV['FHCAP_CFG_FILE']
)
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#find_cluster, #find_cluster_pwds, #find_cluster_pwds_with_repo, #find_cluster_with_repo, #find_data_bag, #find_data_bag_item, #find_environment, #find_repo_item, #find_role, #get_cookbook_deps, #get_cookbook_meta, #get_cookbook_versions, #get_cookbooks, #get_dirty_cookbooks, #get_entry_dependencies, #get_modified_cookbooks, #git_diff, #is_dirty?, #modified?, #repo_cfg, #repo_clusters_dir, #repo_cookbook_paths, #repo_dir, #repo_names, #repo_paths, #repos_config, #repos_dir, #run_inside_repo_dir
#provider_availability_zones, #provider_config, #provider_credentials, #provider_for, #provider_names, #provider_names_for, #provider_regions, #provider_type, #providers_config
#run
Constructor Details
#initialize(*args) ⇒ ThorBase
Returns a new instance of ThorBase.
95
96
97
98
99
100
101
102
103
|
# File 'lib/fhcap/thor_base.rb', line 95
def initialize(*args)
super
self.class.source_root(Fhcap.source_root)
@config = Fhcap::Config.new(
:config_file => ENV['FHCAP_CFG_FILE']
)
@thor = self
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
12
13
14
|
# File 'lib/fhcap/thor_base.rb', line 12
def config
@config
end
|
#thor ⇒ Object
Returns the value of attribute thor.
12
13
14
|
# File 'lib/fhcap/thor_base.rb', line 12
def thor
@thor
end
|
Class Method Details
.add_shared_option(name, options = {}) ⇒ Object
24
25
26
|
# File 'lib/fhcap/thor_base.rb', line 24
def add_shared_option(name, options = {})
@@shared_options[name] = options
end
|
.chef_server_names ⇒ Object
68
69
70
|
# File 'lib/fhcap/thor_base.rb', line 68
def chef_server_names
config_key_collection(:knife)
end
|
.cluster_template_names ⇒ Object
76
77
78
|
# File 'lib/fhcap/thor_base.rb', line 76
def cluster_template_names
Fhcap::TEMPLATE_NAMES
end
|
.config_key_collection(name) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/fhcap/thor_base.rb', line 36
def config_key_collection(name)
if @@fhcap_config.exists? && @@fhcap_config[name.to_sym]
@@fhcap_config[name.to_sym].collect do |key, val|
if block_given?
yield key.to_s, val
else
key.to_s
end
end
else
[]
end
end
|
.exit_on_failure? ⇒ Boolean
20
21
22
|
# File 'lib/fhcap/thor_base.rb', line 20
def exit_on_failure?
true
end
|
.provider_names ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/fhcap/thor_base.rb', line 50
def provider_names
config_key_collection(:providers) do |provider, cfg|
cfg.collect do |id, pcfg|
"#{provider}:#{id}"
end
end.flatten
end
|
.provider_names_for(service) ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/fhcap/thor_base.rb', line 58
def provider_names_for(service)
config_key_collection(:providers) do |provider, cfg|
cfg.reject do |id, pcfg|
!pcfg[:provides] || !pcfg[:provides].include?(service)
end.collect do |id, pcfg|
"#{provider}:#{id}"
end
end.flatten
end
|
.repo_names ⇒ Object
72
73
74
|
# File 'lib/fhcap/thor_base.rb', line 72
def repo_names
config_key_collection(:repos)
end
|
.run_cmd(cmd, options) ⇒ Object
85
86
87
|
# File 'lib/fhcap/thor_base.rb', line 85
def run_cmd(cmd, options)
run(cmd)
end
|
.run_knife_cmd(cmd, options) ⇒ Object
80
81
82
83
|
# File 'lib/fhcap/thor_base.rb', line 80
def run_knife_cmd(cmd, options)
cmd = (['knife', cmd]).join(' ')
run_cmd(cmd, options)
end
|
.shared_options(*option_names) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/fhcap/thor_base.rb', line 28
def shared_options(*option_names)
option_names.each do |option_name|
opt = @@shared_options[option_name]
raise "Tried to access shared option '#{option_name}' but it was not previously defined" if opt.nil?
option option_name, opt
end
end
|