Class: Shiplane::ComposeHash

Inherits:
Object
  • Object
show all
Defined in:
lib/shiplane/compose_hash.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(compose_file, production_config) ⇒ ComposeHash

Returns a new instance of ComposeHash.



7
8
9
10
# File 'lib/shiplane/compose_hash.rb', line 7

def initialize(compose_file, production_config)
  @compose_file = compose_file
  @production_config = production_config
end

Instance Attribute Details

#compose_fileObject

Returns the value of attribute compose_file.



5
6
7
# File 'lib/shiplane/compose_hash.rb', line 5

def compose_file
  @compose_file
end

#production_configObject

Returns the value of attribute production_config.



5
6
7
# File 'lib/shiplane/compose_hash.rb', line 5

def production_config
  @production_config
end

Instance Method Details

#blacklisted_nodesObject



24
25
26
# File 'lib/shiplane/compose_hash.rb', line 24

def blacklisted_nodes
  @blacklisted_nodes ||= production_config.fetch('blacklist', [])
end

#compose_hashObject



16
17
18
# File 'lib/shiplane/compose_hash.rb', line 16

def compose_hash
  @compose_hash ||= YAML.load(compose_file)
end

#default_whitelisted_nodesObject



32
33
34
35
36
# File 'lib/shiplane/compose_hash.rb', line 32

def default_whitelisted_nodes
  [
    "version",
  ]
end

#production_ymlObject



12
13
14
# File 'lib/shiplane/compose_hash.rb', line 12

def production_yml
  blacklisted_nodes.inject(whitelisted_hash){ |acc, node| acc.blacklist(node) }
end

#whitelisted_hashObject



20
21
22
# File 'lib/shiplane/compose_hash.rb', line 20

def whitelisted_hash
  @whitelisted_hash ||= compose_hash.whitelist(*default_whitelisted_nodes, *whitelisted_nodes)
end

#whitelisted_nodesObject



28
29
30
# File 'lib/shiplane/compose_hash.rb', line 28

def whitelisted_nodes
  @whitelisted_nodes ||= production_config.fetch('whitelist', [])
end