Class: RakeDocker::Container::Provisioner

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/rake_docker/container.rb

Overview

rubocop:disable Metrics/ClassLength

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#enhance_with_name, #find_container

Constructor Details

#initialize(name, image, opts = {}) ⇒ Provisioner

Returns a new instance of Provisioner.



149
150
151
152
153
154
155
156
# File 'lib/rake_docker/container.rb', line 149

def initialize(name, image, opts = {})
  @name = name
  @image = image
  @environment = opts[:environment] || {}
  @ports = opts[:ports] || []
  @ready = opts[:ready?]
  @reporter = opts[:reporter] || NullReporter.new
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



147
148
149
# File 'lib/rake_docker/container.rb', line 147

def environment
  @environment
end

#imageObject (readonly)

Returns the value of attribute image.



147
148
149
# File 'lib/rake_docker/container.rb', line 147

def image
  @image
end

#nameObject (readonly)

Returns the value of attribute name.



147
148
149
# File 'lib/rake_docker/container.rb', line 147

def name
  @name
end

#portsObject (readonly)

Returns the value of attribute ports.



147
148
149
# File 'lib/rake_docker/container.rb', line 147

def ports
  @ports
end

#readyObject (readonly)

Returns the value of attribute ready.



147
148
149
# File 'lib/rake_docker/container.rb', line 147

def ready
  @ready
end

#reporterObject (readonly)

Returns the value of attribute reporter.



147
148
149
# File 'lib/rake_docker/container.rb', line 147

def reporter
  @reporter
end

Instance Method Details

#executeObject

rubocop:disable Metrics/AbcSize



159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/rake_docker/container.rb', line 159

def execute
  reporter.checking_if_container_exists(name)
  container = find_container(name)
  if container
    reporter.container_exists(container)
    ensure_container_running(container)
  else
    reporter.container_does_not_exist(name)
    start_new_container(name, image, ports, environment)
  end
  reporter.done
end