Class: StackMaster::StackDefinition

Inherits:
Object
  • Object
show all
Includes:
Utils::Initializable
Defined in:
lib/stack_master/stack_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Initializable

#attributes=

Constructor Details

#initialize(attributes = {}) ⇒ StackDefinition

Returns a new instance of StackDefinition.



17
18
19
20
21
22
23
# File 'lib/stack_master/stack_definition.rb', line 17

def initialize(attributes = {})
  @additional_parameter_lookup_dirs = []
  @notification_arns = []
  @s3 = {}
  @files = []
  super
end

Instance Attribute Details

#additional_parameter_lookup_dirsObject

Returns the value of attribute additional_parameter_lookup_dirs.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def additional_parameter_lookup_dirs
  @additional_parameter_lookup_dirs
end

#base_dirObject

Returns the value of attribute base_dir.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def base_dir
  @base_dir
end

#filesObject

Returns the value of attribute files.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def files
  @files
end

#notification_arnsObject

Returns the value of attribute notification_arns.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def notification_arns
  @notification_arns
end

#regionObject

Returns the value of attribute region.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def region
  @region
end

#s3Object

Returns the value of attribute s3.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def s3
  @s3
end

#secret_fileObject

Returns the value of attribute secret_file.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def secret_file
  @secret_file
end

#stack_nameObject

Returns the value of attribute stack_name.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def stack_name
  @stack_name
end

#stack_policy_fileObject

Returns the value of attribute stack_policy_file.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def stack_policy_file
  @stack_policy_file
end

#tagsObject

Returns the value of attribute tags.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def tags
  @tags
end

#templateObject

Returns the value of attribute template.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def template
  @template
end

Instance Method Details

#==(other) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/stack_master/stack_definition.rb', line 25

def ==(other)
  self.class === other &&
    @region == other.region &&
    @stack_name == other.stack_name &&
    @template == other.template &&
    @tags == other.tags &&
    @notification_arns == other.notification_arns &&
    @base_dir == other.base_dir &&
    @secret_file == other.secret_file &&
    @stack_policy_file == other.stack_policy_file &&
    @additional_parameter_lookup_dirs == other.additional_parameter_lookup_dirs &&
    @s3 == other.s3
end

#files_dirObject



47
48
49
# File 'lib/stack_master/stack_definition.rb', line 47

def files_dir
  File.join(base_dir, 'files')
end

#parameter_filesObject



67
68
69
# File 'lib/stack_master/stack_definition.rb', line 67

def parameter_files
  [ default_parameter_file_path, region_parameter_file_path, additional_parameter_lookup_file_paths ].flatten.compact
end

#s3_configured?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/stack_master/stack_definition.rb', line 75

def s3_configured?
  !s3.nil?
end

#s3_filesObject



51
52
53
54
55
56
57
58
59
60
# File 'lib/stack_master/stack_definition.rb', line 51

def s3_files
  files.inject({}) do |hash, file|
    path = File.join(files_dir, file)
    hash[file] = {
      path: path,
      body: File.read(path)
    }
    hash
  end
end

#s3_template_file_nameObject



62
63
64
65
# File 'lib/stack_master/stack_definition.rb', line 62

def s3_template_file_name
  return template if ['.json', '.yaml', '.yml'].include?(File.extname(template))
  Utils.change_extension(template, 'json')
end

#stack_policy_file_pathObject



71
72
73
# File 'lib/stack_master/stack_definition.rb', line 71

def stack_policy_file_path
  File.join(base_dir, 'policies', stack_policy_file) if stack_policy_file
end

#template_dirObject



39
40
41
# File 'lib/stack_master/stack_definition.rb', line 39

def template_dir
  File.join(base_dir, 'templates')
end

#template_file_pathObject



43
44
45
# File 'lib/stack_master/stack_definition.rb', line 43

def template_file_path
  File.join(template_dir, template)
end