Class: DockerHelpers
- Inherits:
-
Object
- Object
- DockerHelpers
- Defined in:
- lib/potassium/helpers/docker-helpers.rb
Instance Method Summary collapse
- #add_env(target_service, variable_key, variable_value) ⇒ Object
- #add_link(target_service, linked_service) ⇒ Object
- #add_service(name, definition) ⇒ Object
- #add_volume(name, definition = '') ⇒ Object
-
#initialize(compose_path) ⇒ DockerHelpers
constructor
A new instance of DockerHelpers.
Constructor Details
#initialize(compose_path) ⇒ DockerHelpers
Returns a new instance of DockerHelpers.
2 3 4 5 |
# File 'lib/potassium/helpers/docker-helpers.rb', line 2 def initialize(compose_path) @compose_path = compose_path @compose = YAML.safe_load(File.read(compose_path)) end |
Instance Method Details
#add_env(target_service, variable_key, variable_value) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/potassium/helpers/docker-helpers.rb', line 16 def add_env(target_service, variable_key, variable_value) service = @compose['services'][target_service] unless service['environment'].is_a? Hash service['environment'] = {} end service['environment'][variable_key] = variable_value save end |
#add_link(target_service, linked_service) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/potassium/helpers/docker-helpers.rb', line 7 def add_link(target_service, linked_service) service = @compose['services'][target_service] unless service['links'].is_a? Array service['links'] = [] end service['links'].push(linked_service) save end |
#add_service(name, definition) ⇒ Object
25 26 27 |
# File 'lib/potassium/helpers/docker-helpers.rb', line 25 def add_service(name, definition) add_leaf('services', name, definition) end |
#add_volume(name, definition = '') ⇒ Object
29 30 31 |
# File 'lib/potassium/helpers/docker-helpers.rb', line 29 def add_volume(name, definition = '') add_leaf('volumes', name, definition) end |