Class: Stacker::Stack::Template
- Inherits:
-
Component
show all
- Extended by:
- Memoist
- Defined in:
- lib/stacker/stack/template.rb
Defined Under Namespace
Classes: JSONFormatter
Constant Summary
collapse
- FORMAT_VERSION =
'2010-09-09'
Instance Attribute Summary
Attributes inherited from Component
#stack
Instance Method Summary
collapse
Methods inherited from Component
#initialize
Instance Method Details
#diff(*args) ⇒ Object
41
42
43
|
# File 'lib/stacker/stack/template.rb', line 41
def diff *args
Differ.json_diff local, remote, *args
end
|
#dump ⇒ Object
50
51
52
|
# File 'lib/stacker/stack/template.rb', line 50
def dump
write remote
end
|
#exists? ⇒ Boolean
15
16
17
|
# File 'lib/stacker/stack/template.rb', line 15
def exists?
File.exists? path
end
|
#local ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/stacker/stack/template.rb', line 19
def local
@local ||= begin
if exists?
template = JSON.parse File.read path
template['AWSTemplateFormatVersion'] ||= FORMAT_VERSION
template
else
{}
end
end
end
|
#remote ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/stacker/stack/template.rb', line 31
def remote
@remote ||= JSON.parse client.template
rescue AWS::CloudFormation::Errors::ValidationError => err
if err.message =~ /does not exist/
raise DoesNotExistError.new err.message
else
raise Error.new err.message
end
end
|
#write(value = local) ⇒ Object
46
47
48
|
# File 'lib/stacker/stack/template.rb', line 46
def write value = local
File.write path, JSONFormatter.format(value)
end
|