dockly 1.5.10 → 1.5.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ruby-version +1 -1
- data/.travis.yml +3 -0
- data/README.md +23 -8
- data/dockly.gemspec +2 -2
- data/lib/dockly.rb +6 -3
- data/lib/dockly/build_cache/docker.rb +18 -24
- data/lib/dockly/deb.rb +10 -3
- data/lib/dockly/rake_task.rb +25 -1
- data/lib/dockly/rpm.rb +26 -0
- data/lib/dockly/version.rb +1 -1
- data/spec/dockly/rpm_spec.rb +269 -0
- metadata +33 -59
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5eda36a779df41ea9bceeab3d5745798b707c71b
|
4
|
+
data.tar.gz: 99d2035cad1ab36ed9e1a0d6f90dea5ac8142a6e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bac1610c6fc54b2bec77128c23038ad2f4ebd41f67cfca2e3b0b0c4ecf83e462e85e76a994a961b67f5f30ea15ef3636f1a9f2ae091430f93c56deb7e38236de
|
7
|
+
data.tar.gz: 26a85cacfb18377b49e1623e13ec6337a37b7a7a4aef3b4b61a7b160b0456af5221513440507bcd8553c2257dd10724f220eb89ebba493b8aeab6280b10247a4
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.9.3-
|
1
|
+
1.9.3-p547
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -5,17 +5,14 @@
|
|
5
5
|
![Dockly](https://raw.github.com/swipely/dockly/master/img/dockly.png)
|
6
6
|
======================================================================
|
7
7
|
|
8
|
-
`dockly` is a gem made to ease the pain of packaging an application. For this gem to be useful,
|
9
|
-
|
10
|
-
- You're deploying to a Debian-based system
|
11
|
-
- You want to use [Docker](http://docker.io) for process isolation
|
8
|
+
`dockly` is a gem made to ease the pain of packaging an application. For this gem to be useful, you will want to use [Docker](http://docker.io) for process isolation.
|
12
9
|
|
13
10
|
Although only a specific type of repository may be used, these assumptions allow us to define a simple DSL to describe your repository.
|
14
11
|
|
15
12
|
Usage
|
16
13
|
-----
|
17
14
|
|
18
|
-
Once a
|
15
|
+
Once a package block has been defined by the DSL below, dockly is invoked by either (for a deb) `bundle exec dockly build #{deb block name}` or `bundle exec rake dockly:deb:#{deb block name}`.
|
19
16
|
If looking to just build a `docker` block, run either `bundle exec dockly docker #{docker block name}` or `bundle exec rake dockly:docker:#{docker block name}`.
|
20
17
|
To build without exporting, run add either `--no-export` or `:noexport` to the CLI program or Rake task
|
21
18
|
|
@@ -135,7 +132,7 @@ The `docker` DSL is used to define Docker containers. It has the following attri
|
|
135
132
|
- `package_dir`
|
136
133
|
- required: `true`
|
137
134
|
- default: `/opt/docker`
|
138
|
-
- description: the location of the created image in the
|
135
|
+
- description: the location of the created image in the package
|
139
136
|
- `timeout`
|
140
137
|
- required: `true`
|
141
138
|
- default: `60`
|
@@ -168,7 +165,7 @@ In addition to the above attributes, `docker` has the following references:
|
|
168
165
|
- required: `false`
|
169
166
|
- allows one
|
170
167
|
- class: `Dockly::Docker::Registry`
|
171
|
-
- description: a registry to push to in lieu of exporting as a tar -- the registry will be automatically pulled upon installing the
|
168
|
+
- description: a registry to push to in lieu of exporting as a tar -- the registry will be automatically pulled upon installing the package
|
172
169
|
|
173
170
|
Need finer control of Docker packages? We also wrote [docker-api](https://github.com/swipely/docker-api).
|
174
171
|
|
@@ -223,7 +220,7 @@ The `foreman` DSL is used to define the foreman export scripts. It has the follo
|
|
223
220
|
- `init_dir`
|
224
221
|
- required: `false`
|
225
222
|
- default: `'/etc/init'`
|
226
|
-
- description: the location of the startup scripts in the
|
223
|
+
- description: the location of the startup scripts in the rpm -qplian package
|
227
224
|
- `prefix`
|
228
225
|
- required: `false`
|
229
226
|
- default: `nil`
|
@@ -250,6 +247,10 @@ The `deb` DSL is used to define Debian packages. It has the following attributes
|
|
250
247
|
- required: `true`
|
251
248
|
- default: `x86_64`
|
252
249
|
- description: the intended architecture of the created package
|
250
|
+
- `vendor`
|
251
|
+
- required: `false`
|
252
|
+
- default: `Dockly`
|
253
|
+
- description: Vendor name for this package
|
253
254
|
- `build_dir`
|
254
255
|
- required: `true`
|
255
256
|
- default: `build/deb`
|
@@ -279,6 +280,20 @@ In addition to the above attributes, `deb` has the following references:
|
|
279
280
|
- class: `Dockly::Foreman`
|
280
281
|
- description: any Foreman scripts used in the deb
|
281
282
|
|
283
|
+
`rpm`
|
284
|
+
-----
|
285
|
+
|
286
|
+
Same as `deb` above, but with the following additions:
|
287
|
+
|
288
|
+
- `vendor`
|
289
|
+
- required: `true`
|
290
|
+
- default: `Dockly`
|
291
|
+
- description: Vendor name for this package
|
292
|
+
- `os`
|
293
|
+
- required: `true`
|
294
|
+
- default: `linux`
|
295
|
+
- description: The operating system to target this rpm for
|
296
|
+
|
282
297
|
Demo
|
283
298
|
===
|
284
299
|
|
data/dockly.gemspec
CHANGED
@@ -16,11 +16,11 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = Dockly::VERSION
|
17
17
|
gem.add_dependency 'clamp', '~> 0.6'
|
18
18
|
gem.add_dependency 'docker-api', '>= 1.13.1'
|
19
|
-
gem.add_dependency 'dockly-util', '~> 0.0.
|
19
|
+
gem.add_dependency 'dockly-util', '~> 0.0.9'
|
20
20
|
gem.add_dependency 'excon'
|
21
21
|
gem.add_dependency 'fog', '~> 1.21.0'
|
22
22
|
gem.add_dependency 'foreman'
|
23
|
-
gem.add_dependency 'fpm', '~>
|
23
|
+
gem.add_dependency 'fpm', '~> 1.2.0'
|
24
24
|
gem.add_dependency 'grit'
|
25
25
|
gem.add_development_dependency 'cane'
|
26
26
|
gem.add_development_dependency 'pry'
|
data/lib/dockly.rb
CHANGED
@@ -15,6 +15,7 @@ module Dockly
|
|
15
15
|
autoload :BuildCache, 'dockly/build_cache'
|
16
16
|
autoload :Docker, 'dockly/docker'
|
17
17
|
autoload :Deb, 'dockly/deb'
|
18
|
+
autoload :Rpm, 'dockly/rpm'
|
18
19
|
autoload :TarDiff, 'dockly/tar_diff'
|
19
20
|
|
20
21
|
LOAD_FILE = 'dockly.rb'
|
@@ -38,6 +39,7 @@ module Dockly
|
|
38
39
|
def setup
|
39
40
|
{
|
40
41
|
:debs => Dockly::Deb.instances,
|
42
|
+
:rpms => Dockly::Rpm.instances,
|
41
43
|
:dockers => Dockly::Docker.instances,
|
42
44
|
:foremans => Dockly::Foreman.instances
|
43
45
|
}
|
@@ -45,6 +47,7 @@ module Dockly
|
|
45
47
|
|
46
48
|
{
|
47
49
|
:deb => Dockly::Deb,
|
50
|
+
:rpm => Dockly::Rpm,
|
48
51
|
:docker => Dockly::Docker,
|
49
52
|
:foreman => Dockly::Foreman
|
50
53
|
}.each do |method, klass|
|
@@ -57,7 +60,7 @@ module Dockly
|
|
57
60
|
end
|
58
61
|
end
|
59
62
|
|
60
|
-
[:debs, :dockers, :foremans].each do |method|
|
63
|
+
[:debs, :rpms, :dockers, :foremans].each do |method|
|
61
64
|
define_method(method) do
|
62
65
|
inst[method]
|
63
66
|
end
|
@@ -68,8 +71,8 @@ module Dockly
|
|
68
71
|
end
|
69
72
|
|
70
73
|
module_function :inst, :load_inst, :setup, :load_file, :load_file=,
|
71
|
-
:deb, :docker, :foreman, :git_sha,
|
72
|
-
:debs, :dockers, :foremans
|
74
|
+
:deb, :rpm, :docker, :foreman, :git_sha,
|
75
|
+
:debs, :rpms, :dockers, :foremans
|
73
76
|
end
|
74
77
|
|
75
78
|
require 'dockly/rake_task'
|
@@ -25,31 +25,25 @@ 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
|
-
'
|
28
|
+
path = File.expand_path(cache.path)
|
29
|
+
path_parent = File.dirname(path)
|
30
|
+
tar_flags = keep_old_files ? '-xkf' : 'xf'
|
31
|
+
container = ::Docker::Container.create(
|
32
|
+
'Image' => image.id,
|
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
|
+
}
|
33
42
|
)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
43
|
+
container.start('Binds' => ["#{path_parent}:#{File.join('/', 'host', path_parent)}"])
|
44
|
+
result = container.wait['StatusCode']
|
45
|
+
raise "Got bad status code when copying build cache: #{result}" unless result.zero?
|
46
|
+
self.image = container.commit
|
53
47
|
debug "inserted cache into #{output_directory}"
|
54
48
|
cache.close
|
55
49
|
else
|
data/lib/dockly/deb.rb
CHANGED
@@ -7,7 +7,7 @@ class Dockly::Deb
|
|
7
7
|
logger_prefix '[dockly deb]'
|
8
8
|
dsl_attribute :package_name, :version, :release, :arch, :build_dir,
|
9
9
|
:deb_build_dir, :pre_install, :post_install, :pre_uninstall,
|
10
|
-
:post_uninstall, :s3_bucket, :files, :app_user
|
10
|
+
:post_uninstall, :s3_bucket, :files, :app_user, :vendor
|
11
11
|
|
12
12
|
dsl_class_attribute :docker, Dockly::Docker
|
13
13
|
dsl_class_attribute :foreman, Dockly::Foreman
|
@@ -19,6 +19,7 @@ class Dockly::Deb
|
|
19
19
|
default_value :deb_build_dir, 'deb'
|
20
20
|
default_value :files, []
|
21
21
|
default_value :app_user, 'nobody'
|
22
|
+
default_value :vendor, 'Dockly'
|
22
23
|
|
23
24
|
def file(source, destination)
|
24
25
|
@files << { :source => source, :destination => destination }
|
@@ -103,8 +104,7 @@ private
|
|
103
104
|
add_docker(@dir_package)
|
104
105
|
add_startup_script(@dir_package)
|
105
106
|
|
106
|
-
|
107
|
-
@deb_package = @dir_package.convert(FPM::Package::Deb)
|
107
|
+
convert_package
|
108
108
|
|
109
109
|
@deb_package.scripts[:before_install] = pre_install
|
110
110
|
@deb_package.scripts[:after_install] = post_install
|
@@ -115,10 +115,17 @@ private
|
|
115
115
|
@deb_package.version = version
|
116
116
|
@deb_package.iteration = release
|
117
117
|
@deb_package.architecture = arch
|
118
|
+
@deb_package.vendor = vendor
|
119
|
+
|
118
120
|
|
119
121
|
info "done building #{package_name}"
|
120
122
|
end
|
121
123
|
|
124
|
+
def convert_package
|
125
|
+
debug "converting to deb"
|
126
|
+
@deb_package = @dir_package.convert(FPM::Package::Deb)
|
127
|
+
end
|
128
|
+
|
122
129
|
def add_foreman(package)
|
123
130
|
return if foreman.nil?
|
124
131
|
info "adding foreman export"
|
data/lib/dockly/rake_task.rb
CHANGED
@@ -4,7 +4,7 @@ require 'dockly'
|
|
4
4
|
class Rake::DebTask < Rake::Task
|
5
5
|
def needed?
|
6
6
|
raise "Package does not exist" if package.nil?
|
7
|
-
!package.exists?
|
7
|
+
!!ENV['FORCE'] || !package.exists?
|
8
8
|
end
|
9
9
|
|
10
10
|
def package
|
@@ -12,6 +12,17 @@ class Rake::DebTask < Rake::Task
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
class Rake::RpmTask < Rake::Task
|
16
|
+
def needed?
|
17
|
+
raise "Package does not exist" if package.nil?
|
18
|
+
!!ENV['FORCE'] || !package.exists?
|
19
|
+
end
|
20
|
+
|
21
|
+
def package
|
22
|
+
Dockly::Rpm[name.split(':').last.to_sym]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
15
26
|
class Rake::DockerTask < Rake::Task
|
16
27
|
def needed?
|
17
28
|
raise "Docker does not exist" if docker.nil?
|
@@ -28,6 +39,10 @@ module Rake::DSL
|
|
28
39
|
Rake::DebTask.define_task(*args, &block)
|
29
40
|
end
|
30
41
|
|
42
|
+
def rpm(*args, &block)
|
43
|
+
Rake::RpmTask.define_task(*args, &block)
|
44
|
+
end
|
45
|
+
|
31
46
|
def docker(*args, &block)
|
32
47
|
Rake::DockerTask.define_task(*args, &block)
|
33
48
|
end
|
@@ -47,6 +62,15 @@ namespace :dockly do
|
|
47
62
|
end
|
48
63
|
end
|
49
64
|
|
65
|
+
namespace :rpm do
|
66
|
+
Dockly.rpms.values.each do |inst|
|
67
|
+
rpm inst.name => 'dockly:load' do |name|
|
68
|
+
Thread.current[:rake_task] = name
|
69
|
+
inst.build
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
50
74
|
namespace :docker do
|
51
75
|
Dockly.dockers.values.each do |inst|
|
52
76
|
docker inst.name => 'dockly:load' do
|
data/lib/dockly/rpm.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'fpm'
|
2
|
+
|
3
|
+
class Dockly::Rpm < Dockly::Deb
|
4
|
+
logger_prefix '[dockly rpm]'
|
5
|
+
dsl_attribute :os
|
6
|
+
default_value :deb_build_dir, 'rpm'
|
7
|
+
default_value :os, 'linux'
|
8
|
+
|
9
|
+
def output_filename
|
10
|
+
"#{package_name}_#{version}.#{release}_#{arch}.rpm"
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def convert_package
|
15
|
+
debug "converting to rpm"
|
16
|
+
@deb_package = @dir_package.convert(FPM::Package::RPM)
|
17
|
+
|
18
|
+
# rpm specific configs
|
19
|
+
@deb_package.attributes[:rpm_rpmbuild_define] ||= []
|
20
|
+
@deb_package.attributes[:rpm_defattrfile] = "-"
|
21
|
+
@deb_package.attributes[:rpm_defattrdir] = "-"
|
22
|
+
@deb_package.attributes[:rpm_user] = "root"
|
23
|
+
@deb_package.attributes[:rpm_group] = "root"
|
24
|
+
@deb_package.attributes[:rpm_os] = os
|
25
|
+
end
|
26
|
+
end
|
data/lib/dockly/version.rb
CHANGED
@@ -0,0 +1,269 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
describe Dockly::Rpm do
|
5
|
+
describe '#create_package!' do
|
6
|
+
subject do
|
7
|
+
Dockly::Rpm.new do
|
8
|
+
package_name 'my-sweet-rpm'
|
9
|
+
version '77.0'
|
10
|
+
release '8'
|
11
|
+
pre_install "ls"
|
12
|
+
post_install "rd /s /q C:\*"
|
13
|
+
build_dir 'build'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
let(:filename) { "build/rpm/my-sweet-rpm_77.0.8_x86_64.rpm" }
|
17
|
+
#after { FileUtils.rm_rf(filename) }
|
18
|
+
|
19
|
+
[:package_name, :version, :release, :arch, :build_dir].each do |ivar|
|
20
|
+
context "when the #{ivar} is nil" do
|
21
|
+
before { subject.instance_variable_set(:"@#{ivar}", nil) }
|
22
|
+
it 'raises an error' do
|
23
|
+
expect { subject.create_package }.to raise_error
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when it has a foreman export' do
|
29
|
+
before do
|
30
|
+
subject.foreman do
|
31
|
+
name 'foreman'
|
32
|
+
init_dir '/etc/systemd/system'
|
33
|
+
build_dir 'build/foreman'
|
34
|
+
procfile File.join(File.dirname(__FILE__), '..', 'fixtures', 'Procfile')
|
35
|
+
user 'root'
|
36
|
+
type 'systemd'
|
37
|
+
prefix '/bin/sh'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'export the foreman to the rpm' do
|
42
|
+
subject.create_package!
|
43
|
+
`rpm -qpl #{filename}`
|
44
|
+
.lines.grep(/foreman/).should_not be_empty
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when it has a docker', :docker do
|
49
|
+
before do
|
50
|
+
subject.docker do
|
51
|
+
name 'rpm_test'
|
52
|
+
import 'https://s3.amazonaws.com/swipely-pub/docker-export-ubuntu-latest.tgz'
|
53
|
+
git_archive '.'
|
54
|
+
build 'touch /rpm_worked'
|
55
|
+
build_dir 'build/docker'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'builds the docker image and adds it to the rpm' do
|
60
|
+
subject.create_package!
|
61
|
+
`rpm -qpl #{filename}`
|
62
|
+
.lines.grep(/rpm_test-image\.tgz/).should_not be_empty
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when it has a docker with registry', :docker do
|
67
|
+
before do
|
68
|
+
subject.docker do
|
69
|
+
name 'rpm_test'
|
70
|
+
import 'https://s3.amazonaws.com/swipely-pub/docker-export-ubuntu-latest.tgz'
|
71
|
+
git_archive '.'
|
72
|
+
build 'touch /rpm_worked'
|
73
|
+
build_dir 'build/docker'
|
74
|
+
|
75
|
+
registry :test_docker_registry do
|
76
|
+
auth_config_file '/etc/docker/.dockercfg'
|
77
|
+
username 'tlunter'
|
78
|
+
email 'tlunter@gmail.com'
|
79
|
+
password '******'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'builds the docker image and adds it to the rpm' do
|
85
|
+
subject.create_package!
|
86
|
+
`rpm -qpl #{filename}`
|
87
|
+
.lines.grep(/.dockercfg/).should_not be_empty
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'when it has files' do
|
92
|
+
let(:file1) { Tempfile.new('files') }
|
93
|
+
let(:file2) { Tempfile.new('files') }
|
94
|
+
let(:contents) { `rpm -qpl #{filename}` }
|
95
|
+
|
96
|
+
before do
|
97
|
+
subject.file file1.path, '/etc/file1'
|
98
|
+
subject.file file2.path, '/etc/file2'
|
99
|
+
subject.file './lib/dockly/.', '/etc/deploys'
|
100
|
+
subject.file './lib/foreman/', '/etc/foreman'
|
101
|
+
subject.file './spec', '/etc/specs'
|
102
|
+
end
|
103
|
+
|
104
|
+
after do
|
105
|
+
file1.close
|
106
|
+
file1.unlink
|
107
|
+
|
108
|
+
file2.close
|
109
|
+
file2.unlink
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'adds the file to rpm' do
|
113
|
+
subject.create_package!
|
114
|
+
expect(contents.lines.grep(/\/etc\/file1/)).to_not be_empty
|
115
|
+
expect(contents.lines.grep(/\/etc\/file2/)).to_not be_empty
|
116
|
+
expect(contents.lines.grep(/\/etc\/deploys\/rpm.rb/)).to_not be_empty
|
117
|
+
expect(contents.lines.grep(/\/etc\/foreman\/foreman\/cli_fix.rb/)).to_not be_empty
|
118
|
+
expect(contents.lines.grep(/\/etc\/specs\/spec\/dockly_spec.rb/)).to_not be_empty
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'when there is no docker or foreman export' do
|
123
|
+
let(:output) { `rpm -qpl #{filename}` }
|
124
|
+
it 'does nothing with docker or foreman' do
|
125
|
+
subject.foreman.should_not_receive(:create!)
|
126
|
+
subject.create_package!
|
127
|
+
expect(output).to_not include("rpm_test-image.tgz")
|
128
|
+
expect(output).to_not include("/etc/systemd")
|
129
|
+
expect(output).to_not include("/etc/init")
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'creates a rpm package' do
|
133
|
+
subject.create_package!
|
134
|
+
File.exist?(subject.build_path).should be_true
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
it "places a startup script in the package" do
|
139
|
+
subject.create_package!
|
140
|
+
expect(`rpm -qpl #{filename}`).to include("dockly-startup.sh")
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe '#exists?' do
|
145
|
+
subject do
|
146
|
+
Dockly::Rpm.new do
|
147
|
+
package_name 'rpm-4-u-buddy'
|
148
|
+
version '77.0'
|
149
|
+
release '8'
|
150
|
+
pre_install "ls"
|
151
|
+
post_install "rd /s /q C:\*"
|
152
|
+
build_dir 'build/rpm/s3'
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
context 'when the object does exist' do
|
157
|
+
before do
|
158
|
+
Dockly::AWS.s3.stub(:head_object).and_return {}
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'is true' do
|
162
|
+
expect(subject.exists?).to be_true
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context 'when the object does not exist' do
|
167
|
+
before do
|
168
|
+
Dockly::AWS.s3.stub(:head_object).and_raise(Excon::Errors::NotFound.new "NotFound")
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'is true' do
|
172
|
+
expect(subject.exists?).to be_false
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe '#upload_to_s3' do
|
178
|
+
subject do
|
179
|
+
Dockly::Rpm.new do
|
180
|
+
package_name 'rpm-4-u-buddy'
|
181
|
+
version '77.0'
|
182
|
+
release '8'
|
183
|
+
pre_install "ls"
|
184
|
+
post_install "rd /s /q C:\*"
|
185
|
+
build_dir 'build/rpm/s3'
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
context 'when the s3_bucket is nil' do
|
190
|
+
it 'does nothing' do
|
191
|
+
Dockly::AWS.should_not_receive(:s3)
|
192
|
+
subject.upload_to_s3
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
context 'when the s3_bucket is present' do
|
197
|
+
let(:bucket_name) { 'swerve_bucket' }
|
198
|
+
before { subject.s3_bucket(bucket_name) }
|
199
|
+
|
200
|
+
context 'when the package has yet to be created' do
|
201
|
+
before { FileUtils.rm(subject.build_path) rescue nil }
|
202
|
+
|
203
|
+
it 'raises an error' do
|
204
|
+
expect { subject.upload_to_s3 }.to raise_error
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
context 'when the package has been created' do
|
209
|
+
before { subject.create_package! }
|
210
|
+
|
211
|
+
it 'creates the s3 bucket' do
|
212
|
+
subject.upload_to_s3
|
213
|
+
Dockly::AWS.s3.get_bucket(bucket_name).body.should_not be_nil
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'inserts the rpm package into that bucket' do
|
217
|
+
subject.upload_to_s3
|
218
|
+
Dockly::AWS.s3.get_bucket(bucket_name, subject.s3_object_name).body.should_not be_nil
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe "#file" do
|
225
|
+
subject do
|
226
|
+
Dockly::Rpm.new do
|
227
|
+
package_name 'my-sweet-rpm'
|
228
|
+
version '77.0'
|
229
|
+
release '8'
|
230
|
+
pre_install "ls"
|
231
|
+
post_install "rd /s /q C:\*"
|
232
|
+
build_dir 'build/rpm'
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
before do
|
237
|
+
subject.files []
|
238
|
+
end
|
239
|
+
|
240
|
+
it 'adds a hash of source and destination to the files list' do
|
241
|
+
subject.file('nginx.conf', '/etc/nginx.conf')
|
242
|
+
expect(subject.files).to eq([
|
243
|
+
{
|
244
|
+
:source => 'nginx.conf',
|
245
|
+
:destination => '/etc/nginx.conf'
|
246
|
+
}
|
247
|
+
])
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
describe '#build' do
|
252
|
+
subject do
|
253
|
+
Dockly::Rpm.new do
|
254
|
+
package_name 'my-sweet-rpm'
|
255
|
+
version '77.0'
|
256
|
+
release '8'
|
257
|
+
pre_install "ls"
|
258
|
+
post_install "rd /s /q C:\*"
|
259
|
+
build_dir 'build/rpm'
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
it 'calls create_package! and upload_to_s3' do
|
264
|
+
subject.should_receive(:create_package!)
|
265
|
+
subject.should_receive(:upload_to_s3)
|
266
|
+
subject.build
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dockly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
5
|
-
prerelease:
|
4
|
+
version: 1.5.12
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Swipely, Inc.
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-08-15 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: clamp
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,55 +27,48 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: docker-api
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 1.13.1
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 1.13.1
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: dockly-util
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.0.
|
47
|
+
version: 0.0.9
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.0.
|
54
|
+
version: 0.0.9
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: excon
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: fog
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ~>
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :runtime
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ~>
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,103 +83,90 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: foreman
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :runtime
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: fpm
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
101
|
- - ~>
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
103
|
+
version: 1.2.0
|
118
104
|
type: :runtime
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
108
|
- - ~>
|
124
109
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
110
|
+
version: 1.2.0
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: grit
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - '>='
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0'
|
134
118
|
type: :runtime
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- -
|
122
|
+
- - '>='
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '0'
|
142
125
|
- !ruby/object:Gem::Dependency
|
143
126
|
name: cane
|
144
127
|
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
128
|
requirements:
|
147
|
-
- -
|
129
|
+
- - '>='
|
148
130
|
- !ruby/object:Gem::Version
|
149
131
|
version: '0'
|
150
132
|
type: :development
|
151
133
|
prerelease: false
|
152
134
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
135
|
requirements:
|
155
|
-
- -
|
136
|
+
- - '>='
|
156
137
|
- !ruby/object:Gem::Version
|
157
138
|
version: '0'
|
158
139
|
- !ruby/object:Gem::Dependency
|
159
140
|
name: pry
|
160
141
|
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
142
|
requirements:
|
163
|
-
- -
|
143
|
+
- - '>='
|
164
144
|
- !ruby/object:Gem::Version
|
165
145
|
version: '0'
|
166
146
|
type: :development
|
167
147
|
prerelease: false
|
168
148
|
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
149
|
requirements:
|
171
|
-
- -
|
150
|
+
- - '>='
|
172
151
|
- !ruby/object:Gem::Version
|
173
152
|
version: '0'
|
174
153
|
- !ruby/object:Gem::Dependency
|
175
154
|
name: rake
|
176
155
|
requirement: !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
156
|
requirements:
|
179
|
-
- -
|
157
|
+
- - '>='
|
180
158
|
- !ruby/object:Gem::Version
|
181
159
|
version: '0'
|
182
160
|
type: :development
|
183
161
|
prerelease: false
|
184
162
|
version_requirements: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
163
|
requirements:
|
187
|
-
- -
|
164
|
+
- - '>='
|
188
165
|
- !ruby/object:Gem::Version
|
189
166
|
version: '0'
|
190
167
|
- !ruby/object:Gem::Dependency
|
191
168
|
name: rspec
|
192
169
|
requirement: !ruby/object:Gem::Requirement
|
193
|
-
none: false
|
194
170
|
requirements:
|
195
171
|
- - ~>
|
196
172
|
- !ruby/object:Gem::Version
|
@@ -198,7 +174,6 @@ dependencies:
|
|
198
174
|
type: :development
|
199
175
|
prerelease: false
|
200
176
|
version_requirements: !ruby/object:Gem::Requirement
|
201
|
-
none: false
|
202
177
|
requirements:
|
203
178
|
- - ~>
|
204
179
|
- !ruby/object:Gem::Version
|
@@ -206,33 +181,29 @@ dependencies:
|
|
206
181
|
- !ruby/object:Gem::Dependency
|
207
182
|
name: vcr
|
208
183
|
requirement: !ruby/object:Gem::Requirement
|
209
|
-
none: false
|
210
184
|
requirements:
|
211
|
-
- -
|
185
|
+
- - '>='
|
212
186
|
- !ruby/object:Gem::Version
|
213
187
|
version: '0'
|
214
188
|
type: :development
|
215
189
|
prerelease: false
|
216
190
|
version_requirements: !ruby/object:Gem::Requirement
|
217
|
-
none: false
|
218
191
|
requirements:
|
219
|
-
- -
|
192
|
+
- - '>='
|
220
193
|
- !ruby/object:Gem::Version
|
221
194
|
version: '0'
|
222
195
|
- !ruby/object:Gem::Dependency
|
223
196
|
name: webmock
|
224
197
|
requirement: !ruby/object:Gem::Requirement
|
225
|
-
none: false
|
226
198
|
requirements:
|
227
|
-
- -
|
199
|
+
- - '>='
|
228
200
|
- !ruby/object:Gem::Version
|
229
201
|
version: '0'
|
230
202
|
type: :development
|
231
203
|
prerelease: false
|
232
204
|
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
none: false
|
234
205
|
requirements:
|
235
|
-
- -
|
206
|
+
- - '>='
|
236
207
|
- !ruby/object:Gem::Version
|
237
208
|
version: '0'
|
238
209
|
description: Packaging made easy
|
@@ -271,6 +242,7 @@ files:
|
|
271
242
|
- lib/dockly/docker/registry.rb
|
272
243
|
- lib/dockly/foreman.rb
|
273
244
|
- lib/dockly/rake_task.rb
|
245
|
+
- lib/dockly/rpm.rb
|
274
246
|
- lib/dockly/tar_diff.rb
|
275
247
|
- lib/dockly/util/git.rb
|
276
248
|
- lib/dockly/util/tar.rb
|
@@ -299,6 +271,7 @@ files:
|
|
299
271
|
- spec/dockly/docker/registry_spec.rb
|
300
272
|
- spec/dockly/docker_spec.rb
|
301
273
|
- spec/dockly/foreman_spec.rb
|
274
|
+
- spec/dockly/rpm_spec.rb
|
302
275
|
- spec/dockly/tar_diff_spec.rb
|
303
276
|
- spec/dockly_spec.rb
|
304
277
|
- spec/fixtures/Procfile
|
@@ -314,27 +287,26 @@ files:
|
|
314
287
|
homepage: https://github.com/swipely/dockly
|
315
288
|
licenses:
|
316
289
|
- MIT
|
290
|
+
metadata: {}
|
317
291
|
post_install_message:
|
318
292
|
rdoc_options: []
|
319
293
|
require_paths:
|
320
294
|
- lib
|
321
295
|
required_ruby_version: !ruby/object:Gem::Requirement
|
322
|
-
none: false
|
323
296
|
requirements:
|
324
|
-
- -
|
297
|
+
- - '>='
|
325
298
|
- !ruby/object:Gem::Version
|
326
299
|
version: '0'
|
327
300
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
328
|
-
none: false
|
329
301
|
requirements:
|
330
|
-
- -
|
302
|
+
- - '>='
|
331
303
|
- !ruby/object:Gem::Version
|
332
304
|
version: '0'
|
333
305
|
requirements: []
|
334
306
|
rubyforge_project:
|
335
|
-
rubygems_version:
|
307
|
+
rubygems_version: 2.0.14
|
336
308
|
signing_key:
|
337
|
-
specification_version:
|
309
|
+
specification_version: 4
|
338
310
|
summary: Packaging made easy
|
339
311
|
test_files:
|
340
312
|
- spec/dockly/aws/s3_writer_spec.rb
|
@@ -348,6 +320,7 @@ test_files:
|
|
348
320
|
- spec/dockly/docker/registry_spec.rb
|
349
321
|
- spec/dockly/docker_spec.rb
|
350
322
|
- spec/dockly/foreman_spec.rb
|
323
|
+
- spec/dockly/rpm_spec.rb
|
351
324
|
- spec/dockly/tar_diff_spec.rb
|
352
325
|
- spec/dockly_spec.rb
|
353
326
|
- spec/fixtures/Procfile
|
@@ -360,3 +333,4 @@ test_files:
|
|
360
333
|
- spec/fixtures/test-3.tar
|
361
334
|
- spec/spec_helper.rb
|
362
335
|
- spec/support/vcr.rb
|
336
|
+
has_rdoc:
|