Module: Proteus::Helpers::PathHelpers
- Includes:
- Thor::Shell
- Included in:
- Backend::Backend, Common, ContextManagement::Context, ContextManagement::Helpers, Proteus::Helpers, Modules::Manager, Modules::TerraformModule, Modules::TerraformModule, Templates::Partial, Templates::TemplateBinding
- Defined in:
- lib/proteus/helpers/path_helpers.rb
Instance Method Summary collapse
- #config_dir ⇒ Object
- #config_path ⇒ Object
- #context_path(context) ⇒ Object (also: #context_root_path)
- #context_temp_directory(context) ⇒ Object
- #contexts_path ⇒ Object
- #environments_path(context) ⇒ Object
- #module_config_path(context, module_name) ⇒ Object
- #module_data_path(context, module_name) ⇒ Object
- #module_hooks_path(context, module_name) ⇒ Object
- #module_io_file(context, module_name) ⇒ Object
- #module_path(context, module_name) ⇒ Object
- #module_templates_path(context, module_name) ⇒ Object
- #modules_path(context) ⇒ Object
- #plan_file(context, environment) ⇒ Object
- #root_path ⇒ Object
- #state_file(context, environment) ⇒ Object
- #var_file(context, environment) ⇒ Object
Instance Method Details
#config_dir ⇒ Object
26 27 28 |
# File 'lib/proteus/helpers/path_helpers.rb', line 26 def config_dir File.join(root_path, 'config') end |
#config_path ⇒ Object
30 31 32 |
# File 'lib/proteus/helpers/path_helpers.rb', line 30 def config_path File.join(config_dir, 'config.yaml') end |
#context_path(context) ⇒ Object Also known as: context_root_path
38 39 40 |
# File 'lib/proteus/helpers/path_helpers.rb', line 38 def context_path(context) File.join(contexts_path, context) end |
#context_temp_directory(context) ⇒ Object
42 43 44 |
# File 'lib/proteus/helpers/path_helpers.rb', line 42 def context_temp_directory(context) File.join(context_path(context), '.tmp') end |
#contexts_path ⇒ Object
34 35 36 |
# File 'lib/proteus/helpers/path_helpers.rb', line 34 def contexts_path File.join(root_path, 'contexts') end |
#environments_path(context) ⇒ Object
48 49 50 |
# File 'lib/proteus/helpers/path_helpers.rb', line 48 def environments_path(context) File.join(context_path(context), 'environments') end |
#module_config_path(context, module_name) ⇒ Object
73 74 75 |
# File 'lib/proteus/helpers/path_helpers.rb', line 73 def module_config_path(context, module_name) File.join(module_path(context, module_name), 'config') end |
#module_data_path(context, module_name) ⇒ Object
89 90 91 |
# File 'lib/proteus/helpers/path_helpers.rb', line 89 def module_data_path(context, module_name) File.join(module_config_path(context, module_name), 'data') end |
#module_hooks_path(context, module_name) ⇒ Object
85 86 87 |
# File 'lib/proteus/helpers/path_helpers.rb', line 85 def module_hooks_path(context, module_name) File.join(module_config_path(context, module_name), 'hooks') end |
#module_io_file(context, module_name) ⇒ Object
81 82 83 |
# File 'lib/proteus/helpers/path_helpers.rb', line 81 def module_io_file(context, module_name) File.read(File.join(module_path(context, module_name), 'io.tf')) end |
#module_path(context, module_name) ⇒ Object
64 65 66 |
# File 'lib/proteus/helpers/path_helpers.rb', line 64 def module_path(context, module_name) File.join(modules_path(context), module_name) end |
#module_templates_path(context, module_name) ⇒ Object
77 78 79 |
# File 'lib/proteus/helpers/path_helpers.rb', line 77 def module_templates_path(context, module_name) File.join(module_path(context, module_name), 'config', 'templates') end |
#modules_path(context) ⇒ Object
68 69 70 |
# File 'lib/proteus/helpers/path_helpers.rb', line 68 def modules_path(context) File.join(context_path(context), 'modules') end |
#plan_file(context, environment) ⇒ Object
56 57 58 |
# File 'lib/proteus/helpers/path_helpers.rb', line 56 def plan_file(context, environment) File.join(context_temp_directory(context), "terraform.#{environment}.tfplan") end |
#root_path ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/proteus/helpers/path_helpers.rb', line 6 def root_path if ARGV.size == 1 && ARGV[0] == 'init' return Dir.pwd end path = ENV['PROTEUS_ROOT'].present? ? ENV['PROTEUS_ROOT'] : Dir.pwd unless File.directory?(File.join(path, 'contexts')) say "Can't find a contexts directory in #{path}. Exiting.", :red exit 1 end unless File.directory?(File.join(path, 'config')) say "Can't find a config directory in #{path}. Exiting.", :red exit 1 end File.(path) end |
#state_file(context, environment) ⇒ Object
60 61 62 |
# File 'lib/proteus/helpers/path_helpers.rb', line 60 def state_file(context, environment) File.join(context_root_path(context), '.terraform', 'terraform.tfstate') end |
#var_file(context, environment) ⇒ Object
52 53 54 |
# File 'lib/proteus/helpers/path_helpers.rb', line 52 def var_file(context, environment) File.join(environments_path(context), "terraform.#{environment}.tfvars") end |