-
Notifications
You must be signed in to change notification settings - Fork 26
/
tagutil.rb
78 lines (67 loc) · 2.11 KB
/
tagutil.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env ruby
require 'docker'
require 'open3'
basedir = File.dirname(__FILE__)
@auth = YAML.load_file(basedir + File::SEPARATOR + 'auth.yml')
@imagenames = %w(base core flow microarray proteomics sequencing)
@versioned_imagenames = []
%w(release devel).each do |version|
@imagenames.each do |name|
@versioned_imagenames << "#{version}_#{name}"
end
end
@authenticated = false
def get_image_info()
repo = 'bioconductor'
versions = %w(release devel)
for version in versions
for imagename in @imagenames
name = "#{repo}/#{version}_#{imagename}"
output = `docker run --rm rufus/docker-registry-debug -q info #{name}`
lines = output.split("\n")
found_tags = []
for line in lines
next if line.start_with? '-'
found_tags << line.strip.split(' ').first
end
puts "#{name} has tags: #{found_tags.sort.join ', '}"
end
end
end
def get_local_image_info(name)
name = "bioconductor/" + name unless name.start_with? "bioconductor/"
images = Docker::Image.all
image = images.find{|i| i.info['RepoTags'].first.start_with? name}
if image.nil?
puts "#{name}: no such image found"
return
end
image.info['RepoTags']
end
#e.g. devel_flow
def retag(name)
name = "bioconductor/" + name unless name.start_with? "bioconductor/"
images = Docker::Image.all
image = images.find{|i| i.info['RepoTags'].first.start_with? name}
if image.nil?
puts "#{name}: no such image found"
return
end
# unless @authenticated
# Docker.authenticate!(@auth)
# @authenticated = true
# end
# image.push()
# use docker executable instead of api
# because api pushes seem flaky
cmd = "docker push #{name}"
Open3.popen2e(cmd) do |stdin, stdout_err, wait_thr|
while line = stdout_err.gets
puts line
end
exit_status = wait_thr.value
unless exit_status.success?
abort "FAILED !!! '#{cmd}' returned exit code #{exit_status.exitstatus}"
end
end
end