orchestration 0.5.8 → 0.5.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a68a281672878086f5ebc086998c3e37aba04dabaff40b6d677144e59ee6ca4a
4
- data.tar.gz: f601425345ad35f9b0e5478e62901fbddf91261b3f2f36071d07e365664ec794
3
+ metadata.gz: 037e3ae31fd0262ecde552e105f6313346a790cd8a0325d5162343352c9e972a
4
+ data.tar.gz: '057219101c53b9046d4b3d5e56c8ee8232aa12bcac73e33aa13e60bf5c831b22'
5
5
  SHA512:
6
- metadata.gz: f33f122d8098d2eae2157e94e6c65b2b548d752d1339ab1f83170913264e09b01b2db8e835b5fbee8c48a1cad346622ca4875d0d253f5f0d946801164288a8f2
7
- data.tar.gz: a34869f47a254f369ca41d487bc13186e367f4671c22d02d503f0a1b8f86557ce26faa712c7dff9db5f44ff7ab01cadbbc579b04670366fc17b986d8f2458d5f
6
+ metadata.gz: 7e678adc9b3ec89927df730b2f18e6a32dd3da17c84c6dfb77926309523854b7abfa8d29422b00fce976ec269dc48285bded35c3995004d71cca56328d73223f
7
+ data.tar.gz: 4f25a1bbb55d3bda4df651045f9919de417e9c8eada7cbcd6b5c00ce77308db3793b019e2b1a102771c73c2c878c032c5ac0cb75d0f8de9b7d1de3da5fb59471
data/README.md CHANGED
@@ -27,7 +27,7 @@ The below screenshot demonstrates _Orchestration_ being installed in a brand new
27
27
  Add _Orchestration_ to your Gemfile:
28
28
 
29
29
  ```ruby
30
- gem 'orchestration', '~> 0.5.8'
30
+ gem 'orchestration', '~> 0.5.13'
31
31
  ```
32
32
 
33
33
  Install:
@@ -191,12 +191,20 @@ make serve server='-p 3001 -b 192.168.0.1'
191
191
  A default `test` target is provided in your application's main `Makefile`. You are encouraged to modify this target to suit your application's requirements.
192
192
 
193
193
  To launch all dependency containers, run database migrations, and run tests:
194
- ```
194
+ ```bash
195
195
  make test
196
196
  ```
197
197
 
198
- If you prefer to run tests manually (e.g. if you want to run tests for a specific file) then the `test-setup` target can be used:
198
+ The default `test` command can (and should) be extended. This command is defined in the root `Makefile` in the project and, by defaults, runs `rspec` and `rubocop`.
199
+
200
+ To run only the `test` command, without test setup (i.e. without restarting containers etc.), pass the `light` option:
201
+
202
+ ```bash
203
+ make test light=1
199
204
  ```
205
+
206
+ If you prefer to run tests manually (e.g. if you want to run tests for a specific file) then the `test-setup` target can be used:
207
+ ```bash
200
208
  make test-setup
201
209
  bundle exec rspec spec/my_class_spec.rb
202
210
  ```
@@ -394,12 +402,15 @@ _Orchestration_ generates the following `config/rabbitmq.yml`:
394
402
  ```
395
403
  development:
396
404
  url: amqp://127.0.0.1:51070
405
+ management_url: http://127.0.0.1:5069
397
406
 
398
407
  test:
399
408
  url: amqp://127.0.0.1:51068
409
+ management_url: http://127.0.0.1:5067
400
410
 
401
411
  production:
402
412
  url: <%= ENV['RABBITMQ_URL'] %>
