Class: Pangea::ModCache
- Inherits:
-
Object
- Object
- Pangea::ModCache
- Defined in:
- lib/pangea/modcache.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#basedir ⇒ Object
readonly
Returns the value of attribute basedir.
-
#mod ⇒ Object
readonly
Returns the value of attribute mod.
-
#modcachedir ⇒ Object
readonly
Returns the value of attribute modcachedir.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#virtual ⇒ Object
readonly
Returns the value of attribute virtual.
Instance Method Summary collapse
-
#initialize(name, mod, resource, virtual) ⇒ ModCache
constructor
A new instance of ModCache.
- #place_caller_template ⇒ Object
- #place_internal_module(template) ⇒ Object
- #preflight ⇒ Object
Constructor Details
#initialize(name, mod, resource, virtual) ⇒ ModCache
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pangea/modcache.rb', line 15 def initialize(name, mod, resource, virtual) @name = name @mod = mod @resource = resource @virtual = virtual @basedir = File.join(Dir.home, '.pangea') @modcachedir = File.join(basedir, 'modcache') @address = "#{name}/#{mod}/#{resource}/#{virtual}/module" @internal_module_file_name = 'internal.tf.json' end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
7 8 9 |
# File 'lib/pangea/modcache.rb', line 7 def address @address end |
#basedir ⇒ Object (readonly)
Returns the value of attribute basedir.
7 8 9 |
# File 'lib/pangea/modcache.rb', line 7 def basedir @basedir end |
#mod ⇒ Object (readonly)
Returns the value of attribute mod.
7 8 9 |
# File 'lib/pangea/modcache.rb', line 7 def mod @mod end |
#modcachedir ⇒ Object (readonly)
Returns the value of attribute modcachedir.
7 8 9 |
# File 'lib/pangea/modcache.rb', line 7 def modcachedir @modcachedir end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/pangea/modcache.rb', line 7 def name @name end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
7 8 9 |
# File 'lib/pangea/modcache.rb', line 7 def resource @resource end |
#virtual ⇒ Object (readonly)
Returns the value of attribute virtual.
7 8 9 |
# File 'lib/pangea/modcache.rb', line 7 def virtual @virtual end |
Instance Method Details
#place_caller_template ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/pangea/modcache.rb', line 41 def place_caller_template internal_module_path = File.join( modcachedir, @internal_module_file_name ) caller_template = { provider: { aws: { region: 'us-east-1' } }, module: { "#{name}": { source: internal_module_path } } } internal_caller_template_path = File.join( modcachedir, 'caller.tf.json' ) File.write(internal_caller_template_path, JSON[caller_template]) end |
#place_internal_module(template) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/pangea/modcache.rb', line 32 def place_internal_module(template) preflight internal_module_path = File.join( modcachedir, @internal_module_file_name ) File.write(internal_module_path, template) end |
#preflight ⇒ Object
26 27 28 29 30 |
# File 'lib/pangea/modcache.rb', line 26 def preflight [basedir, modcachedir, File.join(modcachedir, address)].each do |d| `mkdir -p #{modcachedir}` unless Dir.exist?(d) end end |