Class: Fhcap::Tasks::Chef::Cookbook::UpdateConfig

Inherits:
Fhcap::Tasks::Chef::ChefTaskBase show all
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/conf.json",
    "fh-metrics" => "fh-messaging/fh-metrics/config/conf.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

Attributes inherited from TaskBase

#config, #options, #thor, #verbose

Instance Method Summary collapse

Methods inherited from Fhcap::Tasks::Chef::ChefTaskBase

#chef_server_environments, #chef_servers_for_environment, #knife_config_dir, #knife_config_file_for, #run_chef_client_cmd, #run_knife_cmd, #run_knife_ssh_cmd, #select_chef_server

Methods inherited from TaskBase

#ask_config, #color_pad, #exit_with_error, #set_color, #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

#cluster_template_names

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(options)
  super
  @name = options[:cookbook]
  @overrides = options[:overrides] || []
  @sort = options[:sort] || true
  @force = options[: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
# 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 }
  exit_with_error("No cookbook conf.rb attribute file found for #{name}") unless conf_attr_file

  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.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))
  end

end