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

Constructor Details

#initialize(*args) ⇒ Phase

Returns a new instance of Phase.



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

def initialize(*args)
  super
  @finalized = false
end

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



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

def self.from(hsh)
  h = hsh.to_h
  extra_keys = h.keys - members

  fail ArgumentError, "unknown options: #{extra_keys.join(', ')}" unless extra_keys.empty?

  new(*h.values_at(*members))
end

Instance Method Details

#built?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/drydock/phase.rb', line 28

def built?
  !cached?
end

#cached?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/drydock/phase.rb', line 32

def cached?
  build_container.nil?
end

#destroy!(force: false) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/drydock/phase.rb', line 36

def destroy!(force: false)
  return self if frozen?

  finalize!(force: force)

  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

  freeze
end

#finalize!(force: false) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/drydock/phase.rb', line 53

def finalize!(force: false)
  unless finalized?
    build_container.remove(force: force) if built?
    @finalized = true
  end

  self
end

#finalized?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/drydock/phase.rb', line 62

def finalized?
  @finalized
end