ruby_yacht 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +27 -0
- data/.gitignore +4 -0
- data/.rdoc_options +29 -0
- data/.rspec +1 -0
- data/.rubocop.yml +1156 -0
- data/.travis.yml +4 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +44 -0
- data/LICENSE +8 -0
- data/README.md +216 -0
- data/doc/CONTRIBUTING.md +12 -0
- data/doc/TODO.md +28 -0
- data/doc/configuration_sample.rb +87 -0
- data/lib/ruby_yacht/dsl/app.rb +59 -0
- data/lib/ruby_yacht/dsl/configuration.rb +55 -0
- data/lib/ruby_yacht/dsl/database.rb +57 -0
- data/lib/ruby_yacht/dsl/dns_server.rb +38 -0
- data/lib/ruby_yacht/dsl/dsl.rb +252 -0
- data/lib/ruby_yacht/dsl/project.rb +140 -0
- data/lib/ruby_yacht/dsl.rb +6 -0
- data/lib/ruby_yacht/images/app/Dockerfile.erb +32 -0
- data/lib/ruby_yacht/images/app/checkout.rb +7 -0
- data/lib/ruby_yacht/images/app/startup.rb +17 -0
- data/lib/ruby_yacht/images/app/update_database_config.rb +45 -0
- data/lib/ruby_yacht/images/app-dependencies/Dockerfile.erb +23 -0
- data/lib/ruby_yacht/images/app-dependencies/install_gems.rb +12 -0
- data/lib/ruby_yacht/images/database/Dockerfile.erb +26 -0
- data/lib/ruby_yacht/images/database/load_seeds.rb +42 -0
- data/lib/ruby_yacht/images/database/setup.rb +19 -0
- data/lib/ruby_yacht/images/database/setup_database.sql.erb +12 -0
- data/lib/ruby_yacht/images/deploy/Dockerfile.erb +2 -0
- data/lib/ruby_yacht/images/web/Dockerfile.erb +25 -0
- data/lib/ruby_yacht/images/web/add_app.rb +12 -0
- data/lib/ruby_yacht/images/web/add_project.rb +14 -0
- data/lib/ruby_yacht/images/web/app_config.erb +11 -0
- data/lib/ruby_yacht/images/web/index.html.erb +10 -0
- data/lib/ruby_yacht/images/web/index_config.erb +12 -0
- data/lib/ruby_yacht/images/web/setup.rb +22 -0
- data/lib/ruby_yacht/runner/build.rb +21 -0
- data/lib/ruby_yacht/runner/build_images.rb +82 -0
- data/lib/ruby_yacht/runner/checkout.rb +68 -0
- data/lib/ruby_yacht/runner/command.rb +161 -0
- data/lib/ruby_yacht/runner/help.rb +55 -0
- data/lib/ruby_yacht/runner/implode.rb +33 -0
- data/lib/ruby_yacht/runner/run_containers.rb +105 -0
- data/lib/ruby_yacht/runner/runner.rb +42 -0
- data/lib/ruby_yacht/runner/services.rb +79 -0
- data/lib/ruby_yacht/runner/shell.rb +66 -0
- data/lib/ruby_yacht/runner/update_hosts.rb +72 -0
- data/lib/ruby_yacht/runner.rb +18 -0
- data/lib/ruby_yacht.rb +6 -0
- data/ruby_yacht.gemspec +18 -0
- data/spec/docker/Dockerfile +5 -0
- data/spec/docker/build.bash +10 -0
- data/spec/dsl/app_spec.rb +47 -0
- data/spec/dsl/configuration_spec.rb +64 -0
- data/spec/dsl/database_spec.rb +75 -0
- data/spec/dsl/dns_server_spec.rb +25 -0
- data/spec/dsl/dsl_spec.rb +298 -0
- data/spec/dsl/project_spec.rb +266 -0
- data/spec/fixtures/app-dependencies-dockerfile +25 -0
- data/spec/fixtures/database-dockerfile +31 -0
- data/spec/fixtures/deploy-dockerfile +2 -0
- data/spec/fixtures/mars-dockerfile +32 -0
- data/spec/fixtures/multi-project-web-dockerfile +35 -0
- data/spec/fixtures/web-dockerfile +27 -0
- data/spec/runner/build_images_spec.rb +164 -0
- data/spec/runner/build_spec.rb +86 -0
- data/spec/runner/checkout_spec.rb +128 -0
- data/spec/runner/command_spec.rb +94 -0
- data/spec/runner/help_spec.rb +73 -0
- data/spec/runner/implode_spec.rb +62 -0
- data/spec/runner/run_containers_spec.rb +141 -0
- data/spec/runner/runner_spec.rb +117 -0
- data/spec/runner/services_spec.rb +135 -0
- data/spec/runner/shell_spec.rb +123 -0
- data/spec/runner/update_hosts_spec.rb +163 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/docker_stubbing.rb +93 -0
- data/spec/support/test_project.rb +56 -0
- metadata +193 -0
@@ -0,0 +1,93 @@
|
|
1
|
+
# This class stubs out commands that are sent to docker.
|
2
|
+
#
|
3
|
+
# This allows our tests to confirm that the correct commands
|
4
|
+
# are sent, as well as run blocks at the time commands are sent
|
5
|
+
# to check the context.
|
6
|
+
#
|
7
|
+
# To set an expectation on a command, call the `expect` method.
|
8
|
+
#
|
9
|
+
# By default, any commands that are not sent to `expect` are
|
10
|
+
# ignored. You can call `fail_unexpected_commands!` to raise an
|
11
|
+
# error instead.
|
12
|
+
class DockerStubber
|
13
|
+
# This method creates a new docker stubber.
|
14
|
+
def initialize()
|
15
|
+
@blocks = []
|
16
|
+
@fail_unexpected_commands = false
|
17
|
+
end
|
18
|
+
|
19
|
+
# The blocks to call when we receive commands.
|
20
|
+
attr_accessor :blocks
|
21
|
+
|
22
|
+
# This method tells the stubber to expect a command.
|
23
|
+
#
|
24
|
+
# === Parameters
|
25
|
+
#
|
26
|
+
# [command] The command to expect
|
27
|
+
# [block] The block to call when the command is sent.
|
28
|
+
def expect(command, &block)
|
29
|
+
unless block_given?
|
30
|
+
block = Proc.new {}
|
31
|
+
end
|
32
|
+
@blocks << [command, block]
|
33
|
+
end
|
34
|
+
|
35
|
+
# This method causes the stubber to raise an exception if it receives a
|
36
|
+
# command it doesn't expect.
|
37
|
+
def fail_unexpected_commands!
|
38
|
+
@fail_unexpected_commands = true
|
39
|
+
end
|
40
|
+
|
41
|
+
# This method determines if we have received all the commands that it does not
|
42
|
+
# expect.
|
43
|
+
def has_received_all_commands?
|
44
|
+
@blocks.none?
|
45
|
+
end
|
46
|
+
|
47
|
+
# This method is called when a command is sent to docker.
|
48
|
+
#
|
49
|
+
# === Parameters
|
50
|
+
#
|
51
|
+
# [command: String] The command that was sent to docker.
|
52
|
+
def receive(command)
|
53
|
+
if @fail_unexpected_commands && command != (@blocks[0] || [])[0]
|
54
|
+
message = "DockerStubber received unexpected command: #{command}"
|
55
|
+
if @blocks[0]
|
56
|
+
message += ". Expected #{@blocks[0][0]}"
|
57
|
+
end
|
58
|
+
raise message
|
59
|
+
end
|
60
|
+
|
61
|
+
entry = @blocks.find { |e| e[0] == command }
|
62
|
+
if entry
|
63
|
+
entry[1].call()
|
64
|
+
@blocks.delete(entry)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# This module provides helpers for specs for our commands.
|
70
|
+
#
|
71
|
+
# This defines a `docker` method that gives a `DockerStubber`. It will also tell
|
72
|
+
# the `subject` command to stup to that docker instance, to stub all its logging,
|
73
|
+
# and will configure the test project.
|
74
|
+
module DockerCommandSpec
|
75
|
+
def self.included(klass)
|
76
|
+
klass.let(:docker) { DockerStubber.new }
|
77
|
+
klass.before do
|
78
|
+
@log_entries = []
|
79
|
+
@system_commands = []
|
80
|
+
allow(subject).to receive(:docker) { |value| docker.receive(value) }
|
81
|
+
allow(subject).to receive(:log) { |message| @log_entries << message }
|
82
|
+
allow(subject).to receive(:system) { |command| @system_commands << command; 0 }
|
83
|
+
allow(subject).to receive(:backtick).and_return('')
|
84
|
+
|
85
|
+
FileUtils.rm Dir[File.join('tmp', '*')]
|
86
|
+
RubyYacht.configure_test_project
|
87
|
+
end
|
88
|
+
|
89
|
+
klass.after do
|
90
|
+
expect(docker).to have_received_all_commands
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module RubyYacht
|
2
|
+
def self.configure_test_project
|
3
|
+
RubyYacht.configuration.clear
|
4
|
+
RubyYacht.configure do
|
5
|
+
project :apollo do
|
6
|
+
system_prefix :apollo
|
7
|
+
domain "apollo.test.com"
|
8
|
+
repository "github.com"
|
9
|
+
|
10
|
+
database do
|
11
|
+
host "db.test.com"
|
12
|
+
name "apollo"
|
13
|
+
username "apollo"
|
14
|
+
password "test"
|
15
|
+
end
|
16
|
+
|
17
|
+
app :mars do
|
18
|
+
repository_name 'brownleej/mars'
|
19
|
+
end
|
20
|
+
|
21
|
+
app :saturn do
|
22
|
+
repository_name 'brownleej/saturn'
|
23
|
+
end
|
24
|
+
|
25
|
+
secret_key_base 'abc'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.configure_second_test_project
|
31
|
+
RubyYacht.configure do
|
32
|
+
project :jupiter do
|
33
|
+
system_prefix :jupiter
|
34
|
+
domain "jupiter.test.com"
|
35
|
+
repository "github.com"
|
36
|
+
|
37
|
+
database do
|
38
|
+
host "db.test.com"
|
39
|
+
name "jupiter"
|
40
|
+
username "jupiter"
|
41
|
+
password "test"
|
42
|
+
end
|
43
|
+
|
44
|
+
app :venus do
|
45
|
+
repository_name 'brownleej/venus'
|
46
|
+
end
|
47
|
+
|
48
|
+
app :saturn do
|
49
|
+
repository_name 'brownleej/saturn'
|
50
|
+
end
|
51
|
+
|
52
|
+
secret_key_base 'abc'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby_yacht
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Brownlee
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: codeclimate-test-reporter
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: timecop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email: apps@mail.johnbrownlee.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- .codeclimate.yml
|
62
|
+
- .gitignore
|
63
|
+
- .rdoc_options
|
64
|
+
- .rspec
|
65
|
+
- .rubocop.yml
|
66
|
+
- .travis.yml
|
67
|
+
- Gemfile
|
68
|
+
- Gemfile.lock
|
69
|
+
- LICENSE
|
70
|
+
- README.md
|
71
|
+
- doc/CONTRIBUTING.md
|
72
|
+
- doc/TODO.md
|
73
|
+
- doc/configuration_sample.rb
|
74
|
+
- lib/ruby_yacht.rb
|
75
|
+
- lib/ruby_yacht/dsl.rb
|
76
|
+
- lib/ruby_yacht/dsl/app.rb
|
77
|
+
- lib/ruby_yacht/dsl/configuration.rb
|
78
|
+
- lib/ruby_yacht/dsl/database.rb
|
79
|
+
- lib/ruby_yacht/dsl/dns_server.rb
|
80
|
+
- lib/ruby_yacht/dsl/dsl.rb
|
81
|
+
- lib/ruby_yacht/dsl/project.rb
|
82
|
+
- lib/ruby_yacht/images/app-dependencies/Dockerfile.erb
|
83
|
+
- lib/ruby_yacht/images/app-dependencies/install_gems.rb
|
84
|
+
- lib/ruby_yacht/images/app/Dockerfile.erb
|
85
|
+
- lib/ruby_yacht/images/app/checkout.rb
|
86
|
+
- lib/ruby_yacht/images/app/startup.rb
|
87
|
+
- lib/ruby_yacht/images/app/update_database_config.rb
|
88
|
+
- lib/ruby_yacht/images/database/Dockerfile.erb
|
89
|
+
- lib/ruby_yacht/images/database/load_seeds.rb
|
90
|
+
- lib/ruby_yacht/images/database/setup.rb
|
91
|
+
- lib/ruby_yacht/images/database/setup_database.sql.erb
|
92
|
+
- lib/ruby_yacht/images/deploy/Dockerfile.erb
|
93
|
+
- lib/ruby_yacht/images/web/Dockerfile.erb
|
94
|
+
- lib/ruby_yacht/images/web/add_app.rb
|
95
|
+
- lib/ruby_yacht/images/web/add_project.rb
|
96
|
+
- lib/ruby_yacht/images/web/app_config.erb
|
97
|
+
- lib/ruby_yacht/images/web/index.html.erb
|
98
|
+
- lib/ruby_yacht/images/web/index_config.erb
|
99
|
+
- lib/ruby_yacht/images/web/setup.rb
|
100
|
+
- lib/ruby_yacht/runner.rb
|
101
|
+
- lib/ruby_yacht/runner/build.rb
|
102
|
+
- lib/ruby_yacht/runner/build_images.rb
|
103
|
+
- lib/ruby_yacht/runner/checkout.rb
|
104
|
+
- lib/ruby_yacht/runner/command.rb
|
105
|
+
- lib/ruby_yacht/runner/help.rb
|
106
|
+
- lib/ruby_yacht/runner/implode.rb
|
107
|
+
- lib/ruby_yacht/runner/run_containers.rb
|
108
|
+
- lib/ruby_yacht/runner/runner.rb
|
109
|
+
- lib/ruby_yacht/runner/services.rb
|
110
|
+
- lib/ruby_yacht/runner/shell.rb
|
111
|
+
- lib/ruby_yacht/runner/update_hosts.rb
|
112
|
+
- ruby_yacht.gemspec
|
113
|
+
- spec/docker/Dockerfile
|
114
|
+
- spec/docker/build.bash
|
115
|
+
- spec/dsl/app_spec.rb
|
116
|
+
- spec/dsl/configuration_spec.rb
|
117
|
+
- spec/dsl/database_spec.rb
|
118
|
+
- spec/dsl/dns_server_spec.rb
|
119
|
+
- spec/dsl/dsl_spec.rb
|
120
|
+
- spec/dsl/project_spec.rb
|
121
|
+
- spec/fixtures/app-dependencies-dockerfile
|
122
|
+
- spec/fixtures/database-dockerfile
|
123
|
+
- spec/fixtures/deploy-dockerfile
|
124
|
+
- spec/fixtures/mars-dockerfile
|
125
|
+
- spec/fixtures/multi-project-web-dockerfile
|
126
|
+
- spec/fixtures/web-dockerfile
|
127
|
+
- spec/runner/build_images_spec.rb
|
128
|
+
- spec/runner/build_spec.rb
|
129
|
+
- spec/runner/checkout_spec.rb
|
130
|
+
- spec/runner/command_spec.rb
|
131
|
+
- spec/runner/help_spec.rb
|
132
|
+
- spec/runner/implode_spec.rb
|
133
|
+
- spec/runner/run_containers_spec.rb
|
134
|
+
- spec/runner/runner_spec.rb
|
135
|
+
- spec/runner/services_spec.rb
|
136
|
+
- spec/runner/shell_spec.rb
|
137
|
+
- spec/runner/update_hosts_spec.rb
|
138
|
+
- spec/spec_helper.rb
|
139
|
+
- spec/support/docker_stubbing.rb
|
140
|
+
- spec/support/test_project.rb
|
141
|
+
homepage: https://github.com/brownleej/ruby-yacht
|
142
|
+
licenses:
|
143
|
+
- MIT
|
144
|
+
metadata: {}
|
145
|
+
post_install_message:
|
146
|
+
rdoc_options: []
|
147
|
+
require_paths:
|
148
|
+
- lib
|
149
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
requirements: []
|
160
|
+
rubyforge_project:
|
161
|
+
rubygems_version: 2.0.14.1
|
162
|
+
signing_key:
|
163
|
+
specification_version: 4
|
164
|
+
summary: A DSL for building docker containers for a family of Rails apps
|
165
|
+
test_files:
|
166
|
+
- spec/docker/Dockerfile
|
167
|
+
- spec/docker/build.bash
|
168
|
+
- spec/dsl/app_spec.rb
|
169
|
+
- spec/dsl/configuration_spec.rb
|
170
|
+
- spec/dsl/database_spec.rb
|
171
|
+
- spec/dsl/dns_server_spec.rb
|
172
|
+
- spec/dsl/dsl_spec.rb
|
173
|
+
- spec/dsl/project_spec.rb
|
174
|
+
- spec/fixtures/app-dependencies-dockerfile
|
175
|
+
- spec/fixtures/database-dockerfile
|
176
|
+
- spec/fixtures/deploy-dockerfile
|
177
|
+
- spec/fixtures/mars-dockerfile
|
178
|
+
- spec/fixtures/multi-project-web-dockerfile
|
179
|
+
- spec/fixtures/web-dockerfile
|
180
|
+
- spec/runner/build_images_spec.rb
|
181
|
+
- spec/runner/build_spec.rb
|
182
|
+
- spec/runner/checkout_spec.rb
|
183
|
+
- spec/runner/command_spec.rb
|
184
|
+
- spec/runner/help_spec.rb
|
185
|
+
- spec/runner/implode_spec.rb
|
186
|
+
- spec/runner/run_containers_spec.rb
|
187
|
+
- spec/runner/runner_spec.rb
|
188
|
+
- spec/runner/services_spec.rb
|
189
|
+
- spec/runner/shell_spec.rb
|
190
|
+
- spec/runner/update_hosts_spec.rb
|
191
|
+
- spec/spec_helper.rb
|
192
|
+
- spec/support/docker_stubbing.rb
|
193
|
+
- spec/support/test_project.rb
|