Class: Drydock::Phase

Inherits:
Struct
  • Object
show all
Defined in:
lib/drydock/phase.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#build_containerObject Also known as: build

Returns the value of attribute build_container

Returns:

  • (Object)

    the current value of build_container



3
4
5
# File 'lib/drydock/phase.rb', line 3

def build_container
  @build_container
end

#result_imageObject Also known as: result

Returns the value of attribute result_image

Returns:

  • (Object)

    the current value of result_image



3
4
5
# File 'lib/drydock/phase.rb', line 3

def result_image
  @result_image
end

#source_imageObject Also known as: source

Returns the value of attribute source_image

Returns:

  • (Object)

    the current value of source_image



3
4
5
# File 'lib/drydock/phase.rb', line 3

def source_image
  @source_image
end

Class Method Details

.from(hsh) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
# File 'lib/drydock/phase.rb', line 14

def self.from(hsh)
  h = hsh.to_h
  extra_keys = h.keys - members
  raise ArgumentError, "unknown options: #{extra_keys.join(', ')}" unless extra_keys.empty?
  new(*h.values_at(*members))
end

Instance Method Details

#built?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/drydock/phase.rb', line 21

def built?
  !cached?
end

#cached?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/drydock/phase.rb', line 25

def cached?
  build_container.nil?
end

#destroy!(force: false) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/drydock/phase.rb', line 29

def destroy!(force: false)
  if result_image
    begin
      result_image.remove(force: force)
    rescue Docker::Error::NotFoundError => e
      # Ignore, because the image could have been deleted by another phase in
      # another derived chain.
    end
  end

  build_container.remove(force: force) if built?
  self
end

#finalize!(force: false) ⇒ Object



43
44
45
46
47
# File 'lib/drydock/phase.rb', line 43

def finalize!(force: false)
  return self unless built?
  build_container.remove(force: force)
  self
end