Class: Terraspace::Builder::Allow
- Inherits:
-
Object
- Object
- Terraspace::Builder::Allow
- Defined in:
- lib/terraspace/builder/allow.rb
Instance Method Summary collapse
- #check! ⇒ Object
- #config ⇒ Object
- #current_region ⇒ Object
- #env_allowed? ⇒ Boolean
-
#initialize(mod) ⇒ Allow
constructor
A new instance of Allow.
- #region_allowed? ⇒ Boolean
Constructor Details
#initialize(mod) ⇒ Allow
Returns a new instance of Allow.
3 4 5 |
# File 'lib/terraspace/builder/allow.rb', line 3 def initialize(mod) @mod = mod end |
Instance Method Details
#check! ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/terraspace/builder/allow.rb', line 7 def check! = [] unless env_allowed? << "This env is not allowed to be used: TS_ENV=#{Terraspace.env}" << "Allowed envs: #{config.allow.envs.join(', ')}" end unless region_allowed? << "This region is not allowed to be used: Detected current region=#{current_region}" << "Allowed regions: #{config.allow.regions.join(', ')}" end unless .empty? puts "ERROR: The configs do not allow this.".color(:red) puts exit 1 end end |
#config ⇒ Object
39 40 41 |
# File 'lib/terraspace/builder/allow.rb', line 39 def config Terraspace.config end |
#current_region ⇒ Object
34 35 36 37 |
# File 'lib/terraspace/builder/allow.rb', line 34 def current_region = Terraspace::Compiler::Expander.autodetect(@mod). .region end |
#env_allowed? ⇒ Boolean
24 25 26 27 |
# File 'lib/terraspace/builder/allow.rb', line 24 def env_allowed? return true unless config.allow.envs config.allow.envs.include?(Terraspace.env) end |
#region_allowed? ⇒ Boolean
29 30 31 32 |
# File 'lib/terraspace/builder/allow.rb', line 29 def region_allowed? return true unless config.allow.regions config.allow.regions.include?(current_region) end |