Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
fix: Application deployment fix
Browse files Browse the repository at this point in the history
Until this commit, all applications defined for given layer were deployed (no matter which app did
you choose from the dropdown). From now on, the correct behavior is implemented - only selected
application gets deployed.

BREAKING CHANGE: node['applications'] becomes obsolete
  • Loading branch information
ajgon committed Oct 21, 2016
1 parent 5301a9c commit 7ac4166
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 40 deletions.
9 changes: 4 additions & 5 deletions .overcommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ PreCommit:
enabled: true
Fasterer:
enabled: true
FixMe:
enabled: true
Foodcritic:
enabled: true
description: 'Run foodcritic'
require_files: false
required_executable: './bin/foodcritic'
install_command: 'gem install foodcritic'
flags: ['-f', 'any', '-B', '.']
HardTabs:
enabled: true
exclude:
Expand Down Expand Up @@ -46,6 +43,8 @@ PreCommit:
enabled: true
XmlSyntax:
enabled: true
YamlLint:
enabled: true
YamlSyntax:
enabled: true
CommitMsg:
Expand Down
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ addons:
- chef-stable-precise
packages:
- chefdk
- python-pip

before_install: "gem install bundler"
install: bundle install --without chef
install:
- pip install --user yamllint
- bundle install --without chef

before_script:
- chef gem install coveralls
Expand Down
29 changes: 15 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ GEM
celluloid-io (0.16.2)
celluloid (>= 0.16.0)
nio4r (>= 1.1.0)
chef (12.14.89)
chef (12.15.19)
addressable
bundler (>= 1.10)
chef-config (= 12.14.89)
chef-config (= 12.15.19)
chef-zero (>= 4.8)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
Expand All @@ -72,7 +72,7 @@ GEM
specinfra (~> 2.10)
syslog-logger (~> 1.6)
uuidtools (~> 2.1.5)
chef-config (12.14.89)
chef-config (12.15.19)
addressable
fuzzyurl
mixlib-config (~> 2.0)
Expand All @@ -91,6 +91,7 @@ GEM
ffi (~> 1.0, >= 1.0.11)
cleanroom (1.0.0)
colorize (0.8.1)
connection_pool (2.2.0)
coveralls (0.8.15)
json (>= 1.8, < 3)
simplecov (~> 0.12.0)
Expand Down Expand Up @@ -159,17 +160,19 @@ GEM
mixlib-log
mixlib-cli (1.7.0)
mixlib-config (2.2.4)
mixlib-install (2.0.3)
mixlib-install (2.1.3)
artifactory
mixlib-shellout
mixlib-versioning
thor
mixlib-log (1.7.1)
mixlib-shellout (2.2.7)
mixlib-versioning (1.1.0)
molinillo (0.5.1)
multi_json (1.12.1)
multipart-post (2.0.0)
net-http-persistent (2.9.4)
net-http-persistent (3.0.0)
connection_pool (~> 2.2)
net-http-pipeline (1.0.1)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
Expand All @@ -183,12 +186,11 @@ GEM
net-ssh-gateway (>= 1.2.0)
net-telnet (0.1.1)
nio4r (1.2.1)
nokogiri (1.6.8)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
octokit (4.3.0)
sawyer (~> 0.7.0, >= 0.5.3)
ohai (8.20.0)
ohai (8.21.0)
chef-config (>= 12.5.0.alpha.1, < 13)
ffi (~> 1.9)
ffi-yajl (~> 2.2)
Expand All @@ -200,12 +202,11 @@ GEM
plist (~> 3.1)
systemu (~> 2.6.4)
wmi-lite (~> 1.0)
overcommit (0.36.0)
overcommit (0.37.0)
childprocess (~> 0.5.8)
iniparse (~> 1.4)
parser (2.3.1.4)
ast (~> 2.2)
pkg-config (1.1.7)
plist (3.2.0)
polyglot (0.3.5)
powerpack (0.1.1)
Expand Down Expand Up @@ -254,22 +255,22 @@ GEM
rspec_junit_formatter (0.2.3)
builder (< 4)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (0.43.0)
rubocop (0.44.1)
parser (>= 2.3.1.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
ruby_parser (3.8.2)
ruby_parser (3.8.3)
sexp_processor (~> 4.1)
rufus-lru (1.1.0)
safe_yaml (1.0.4)
sawyer (0.7.0)
addressable (>= 2.3.5, < 2.5)
faraday (~> 0.8, < 0.10)
semverse (2.0.0)
serverspec (2.36.1)
serverspec (2.37.2)
multi_json
rspec (~> 3.0)
rspec-its
Expand All @@ -284,7 +285,7 @@ GEM
solve (3.0.1)
molinillo (~> 0.4)
semverse (>= 1.1, < 3.0)
specinfra (2.63.1)
specinfra (2.63.3)
net-scp
net-ssh (>= 2.7, < 4.0)
net-telnet
Expand Down
8 changes: 0 additions & 8 deletions docs/source/attributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ Attributes
| so for example ``app['framework']['adapter']`` actually means
| ``node['deploy'][<application_shortname>]['framework']['adapter']``.
basic
-----

- ``node['applications']``

- An array of application shortnames which should be deployed to given layer.
If not provided, all detected applications will be deployed.

global
------

Expand Down
10 changes: 1 addition & 9 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def deploy_dir(application)
def every_enabled_application
node['deploy'].each do |deploy_app_shortname, deploy|
application = applications.detect { |app| app['shortname'] == deploy_app_shortname }
next unless application
next unless application && application['deploy']
yield application, deploy
end
end
Expand All @@ -77,12 +77,4 @@ def perform_bundle_install(shared_path, envs = {})

def prepare_recipe
node.default['deploy'] = Hash[applications.map { |app| [app['shortname'], {}] }].merge(node['deploy'] || {})
apps_not_included.each do |app_for_removal|
node.rm('deploy', app_for_removal)
end
end

def apps_not_included
return [] if node['applications'].blank?
node['deploy'].keys.select { |app_name| !node['applications'].include?(app_name) }
end
2 changes: 2 additions & 0 deletions recipes/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

include_recipe 'opsworks_ruby::configure'

# rubocop:disable Metrics/BlockLength
every_enabled_application do |application, deploy|
databases = []
every_enabled_rds(self, application) do |rds|
Expand Down Expand Up @@ -86,3 +87,4 @@

fire_hook(:after_deploy, items: databases + [scm, framework, appserver, worker, webserver])
end
# rubocop:enable Metrics/BlockLength
5 changes: 2 additions & 3 deletions spec/unit/recipes/deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,14 @@
end.not_to raise_error
end

it 'node[\'applications\']' do
it 'app[\'deploy\'] = false' do
stub_search(:aws_opsworks_app, '*:*').and_return([
aws_opsworks_app.merge(shortname: 'a1'),
aws_opsworks_app.merge(shortname: 'a2')
aws_opsworks_app.merge(shortname: 'a2', deploy: false)
])
chef_run = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |solo_node|
solo_node.set['lsb'] = node['lsb']
solo_node.set['deploy'] = { 'a1' => {}, 'a2' => {} }
solo_node.set['applications'] = ['a1']
end.converge(described_recipe)
service = chef_run.service('puma_a1')

Expand Down

0 comments on commit 7ac4166

Please sign in to comment.