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

Commit

Permalink
feat(global): Moved app['environment'] to `app['global']['environme…
Browse files Browse the repository at this point in the history
…nt']`

To keep consistency with `group`.`field` configuration format, a new group `global` was created. All
project-wide parameters will be passed here.

Resolves #50

BREAKING CHANGE: If you were using an `app['environment']` variable (for example to set env to
staging), please update your stack/layer JSONs to `app['global']['environment']`.

Signed-off-by: Igor Rzegocki <igor@rzegocki.pl>
  • Loading branch information
ajgon committed Sep 30, 2016
1 parent 76a7f36 commit 432a21c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ so for example `app['framework']['adapter']` actually means
Global parameters apply to the whole application, and can be used by any section
(framework, appserver etc.).

* `app['environment']`
* `app['global']['environment']`
* **Default:** `production`
* Sets the "deploy environment" for all the app-related (for example `RAILS_ENV`
in Rails) actions in the project (server, worker, etc.)
Expand Down
6 changes: 3 additions & 3 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# frozen_string_literal: true

# environment
default['defaults']['environment'] = 'production'

# deploy
default['defaults']['deploy']['symlinks'] = {
'system' => 'public/system',
Expand All @@ -24,6 +21,9 @@
nginx::http_stub_status_module
)

# global
default['defaults']['global']['environment'] = 'production'

# database
## common

Expand Down
5 changes: 2 additions & 3 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ def rdses

def globals
{
environment: node['deploy'][app['shortname']].try(:[], 'environment') ||
app['attributes']['rails_env'] || node['defaults']['environment'] || 'production'
}
environment: 'production'
}.merge((node['deploy'][app['shortname']].try(:[], 'global') || node['defaults']['global'] || {}).symbolize_keys)
end

def fire_hook(name, options)
Expand Down
4 changes: 3 additions & 1 deletion spec/fixtures/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ def node(override = {})
},
deploy: {
dummy_project: {
environment: 'staging',
global: {
environment: 'staging'
},
# database: {
# adapter: 'postgresql',
# username: 'dbuser',
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/recipes/configure_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@
deploy: {
dummy_project: {
database: { adapter: 'sqlite3' },
environment: 'staging',
global: { environment: 'staging' },
appserver: node['deploy']['dummy_project']['appserver'].merge('adapter' => 'thin'),
webserver: node['deploy']['dummy_project']['webserver'],
framework: node['deploy']['dummy_project']['framework'].merge('adapter' => 'padrino'),
Expand Down Expand Up @@ -852,7 +852,7 @@
host: 'dummy-project.936.us-west-2.rds.amazon.com',
database: 'database_936'
},
environment: 'staging',
global: { environment: 'staging' },
framework: { adapter: 'rails' }
}
})
Expand Down

0 comments on commit 432a21c

Please sign in to comment.