Module: Terraspace::Core
Constant Summary collapse
- @@root =
nil
- @@logger =
nil
- @@cloud_warning_shown =
false
- @@buffer =
[]
Instance Method Summary collapse
- #app ⇒ Object
- #buffer ⇒ Object
- #cache_root ⇒ Object
- #cloud? ⇒ Boolean
- #command?(name) ⇒ Boolean
-
#config ⇒ Object
Generally, use the Terraspace.config instead of App.instance.config since it guarantees the load_project_config call.
- #configure(&block) ⇒ Object
- #env ⇒ Object
- #extra ⇒ Object
- #log_root ⇒ Object
- #logger ⇒ Object
-
#logger=(v) ⇒ Object
allow different logger when running up all.
- #pass_file?(path) ⇒ Boolean
- #project ⇒ Object
- #role ⇒ Object
- #root ⇒ Object
- #terraform_bin ⇒ Object
- #tmp_root ⇒ Object
Instance Method Details
#app ⇒ Object
10 11 12 |
# File 'lib/terraspace/core.rb', line 10 def app ENV['TS_APP'] unless ENV['TS_APP'].blank? end |
#buffer ⇒ Object
102 103 104 |
# File 'lib/terraspace/core.rb', line 102 def buffer @@buffer end |
#cache_root ⇒ Object
41 42 43 |
# File 'lib/terraspace/core.rb', line 41 def cache_root ENV['TS_CACHE_ROOT'] || "#{root}/.terraspace-cache" end |
#cloud? ⇒ Boolean
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/terraspace/core.rb', line 89 def cloud? enabled = !!Terraspace.config.cloud.org if ENV['TS_TOKEN'] && !enabled && !@@cloud_warning_shown logger.warn <<~EOL.color(:yellow) WARN: TS_TOKEN is set but config.cloud.org is not set. See: http://terraspace.cloud/docs/cloud/setup/ EOL @@cloud_warning_shown = true end enabled end |
#command?(name) ⇒ Boolean
106 107 108 |
# File 'lib/terraspace/core.rb', line 106 def command?(name) ARGV[0] == name || ARGV[1] == name end |
#config ⇒ Object
Generally, use the Terraspace.config instead of App.instance.config since it guarantees the load_project_config call
60 61 62 63 |
# File 'lib/terraspace/core.rb', line 60 def config App.instance.load_project_config App.instance.config end |
#configure(&block) ⇒ Object
55 56 57 |
# File 'lib/terraspace/core.rb', line 55 def configure(&block) App.instance.configure(&block) end |
#env ⇒ Object
18 19 20 |
# File 'lib/terraspace/core.rb', line 18 def env ENV['TS_ENV'].blank? ? "dev" : ENV['TS_ENV'] end |
#extra ⇒ Object
22 23 24 |
# File 'lib/terraspace/core.rb', line 22 def extra ENV['TS_EXTRA'] unless ENV['TS_EXTRA'].blank? end |
#log_root ⇒ Object
51 52 53 |
# File 'lib/terraspace/core.rb', line 51 def log_root "#{root}/log" end |
#logger ⇒ Object
67 68 69 |
# File 'lib/terraspace/core.rb', line 67 def logger @@logger ||= config.logger end |
#logger=(v) ⇒ Object
allow different logger when running up all
72 73 74 |
# File 'lib/terraspace/core.rb', line 72 def logger=(v) @@logger = v end |
#pass_file?(path) ⇒ Boolean
76 77 78 79 80 81 |
# File 'lib/terraspace/core.rb', line 76 def pass_file?(path) pass_files = config.build.pass_files + config.build.default_pass_files pass_files.uniq.detect do |i| i.is_a?(Regexp) ? path =~ i : path.include?(i) end end |
#project ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/terraspace/core.rb', line 26 def project if ENV['TS_PROJECT'].blank? "main" else ENV['TS_PROJECT'] end end |
#role ⇒ Object
14 15 16 |
# File 'lib/terraspace/core.rb', line 14 def role ENV['TS_ROLE'] unless ENV['TS_ROLE'].blank? end |
#root ⇒ Object
35 36 37 |
# File 'lib/terraspace/core.rb', line 35 def root @@root ||= ENV['TS_ROOT'] || Dir.pwd end |
#terraform_bin ⇒ Object
5 6 7 8 |
# File 'lib/terraspace/core.rb', line 5 def terraform_bin # basename so command shows up as a prettier short name in the output File.basename(Terraspace::Check.new.terraform_bin) end |
#tmp_root ⇒ Object
46 47 48 |
# File 'lib/terraspace/core.rb', line 46 def tmp_root ENV['TS_TMP_ROOT'] || "/tmp/terraspace" end |