Module: RSpec::Terraspace::Concern
Instance Method Summary collapse
- #out_path ⇒ Object
- #output(mod, name) ⇒ Object
- #outputs ⇒ Object
-
#save_output ⇒ Object
Note: a terraspace.down will remove the output.json since it does a clean.
- #save_state ⇒ Object
- #state ⇒ Object
- #state_path ⇒ Object
-
#state_resource(full_name) ⇒ Object
full_name: random_pet.this.
Instance Method Details
#out_path ⇒ Object
21 22 23 |
# File 'lib/rspec/terraspace/concern.rb', line 21 def out_path "#{Terraspace.tmp_root}/rspec/terraform-output.json" end |
#output(mod, name) ⇒ Object
5 6 7 |
# File 'lib/rspec/terraspace/concern.rb', line 5 def output(mod, name) outputs.dig(name, "value") end |
#outputs ⇒ Object
9 10 11 12 |
# File 'lib/rspec/terraspace/concern.rb', line 9 def outputs save_output JSON.load(IO.read(out_path)) end |
#save_output ⇒ Object
Note: a terraspace.down will remove the output.json since it does a clean
15 16 17 18 |
# File 'lib/rspec/terraspace/concern.rb', line 15 def save_output FileUtils.mkdir_p(File.dirname(out_path)) run("output #{@mod.name} --format json --out #{out_path}") end |
#save_state ⇒ Object
39 40 41 42 |
# File 'lib/rspec/terraspace/concern.rb', line 39 def save_state FileUtils.mkdir_p(File.dirname(state_path)) run("state pull #{@mod.name} > #{state_path}") end |
#state ⇒ Object
25 26 27 28 |
# File 'lib/rspec/terraspace/concern.rb', line 25 def state save_state JSON.load(IO.read(state_path)) end |
#state_path ⇒ Object
45 46 47 |
# File 'lib/rspec/terraspace/concern.rb', line 45 def state_path "#{Terraspace.tmp_root}/rspec/terraform-state.json" end |
#state_resource(full_name) ⇒ Object
full_name: random_pet.this
31 32 33 34 35 36 37 |
# File 'lib/rspec/terraspace/concern.rb', line 31 def state_resource(full_name) type, name = full_name.split('.') state['resources'].find do |i| i['type'] == type && i['name'] == name || # IE: type=random_pet name=this i['module'] == full_name # IE: module.bucket end end |