Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thomasmckay/30761adbfb00144cea1ae4cf2aa96835 to your computer and use it in GitHub Desktop.
Save thomasmckay/30761adbfb00144cea1ae4cf2aa96835 to your computer and use it in GitHub Desktop.
skopeo copy upload w/ hammer
#!/usr/bin/env ruby
require 'json'
inspect_results = JSON.parse(`skopeo inspect #{ARGV[0]}`)
name = inspect_results['Name'].split('/')[-1]
Dir.mkdir(name) unless Dir.exist?(name)
Dir.chdir(name)
inspect_results['RepoTags'].each do |repotag|
puts "#{repotag}"
if !Dir.exist?(repotag)
Dir.mkdir(repotag)
`skopeo copy #{ARGV[0]}:#{repotag} dir:#{repotag}`
end
if !File.exist?("#{repotag}.tar")
Dir.chdir(repotag)
`tar cvf ../#{repotag}.tar *`
Dir.chdir("..")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment