Class: Drydock::Instructions::Copy

Inherits:
Base
  • Object
show all
Defined in:
lib/drydock/instructions/copy.rb

Overview

The concrete implementation of the COPY instruction. Do not use this class directly.

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#chainObject (readonly)

Returns the value of attribute chain.



14
15
16
# File 'lib/drydock/instructions/copy.rb', line 14

def chain
  @chain
end

#chmodObject

Returns the value of attribute chmod.



12
13
14
# File 'lib/drydock/instructions/copy.rb', line 12

def chmod
  @chmod
end

#ignorefileObject

Returns the value of attribute ignorefile.



12
13
14
# File 'lib/drydock/instructions/copy.rb', line 12

def ignorefile
  @ignorefile
end

#no_cacheObject

Returns the value of attribute no_cache.



12
13
14
# File 'lib/drydock/instructions/copy.rb', line 12

def no_cache
  @no_cache
end

#recursiveObject

Returns the value of attribute recursive.



12
13
14
# File 'lib/drydock/instructions/copy.rb', line 12

def recursive
  @recursive
end

#source_pathObject (readonly)

Returns the value of attribute source_path.



14
15
16
# File 'lib/drydock/instructions/copy.rb', line 14

def source_path
  @source_path
end

#target_pathObject (readonly)

Returns the value of attribute target_path.



14
15
16
# File 'lib/drydock/instructions/copy.rb', line 14

def target_path
  @target_path
end

Instance Method Details

#run!Object

Raises:



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

def run!
  if source_path.start_with?('/')
    Drydock.logger.warn("#{source_path.inspect} is an absolute path; we recommend relative paths")
  end

  fail InvalidInstructionError, "#{source_path} does not exist" unless File.exist?(source_path)

  buffer = build_tar_from_source!
  digest = calculate_digest(buffer)
  write_to_container(buffer, digest)
end