lib/fig/lock.rb
# Select the latest version for images in the fig hash. Updates the input hash.
Select the latest version for images in the fig hash. Updates the input hash.
Select the latest version for images in the fig hash . Updates the input hash .
def select_latest(hash)
  log.info "Selecting latest tags:"
  resolved_tags = {}
  old_lock_yaml = lock_yaml
  hash.each do |k,v|
  image = v['image']
  next unless image
  image = "#{image}:latest" unless image.index(':')
  log.info "Selecting latest tag for #{image} ..."
  unless image.nil?
  result = resolved_tags[image]
  if result
  log.debug "Using previously resolved image: #{result}"
  else
tags = docker_client.tags(image)
  latest = tags['latest']
  fail "Image #{image} has no latest tag" if latest.nil?
  version = tags.detect{|k,v|
    v == latest && k != 'latest'
  }
version = version[0] if version
fail "No matching version found for hash #{latest}" unless version
result = "#{image[0..image.rindex(':')-1]}:#{version}"
log.debug "Resolved image: #{result}"
resolved_tags[image] = result
end
v['image'] = result
if old_lock_yaml && old_lock_yaml[k] && old_lock_yaml[k]['image'] == result
log.debug "Component #{k} already using tag: #{result}"
else
log.info "Component #{k} updated to tag: #{result}"
end
end
end
end
def select_latest ( hash ) log . info "Selecting latest tags:" resolved_tags = { } old_lock_yaml = lock_yaml hash . each do | k , v | image = v [ 'image' ] next unless image image = "#{image}:latest" unless image . index ( ':' ) log . info "Selecting latest tag for #{image} ..." unless image . nil? result = resolved_tags [ image ] if result log . debug "Using previously resolved image: #{result}" else tags = docker_client . tags ( image ) latest = tags [ 'latest' ] fail "Image #{image} has no latest tag" if latest . nil? version = tags . detect { | k , v | v == latest && k != 'latest' } version = version [ 0 ] if version fail "No matching version found for hash #{latest}" unless version result = "#{image[0..image.rindex(':')-1]}:#{version}" log . debug "Resolved image: #{result}" resolved_tags [ image ] = result end v [ 'image' ] = result if old_lock_yaml && old_lock_yaml [ k ] && old_lock_yaml [ k ] [ 'image' ] == result log . debug "Component #{k} already using tag: #{result}" else log . info "Component #{k} updated to tag: #{result}" end end end end
Select the latest version for images in the fig hash.
Select the latest version for images in the fig hash .
# Fetch tags # Figure out which one corresponds to "latest" # Update hash
hash
<not_specific>