Class: SimplyGenius::Atmos::Config
- Inherits:
-
Object
- Object
- SimplyGenius::Atmos::Config
- Includes:
- FileUtils, GemLogger::LoggerSupport
- Defined in:
- lib/simplygenius/atmos/config.rb
Instance Attribute Summary collapse
-
#atmos_env ⇒ Object
Returns the value of attribute atmos_env.
-
#config_file ⇒ Object
Returns the value of attribute config_file.
-
#root_dir ⇒ Object
Returns the value of attribute root_dir.
-
#tmp_root ⇒ Object
Returns the value of attribute tmp_root.
-
#working_group ⇒ Object
Returns the value of attribute working_group.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #account_hash ⇒ Object
- #add_user_load_path(*paths) ⇒ Object
- #all_env_names ⇒ Object
- #auth_cache_dir ⇒ Object
-
#initialize(atmos_env, working_group = 'default') ⇒ Config
constructor
A new instance of Config.
- #is_atmos_repo? ⇒ Boolean
- #plugin_manager ⇒ Object
- #provider ⇒ Object
- #tf_working_dir ⇒ Object
- #tmp_dir ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(atmos_env, working_group = 'default') ⇒ Config
Returns a new instance of Config.
21 22 23 24 25 26 27 28 |
# File 'lib/simplygenius/atmos/config.rb', line 21 def initialize(atmos_env, working_group = 'default') @atmos_env = atmos_env @working_group = working_group @root_dir = File.(Dir.pwd) @config_file = File.join(root_dir, "config", "atmos.yml") @tmp_root = File.join(root_dir, "tmp") @included_configs = [] end |
Instance Attribute Details
#atmos_env ⇒ Object
Returns the value of attribute atmos_env.
16 17 18 |
# File 'lib/simplygenius/atmos/config.rb', line 16 def atmos_env @atmos_env end |
#config_file ⇒ Object
Returns the value of attribute config_file.
16 17 18 |
# File 'lib/simplygenius/atmos/config.rb', line 16 def config_file @config_file end |
#root_dir ⇒ Object
Returns the value of attribute root_dir.
16 17 18 |
# File 'lib/simplygenius/atmos/config.rb', line 16 def root_dir @root_dir end |
#tmp_root ⇒ Object
Returns the value of attribute tmp_root.
16 17 18 |
# File 'lib/simplygenius/atmos/config.rb', line 16 def tmp_root @tmp_root end |
#working_group ⇒ Object
Returns the value of attribute working_group.
16 17 18 |
# File 'lib/simplygenius/atmos/config.rb', line 16 def working_group @working_group end |
Instance Method Details
#[](key) ⇒ Object
34 35 36 37 38 |
# File 'lib/simplygenius/atmos/config.rb', line 34 def [](key) load result = @config.notation_get(key) return result end |
#account_hash ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/simplygenius/atmos/config.rb', line 58 def account_hash load environments = @full_config[:environments] || {} environments.inject(Hash.new) do |accum, entry| accum[entry.first] = entry.last[:account_id] accum end end |
#add_user_load_path(*paths) ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/simplygenius/atmos/config.rb', line 94 def add_user_load_path(*paths) load_path = paths + Array(self["atmos.load_path"]) if load_path.present? load_path = load_path.collect { |path| File.(path) } logger.debug("Adding to load path: #{load_path.inspect}") $LOAD_PATH.insert(0, *load_path) end end |
#all_env_names ⇒ Object
53 54 55 56 |
# File 'lib/simplygenius/atmos/config.rb', line 53 def all_env_names load @full_config[:environments].keys end |
#auth_cache_dir ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/simplygenius/atmos/config.rb', line 76 def auth_cache_dir @auth_cache_dir ||= begin dir = File.join(tmp_dir, 'auth') logger.debug("Auth cache dir: #{dir}") mkdir_p(dir) dir end end |
#is_atmos_repo? ⇒ Boolean
30 31 32 |
# File 'lib/simplygenius/atmos/config.rb', line 30 def is_atmos_repo? File.exist?(config_file) end |
#plugin_manager ⇒ Object
49 50 51 |
# File 'lib/simplygenius/atmos/config.rb', line 49 def plugin_manager @plugin_manager ||= PluginManager.new(self["atmos.plugins"]) end |
#provider ⇒ Object
45 46 47 |
# File 'lib/simplygenius/atmos/config.rb', line 45 def provider @provider ||= ProviderFactory.get(self[:provider]) end |
#tf_working_dir ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/simplygenius/atmos/config.rb', line 85 def tf_working_dir @tf_working_dir ||= begin dir = File.join(tmp_dir, 'tf', working_group) logger.debug("Terraform working dir: #{dir}") mkdir_p(dir) dir end end |
#tmp_dir ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/simplygenius/atmos/config.rb', line 67 def tmp_dir @tmp_dir ||= begin dir = File.join(tmp_root, atmos_env) logger.debug("Tmp dir: #{dir}") mkdir_p(dir) dir end end |
#to_h ⇒ Object
40 41 42 43 |
# File 'lib/simplygenius/atmos/config.rb', line 40 def to_h load @config.to_hash end |