413
+ management_url: <%= ENV['RABBITMQ_MANAGEMENT_URL'] %>
403
414
  ```
404
415
 
405
416
  Using this approach, the environment variable `RABBITMQ_URL` can be used to configure _Bunny_ in production (similar to `DATABASE_URL` and `MONGO_URL`).
@@ -100,7 +100,13 @@ module Orchestration
100
100
  'WEB_PRELOAD_APP' => '1',
101
101
  'WEB_HEALTHCHECK_PATH' => '/',
102
102
  'DATABASE_URL' => database_url
103
- }.merge(Hash[inherited_environment.map { |key| [key, nil] }])
103
+ }.merge(inherited_environment.map { |key| [key, nil] }.to_h).merge(rabbitmq_urls)
104
+ end
105
+
106
+ def rabbitmq_urls
107
+ return {} unless Services::RabbitMQ::Configuration.new(Environment.new).enabled?
108
+
109
+ { 'RABBITMQ_URL' => 'amqp://rabbitmq:5672', 'RABBITMQ_MANAGEMENT_URL' => 'http://rabbitmq:15672' }
104
110
  end
105
111
 
106
112
  def database_url
@@ -14,7 +14,7 @@ module Orchestration
14
14
  end
15
15
 
16
16
  def services
17
- Hash[services_enabled]
17
+ services_enabled.to_h
18
18
  end
19
19
 
20
20
  def volumes
@@ -62,6 +62,7 @@ module Orchestration
62
62
  .fetch(service)
63
63
  .new(config, @environment)
64
64
  .definition
65
+ &.tap { |definition| definition['networks'] ||= { 'local' => {} } }
65
66
  end
66
67
  end
67
68
  end
@@ -42,7 +42,7 @@ module Orchestration
42
42
  'version' => compose_config(environment).version,
43
43
  'services' => services(environment),
44
44
  'volumes' => volumes(environment),
45
- 'networks' => networks(environment)
45
+ 'networks' => compose_config(environment).networks
46
46
  }
47
47
  end
48
48
 
@@ -56,17 +56,11 @@ module Orchestration
56
56
  compose_config(environment).volumes
57
57
  end
58
58
 
59
- def networks(environment)
60
- return {} unless environment == :production
61
-
62
- compose_config(environment).networks
63
- end
64
-
65
59
  def compose_config(environment)
66
60
  DockerCompose::Configuration.new(
67
61
  @env,
68
62
  environment,
69
- Hash[configurations(environment)]
63
+ configurations(environment).to_h
70
64
  )
71
65
  end
72
66
 
@@ -13,15 +13,17 @@ module Orchestration
13
13
  def definition
14
14
  return nil unless @config.enabled?
15
15
 
16
- { 'image' => 'library/rabbitmq' }.merge(ports)
16
+ { 'image' => 'library/rabbitmq:management' }.merge(ports)
17
17
  end
18
18
 
19
19
  def ports
20
20
  return {} unless %i[development test].include?(@environment)
21
21
 
22
22
  container_port = Orchestration::Services::RabbitMQ::PORT
23
+ management_port = Orchestration::Services::RabbitMQ::MANAGEMENT_PORT
23
24
 
24
- { 'ports' => ["#{sidecar_port(@environment)}#{container_port}"] }
25
+ { 'ports' => ["#{sidecar_port(@environment)}#{container_port}",
26
+ "#{sidecar_port(@environment)}#{management_port}"] }
25
27
  end
26
28
  end
27
29
  end
@@ -129,7 +129,7 @@ module Orchestration
129
129
  def docker_filter(string)
130
130
  # Filter out characters not accepted by Docker Hub
131
131
  permitted = [('0'..'9'), ('a'..'z')].map(&:to_a).flatten
132
- string.split('').select { |char| permitted.include?(char) }.join
132
+ string.chars.select { |char| permitted.include?(char) }.join
133
133
  end
134
134
  end
135
135
  end
@@ -4,7 +4,9 @@ module Orchestration
4
4
  class OrchestrationError < StandardError; end
5
5
 
6
6
  class HTTPConnectionError < OrchestrationError; end
7
+
7
8
  class DatabaseConfigurationError < OrchestrationError; end
9
+
8
10
  class MongoConfigurationError < OrchestrationError; end
9
11
 
10
12
  class UnknownEnvironmentError < DatabaseConfigurationError; end
@@ -10,7 +10,7 @@ module Orchestration
10
10
  end
11
11
 
12
12
  def image
13
- return mysql5_7 if gem_version < Gem::Version.new('0.4')
13
+ return mysql57 if gem_version < Gem::Version.new('0.4')
14
14
 
15
15
  'library/mysql'
16
16
  end
@@ -43,7 +43,7 @@ module Orchestration
43
43
 
44
44
  private
45
45
 
46
- def mysql5_7
46
+ def mysql57
47
47
  'library/mysql:5.7'
48
48
  end
49
49
 
@@ -15,7 +15,7 @@ module Orchestration
15
15
  def friendly_config
16
16
  return "[#{adapter.name}]" if sqlite?
17
17
 
18
- "[#{adapter.name}] #{host}:#{port}"
18
+ "[#{adapter.name}] #{adapter.name}://#{username}:#{password}@#{host}:#{port}/#{database}"
19
19
  end
20
20
 
21
21
  def settings(healthcheck: false)
@@ -82,37 +82,31 @@ module Orchestration
82
82
  end
83
83
 
84
84
  def host
85
- url_config['host'] || file_config['host'] || super
85
+ chained_config('host') || super
86
86
  end
87
87
 
88
88
  def port
89
89
  return nil if sqlite?
90
90
 
91
- url_config['port'] || file_config['port'] || super
91
+ chained_config('port') || super
92
92
  end
93
93
 
94
94
  def username
95
- (
96
- url_config['username'] ||
97
- file_config['username'] ||
98
- (adapter && adapter.credentials['username'])
99
- )
95
+ chained_config('username') || (adapter && adapter.credentials['username'])
100
96
  end
101
97
 
102
98
  def password
103
- (
104
- url_config['password'] ||
105
- file_config['password'] ||
106
- (adapter && adapter.credentials['password'])
107
- )
99
+ chained_config('password') || (adapter && adapter.credentials['password'])
108
100
  end
109
101
 
110
102
  def database
111
- (
112
- url_config['database'] ||
113
- file_config['database'] ||
114
- (adapter && adapter.credentials['database'])
115
- )
103
+ chained_config('database') || (adapter && adapter.credentials['database'])
104
+ end
105
+
106
+ def chained_config(key)
107
+ return url_config[key] || file_config[key] if @env.environment == 'test'
108
+
109
+ file_config[key] || url_config[key]
116
110
  end
117
111
 
118
112
  def adapter_by_name(name)
@@ -4,6 +4,7 @@ module Orchestration
4
4
  module Services
5
5
  module RabbitMQ
6
6
  PORT = 5672
7
+ MANAGEMENT_PORT = 15_672
7
8
  end
8
9
  end
9
10
  end
@@ -2,5 +2,3 @@
2
2
  # e.g.:
3
3
  #
4
4
  # DISABLE_SPRING=1
5
-
6
- PUBLISH_PORT=3000
@@ -112,7 +112,7 @@ all: build
112
112
 
113
113
  .PHONY: start
114
114
  ifndef network
115
- start: network := ${compose_project_name}_default
115
+ start: network := ${compose_project_name}
116
116
  endif
117
117
  start: _create-log-directory _clean-logs
118
118
  @$(call print,'${yellow}Starting ${cyan}${env}${yellow} containers${reset} ...')
@@ -144,7 +144,7 @@ start-<%= service %>:
144
144
  <% end %>
145
145
 
146
146
  .PHONY: stop
147
- stop: network := ${compose_project_name}_default
147
+ stop: network := ${compose_project_name}
148
148
  stop:
149
149
  @$(call print,'${yellow}Stopping ${cyan}${env}${yellow} containers${reset} ...')
150
150
  @if docker ps --format "{{.ID}}" | grep -q $(shell hostname) ; \
@@ -238,7 +238,6 @@ ifndef verbose
238
238
  $(call hr,${red}) ; \
239
239
  )
240
240
  endif
241
- ifneq (,$(findstring deploy,$(MAKECMDGOALS)))
242
241
  @echo ; \
243
242
  $(call hr,${yellow}) ; \
244
243
  $(call println,'${gray}docker-compose logs${reset}') ; \
@@ -247,7 +246,6 @@ ifneq (,$(findstring deploy,$(MAKECMDGOALS)))
247
246
  @${compose} logs
248
247
  @echo ; \
249
248
  $(call hr,${yellow})
250
- endif
251
249
  @$(NOOP)
252
250
 
253
251
  .PHONY: image
@@ -1,6 +1,6 @@
1
1
  environment ENV.fetch('RAILS_ENV') { 'development' }
2
2
 
3
- port ENV.fetch('WEB_PORT') { 3000 }
3
+ port ENV.fetch('WEB_PORT') { 8080 }
4
4
  workers ENV.fetch('WEB_CONCURRENCY') { 4 }
5
5
  threads_count = ENV.fetch('RAILS_MAX_THREADS') { 8 }
6
6
 
@@ -1,12 +1,15 @@
1
1
  <% if compose.call('development').services.key?('rabbitmq') %>
2
2
  development:
3
- url: <%= "#{'<' + '%' + '='} ENV.fetch('RABBITMQ_URL', 'amqp://127.0.0.1:#{compose.call('development').local_port('rabbitmq')}') #{'%' + '>'}" %>
3
+ url: <%= "#{'<' + '%' + '='} ENV.fetch('RABBITMQ_URL', 'amqp://127.0.0.1:#{compose.call('development').local_port('rabbitmq', 5672)}') #{'%' + '>'}" %>
4
+ management_url: <%= "#{'<' + '%' + '='} ENV.fetch('RABBITMQ_MANAGEMENT_URL', 'http://guest:guest@127.0.0.1:#{compose.call('development').local_port('rabbitmq', 15672)}') #{'%' + '>'}" %>
4
5
  <% end %>
5
6
 
6
7
  <% if compose.call('test').services.key?('rabbitmq') %>
7
8
  test:
8
- url: <%= "#{'<' + '%' + '='} ENV.fetch('RABBITMQ_URL', 'amqp://127.0.0.1:#{compose.call('test').local_port('rabbitmq')}') #{'%' + '>'}" %>
9
+ url: <%= "#{'<' + '%' + '='} ENV.fetch('RABBITMQ_URL', 'amqp://127.0.0.1:#{compose.call('test').local_port('rabbitmq', 5672)}') #{'%' + '>'}" %>
10
+ management_url: <%= "#{'<' + '%' + '='} ENV.fetch('RABBITMQ_MANAGEMENT_URL', 'http://guest:guest@127.0.0.1:#{compose.call('test').local_port('rabbitmq', 15672)}') #{'%' + '>'}" %>
9
11
  <% end %>
10
12
 
11
13
  production:
12
14
  url: <%%= ENV['RABBITMQ_URL'] %>
15
+ url: <%%= ENV['RABBITMQ_MANAGEMENT_URL'] %>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orchestration
4
- VERSION = '0.5.8'
4
+ VERSION = '0.5.13'
5
5
  end
@@ -33,9 +33,8 @@ Gem::Specification.new do |spec|
33
33
  spec.add_runtime_dependency 'thor', '~> 1.0'
34
34
 
35
35
  spec.add_development_dependency 'activerecord', '~> 6.0'
36
- spec.add_development_dependency 'bundler', '~> 1.16'
37
36
  spec.add_development_dependency 'bunny', '~> 2.12'
38
- spec.add_development_dependency 'devpack', '~> 0.3.0'
37
+ spec.add_development_dependency 'devpack', '~> 0.3.2'
39
38
  spec.add_development_dependency 'mongoid', '~> 7.0'
40
39
  spec.add_development_dependency 'mysql2', '~> 0.5.2'
41
40
  spec.add_development_dependency 'pg', '~> 1.1'
@@ -43,7 +42,10 @@ Gem::Specification.new do |spec|
43
42
  spec.add_development_dependency 'rake', '~> 10.0'
44
43
  spec.add_development_dependency 'rspec', '~> 3.0'
45
44
  spec.add_development_dependency 'rspec-its', '~> 1.2'
46
- spec.add_development_dependency 'rubocop', '~> 0.90.0'
45
+ spec.add_development_dependency 'rubocop', '~> 1.12'
46
+ spec.add_development_dependency 'rubocop-rails', '~> 2.9'
47
+ spec.add_development_dependency 'rubocop-rake', '~> 0.5.1'
48
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.2'
47
49
  spec.add_development_dependency 'sqlite3', '~> 1.3'
48
50
  spec.add_development_dependency 'strong_versions', '~> 0.4.5'
49
51
  spec.add_development_dependency 'webmock', '~> 3.4'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orchestration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-18 00:00:00.000000000 Z
11
+ date: 2021-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: database_url
@@ -94,20 +94,6 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '6.0'
97
- - !ruby/object:Gem::Dependency
98
- name: bundler
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '1.16'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '1.16'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: bunny
113
99
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +114,14 @@ dependencies:
128
114
  requirements:
129
115
  - - "~>"
130
116
  - !ruby/object:Gem::Version
131
- version: 0.3.0
117
+ version: 0.3.2
132
118
  type: :development
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
122
  - - "~>"
137
123
  - !ruby/object:Gem::Version
138
- version: 0.3.0
124
+ version: 0.3.2
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: mongoid
141
127
  requirement: !ruby/object:Gem::Requirement
@@ -240,14 +226,56 @@ dependencies:
240
226
  requirements:
241
227
  - - "~>"
242
228
  - !ruby/object:Gem::Version
243
- version: 0.90.0
229
+ version: '1.12'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '1.12'
237
+ - !ruby/object:Gem::Dependency
238
+ name: rubocop-rails
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '2.9'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '2.9'
251
+ - !ruby/object:Gem::Dependency
252
+ name: rubocop-rake
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: 0.5.1
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: 0.5.1
265
+ - !ruby/object:Gem::Dependency
266
+ name: rubocop-rspec
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: '2.2'
244
272
  type: :development
245
273
  prerelease: false
246
274
  version_requirements: !ruby/object:Gem::Requirement
247
275
  requirements:
248
276
  - - "~>"
249
277
  - !ruby/object:Gem::Version
250
- version: 0.90.0
278
+ version: '2.2'
251
279
  - !ruby/object:Gem::Dependency
252
280
  name: sqlite3
253
281
  requirement: !ruby/object:Gem::Requirement
@@ -371,7 +399,7 @@ files:
371
399
  homepage: https://github.com/bobf/orchestration
372
400
  licenses: []
373
401
  metadata: {}
374
- post_install_message:
402
+ post_install_message:
375
403
  rdoc_options: []
376
404
  require_paths:
377
405
  - lib
@@ -387,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
387
415
  version: '0'
388
416
  requirements: []
389
417
  rubygems_version: 3.0.3
390
- signing_key:
418
+ signing_key:
391
419
  specification_version: 4
392
420
  summary: Docker orchestration toolkit
393
421
  test_files: []