Module: Dapp::Dimg::Dapp::Command::BuildContext::Import
- Included in:
- Dapp
- Defined in:
- lib/dapp/dimg/dapp/command/build_context/import.rb
Instance Method Summary collapse
- #build_context_import ⇒ Object
- #build_path_empty? ⇒ Boolean
- #import_build_context_build_tar ⇒ Object
- #import_build_context_image_tar ⇒ Object
- #store_current_build_dir ⇒ Object
Instance Method Details
#build_context_import ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dapp/dimg/dapp/command/build_context/import.rb', line 7 def build_context_import raise Error::Command, code: :context_directory_not_found, data: { path: build_context_path } unless build_context_path.exist? log_process(:'import context') do with_log_indent do import_build_context_build_tar import_build_context_image_tar end end end |
#build_path_empty? ⇒ Boolean
63 64 65 |
# File 'lib/dapp/dimg/dapp/command/build_context/import.rb', line 63 def build_path_empty? (build_path.entries.map(&:to_s) - %w(. .. locks)).empty? end |
#import_build_context_build_tar ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dapp/dimg/dapp/command/build_context/import.rb', line 31 def import_build_context_build_tar if build_context_build_tar.exist? log_secondary_process(:build_dir, short: true) do store_current_build_dir tar_read(build_context_build_tar) do |tar| tar.each_entry do |entry| header = entry.header path = File.join(build_path, entry.full_name) if entry.directory? FileUtils.mkpath path, :mode => entry.header.mode else FileUtils.mkpath File.dirname(path) File.write(path, entry.read) File.chmod(header.mode, path) end end end end else log_warning(desc: { code: :context_archive_not_found, data: { path: build_context_build_tar } }) end end |
#import_build_context_image_tar ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dapp/dimg/dapp/command/build_context/import.rb', line 19 def import_build_context_image_tar if build_context_images_tar.exist? log_secondary_process(:images, short: true) do lock("#{name}.images") do Image::Docker.load!(build_context_images_tar, verbose: true, quiet: log_quiet?) end end else log_warning(desc: { code: :context_archive_not_found, data: { path: build_context_images_tar } }) end end |
#store_current_build_dir ⇒ Object
56 57 58 59 60 61 |
# File 'lib/dapp/dimg/dapp/command/build_context/import.rb', line 56 def store_current_build_dir return if build_path_empty? raise Error::Command, code: :stored_build_dir_already_exist, data: { path: "#{build_path}.old" } if File.exist?("#{build_path}.old") FileUtils.mv(build_path, "#{build_path}.old") end |