dockly 1.5.9 → 1.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.cane +1 -1
- data/lib/dockly/bash_builder.rb +1 -0
- data/lib/dockly/build_cache/docker.rb +24 -18
- data/lib/dockly/cli.rb +9 -5
- data/lib/dockly/deb.rb +1 -0
- data/lib/dockly/version.rb +1 -1
- data/snippets/docker_tag_latest.erb +3 -0
- data/spec/dockly/bash_builder_spec.rb +16 -0
- metadata +2 -1
data/.cane
CHANGED
data/lib/dockly/bash_builder.rb
CHANGED
@@ -20,6 +20,7 @@ module Dockly
|
|
20
20
|
generate_snippet_for :install_package, [:path]
|
21
21
|
generate_snippet_for :get_and_install_deb, [:s3_url, :deb_path]
|
22
22
|
generate_snippet_for :docker_import, [:repo, :tag], { :tag => "latest" }
|
23
|
+
generate_snippet_for :docker_tag_latest, [:repo, :tag]
|
23
24
|
generate_snippet_for :file_docker_import, [:path, :repo, :tag]
|
24
25
|
generate_snippet_for :file_diff_docker_import, [:base_image, :diff_image, :repo, :tag]
|
25
26
|
generate_snippet_for :s3_docker_import, [:s3_url, :repo, :tag]
|
@@ -25,25 +25,31 @@ class Dockly::BuildCache::Docker < Dockly::BuildCache::Base
|
|
25
25
|
ensure_present! :output_dir
|
26
26
|
if cache = pull_from_s3(version)
|
27
27
|
debug "inserting to #{output_directory}"
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
'
|
33
|
-
'Cmd' => ['/bin/bash', '-lc', [
|
34
|
-
"mkdir -p #{File.dirname(output_directory)}",
|
35
|
-
'&&',
|
36
|
-
"tar #{tar_flags} #{File.join('/', 'host', path)} -C #{File.dirname(output_directory)}"
|
37
|
-
].join(' ')
|
38
|
-
],
|
39
|
-
'Volumes' => {
|
40
|
-
File.join('/', 'host', path_parent) => { path_parent => 'rw' }
|
41
|
-
}
|
28
|
+
container = image.run("mkdir -p #{File.dirname(output_directory)}")
|
29
|
+
image_with_dir = container.tap(&:wait).commit
|
30
|
+
self.image = image_with_dir.insert_local(
|
31
|
+
'localPath' => cache.path,
|
32
|
+
'outputPath' => File.dirname(output_directory)
|
42
33
|
)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
34
|
+
#path = File.expand_path(cache.path)
|
35
|
+
#path_parent = File.dirname(path)
|
36
|
+
#tar_flags = keep_old_files ? '-xkf' : 'xf'
|
37
|
+
#container = ::Docker::Container.create(
|
38
|
+
# 'Image' => image.id,
|
39
|
+
# 'Cmd' => ['/bin/bash', '-lc', [
|
40
|
+
# "mkdir -p #{File.dirname(output_directory)}",
|
41
|
+
# '&&',
|
42
|
+
# "tar #{tar_flags} #{File.join('/', 'host', path)} -C #{File.dirname(output_directory)}"
|
43
|
+
# ].join(' ')
|
44
|
+
# ],
|
45
|
+
# 'Volumes' => {
|
46
|
+
# File.join('/', 'host', path_parent) => { path_parent => 'rw' }
|
47
|
+
# }
|
48
|
+
#)
|
49
|
+
#container.start('Binds' => ["#{path_parent}:#{File.join('/', 'host', path_parent)}"])
|
50
|
+
#result = container.wait['StatusCode']
|
51
|
+
#raise "Got bad status code when copying build cache: #{result}" unless result.zero?
|
52
|
+
#self.image = container.commit
|
47
53
|
debug "inserted cache into #{output_directory}"
|
48
54
|
cache.close
|
49
55
|
else
|
data/lib/dockly/cli.rb
CHANGED
@@ -81,15 +81,18 @@ class Dockly::BuildCacheCommand < Dockly::AbstractCommand
|
|
81
81
|
def execute
|
82
82
|
Dockly::BuildCache.model = Dockly::BuildCache::Local
|
83
83
|
super
|
84
|
-
|
85
|
-
|
84
|
+
docker = Dockly.docker(docker_name.to_sym)
|
85
|
+
build_caches = (docker && docker.build_cache) || []
|
86
|
+
|
87
|
+
puts "No build cache for #{docker_name}" if build_caches.empty?
|
88
|
+
|
86
89
|
if list?
|
87
90
|
build_caches.each_with_index do |build_cache, index|
|
88
91
|
puts "#{index + 1}. Hash: #{build_cache.hash_command} Build: #{build_cache.build_command}"
|
89
92
|
end
|
90
93
|
else
|
91
94
|
bcs = if local?
|
92
|
-
convert_bc_to_local_bc(
|
95
|
+
convert_bc_to_local_bc(docker)
|
93
96
|
else
|
94
97
|
build_caches
|
95
98
|
end
|
@@ -107,9 +110,10 @@ class Dockly::Cli < Dockly::AbstractCommand
|
|
107
110
|
subcommand ['build_cache', 'bc'], 'Build Cache commands', Dockly::BuildCacheCommand
|
108
111
|
end
|
109
112
|
|
110
|
-
def convert_bc_to_local_bc(
|
113
|
+
def convert_bc_to_local_bc(docker)
|
114
|
+
return [] unless docker
|
111
115
|
lbcs = []
|
112
|
-
|
116
|
+
docker.build_cache.each do |bc|
|
113
117
|
lbc = Dockly::BuildCache::Local.new! { name bc.name }
|
114
118
|
bc.instance_variables.each do |variable|
|
115
119
|
lbc.instance_variable_set(variable, bc.instance_variable_get(variable))
|
data/lib/dockly/deb.rb
CHANGED
data/lib/dockly/version.rb
CHANGED
@@ -74,6 +74,22 @@ describe Dockly::BashBuilder do
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
describe "#docker_tag_latest" do
|
78
|
+
context "when there is no tag" do
|
79
|
+
it "does not mark a tag" do
|
80
|
+
output = subject.docker_tag_latest("test_repo")
|
81
|
+
expect(output).to_not include("docker tag")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "when there is a tag" do
|
86
|
+
it "tags the repo:tag as repo:latest" do
|
87
|
+
output = subject.docker_tag_latest("test_repo", "a_tag")
|
88
|
+
expect(output).to include("docker tag test_repo:a_tag test_repo:latest")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
77
93
|
describe "#file_docker_import" do
|
78
94
|
let(:path) { "/opt/dockly/file.tar.gz" }
|
79
95
|
it "cats, gunzips and passes to docker import" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dockly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -278,6 +278,7 @@ files:
|
|
278
278
|
- lib/foreman/cli_fix.rb
|
279
279
|
- lib/foreman/export/base_fix.rb
|
280
280
|
- snippets/docker_import.erb
|
281
|
+
- snippets/docker_tag_latest.erb
|
281
282
|
- snippets/file_diff_docker_import.erb
|
282
283
|
- snippets/file_docker_import.erb
|
283
284
|
- snippets/get_and_install_deb.erb
|