Class: Fhcap::Tasks::Chef::Cookbook::UpdateConfig
- Inherits:
-
Fhcap::Tasks::Chef::ChefTaskBase
- Object
- TaskBase
- Fhcap::Tasks::Chef::ChefTaskBase
- Fhcap::Tasks::Chef::Cookbook::UpdateConfig
- Defined in:
- lib/fhcap/tasks/chef/cookbook/update_config.rb
Constant Summary collapse
- COMP_CFG_MAP =
{ "fh-aaa" => "fh-aaa/config/dev.json", "millicore" => "millicore/src/main/resources/config/cluster-config.properties", "fh-reaper" => "millicore/src/main/resources/config/reaper.properties", "fh-supercore" => "fh-supercore/config/dev.json", "fh-docs" => ["fh-docs/config/development.json", "fh-docs/config/config.json"], "fh-doxy" => "fh-doxy/config/dev.json", "fh-messaging" => "fh-messaging/fh-messaging/config/dev.json", "fh-metrics" => "fh-messaging/fh-metrics/config/dev.json", "fh-ditch" => "fh-ditch/config/dev.json", "fh-scm" => "fh-scm/config/dev.json", "fh-stats" => "fh-stats/fh-statsd/config/dev.json", "fh-dynoman" => "fh-dynoman/config/dev.json", "fh-proxy" => "fh-proxy/config/dev.json", "fh-ngui" => "fh-ngui/config/dev.json", "fh-appstore" => "fh-appstore/config/dev.json", "fh-digger" => "fh-digger/config/dev.json", "fh-mbaas" => "fh-mbaas/config/dev.json", }
Instance Attribute Summary collapse
-
#force ⇒ Object
readonly
Returns the value of attribute force.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#overrides ⇒ Object
readonly
Returns the value of attribute overrides.
-
#sort ⇒ Object
readonly
Returns the value of attribute sort.
Attributes inherited from TaskBase
#config, #options, #thor, #verbose
Instance Method Summary collapse
-
#initialize(options) ⇒ UpdateConfig
constructor
A new instance of UpdateConfig.
- #run ⇒ Object
Methods inherited from Fhcap::Tasks::Chef::ChefTaskBase
#knife_config_dir, #knife_config_file_for, #run_chef_client_cmd, #run_knife_cmd, #run_knife_ssh_cmd
Methods inherited from TaskBase
#ask_config, #color_pad, #exit_with_error, #set_color, #suppress_stdout, #table_header, #table_row, #with_progress
Methods included from KnifeHelper
#chef_server_config_for, #chef_server_config_hash_for, #chef_server_names, #knife_config, #knife_config_dir, #knife_config_file_for
Methods included from ProvidersHelper
#provider_availability_zones, #provider_config, #provider_credentials, #provider_for, #provider_names, #provider_names_for, #provider_regions, #provider_type, #providers_config
Methods included from ReposHelper
#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_entry_dependencies, #get_modified_cookbooks, #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
Methods included from FhcapHelper
Constructor Details
#initialize(options) ⇒ UpdateConfig
Returns a new instance of UpdateConfig.
33 34 35 36 37 38 39 |
# File 'lib/fhcap/tasks/chef/cookbook/update_config.rb', line 33 def initialize() super @name = [:cookbook] @overrides = [:overrides] || [] @sort = [:sort] || true @force = [:force] || false end |
Instance Attribute Details
#force ⇒ Object (readonly)
Returns the value of attribute force.
31 32 33 |
# File 'lib/fhcap/tasks/chef/cookbook/update_config.rb', line 31 def force @force end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
31 32 33 |
# File 'lib/fhcap/tasks/chef/cookbook/update_config.rb', line 31 def name @name end |
#overrides ⇒ Object (readonly)
Returns the value of attribute overrides.
31 32 33 |
# File 'lib/fhcap/tasks/chef/cookbook/update_config.rb', line 31 def overrides @overrides end |
#sort ⇒ Object (readonly)
Returns the value of attribute sort.
31 32 33 |
# File 'lib/fhcap/tasks/chef/cookbook/update_config.rb', line 31 def sort @sort end |
Instance Method Details
#run ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/fhcap/tasks/chef/cookbook/update_config.rb', line 41 def run thor.say "Chef::Cookbook::UpdateConfig cookbook = #{name}", :yellow cookbook = cookbook_loader.cookbooks_by_name[name] conf_attr_file = cookbook.attribute_filenames.find { |e| /conf.rb/ =~ e } unless conf_attr_file return thor.say "No cookbook conf.rb attribute file found for #{name}, skipping config update" end conf_src_files = cfg_lookup(name) exit_with_error("No local src config file found for #{name}") if conf_src_files.empty? thor.say "conf_attr_file = #{conf_attr_file}" thor.say "conf_src_files = #{conf_src_files}" conf_src_files.each() do |file| if File.exists? file if File.extname(file) =~ /.properties/ cfg = Fhcap::JavaConfig.new else cfg = Fhcap::JsonConfig.new end cfg.from_attributes_file(name, conf_attr_file) cfg.from_file(file, force, overrides) thor.create_file(conf_attr_file, cfg.attribute_file_content(name, sort)) else thor.say "Missing local file '#{file}', skipping config update" end end end |