Class: Dockly::BuildCacheCommand

Inherits:
AbstractCommand show all
Defined in:
lib/dockly/cli.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/dockly/cli.rb', line 109

def execute
  Dockly::BuildCache.model = Dockly::BuildCache::Local
  super
  docker = Dockly.docker(docker_name.to_sym)
  build_caches = (docker && docker.build_cache) || []

  puts "No build cache for #{docker_name}" if build_caches.empty?

  if list?
    build_caches.each_with_index do |build_cache, index|
      puts "#{index + 1}. Hash: #{build_cache.hash_command} Build: #{build_cache.build_command}"
    end
  else
    bcs = if local?
      convert_bc_to_local_bc(docker)
    else
      build_caches
    end
    bcs.each do |bc|
      bc.execute!
    end
  end
end