capistrano-env_config 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -1
- data/README.md +33 -12
- data/capistrano-env_config.gemspec +2 -2
- data/lib/capistrano-env_config.rb +2 -2
- data/lib/capistrano/env_config.rb +2 -2
- data/lib/capistrano/env_config/version.rb +1 -1
- data/lib/capistrano/tasks/env_config.rake +24 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 454e578c8df69f1d96d4a40af745ff98851cb0d3
|
4
|
+
data.tar.gz: 20b0f51bc9b841657a427f486d4fd547bb187bc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d818244b23cf883f33832537bbeffdb485e64cd1bc652953754c6846be0a3c926c0c1ad4e3f32155c83143c07ecd54fa668fa2db1b51cf8a1e53428b13341b4
|
7
|
+
data.tar.gz: 90d158945825fd34a1f4612f6594b937279449994015b12e18bf2837e3d36ef8497f4a454b2db4b4f8ddcb6eafdb1d6ea90bfa5c90289560647dc312d4ec8450
|
data/CHANGELOG.md
CHANGED
@@ -7,7 +7,8 @@ v0.0.2
|
|
7
7
|
environment variables from.
|
8
8
|
* Added an argument for specifically setting roles when using the `Environment`
|
9
9
|
class programatically.
|
10
|
-
|
10
|
+
* Note: Implemented using the potentially unstable and subject to change
|
11
|
+
`Capistrano::Plugin` API.
|
11
12
|
|
12
13
|
v0.0.1
|
13
14
|
------
|
data/README.md
CHANGED
@@ -11,9 +11,9 @@ Usage
|
|
11
11
|
-----
|
12
12
|
|
13
13
|
* `cap env:list` – To list current environment configuration
|
14
|
-
* `cap env:get[VARIABLE_NAME]` – To get the value of specific variable
|
15
|
-
* `cap env:unset[VARIABLE_NAME]` – To delete an environment variable
|
16
|
-
* `cap env:set[VARIABLE_NAME=VALUE]` – To set an environment variable
|
14
|
+
* `cap env:get[VARIABLE_NAME,VARIABLE_NAME]` – To get the value of specific variable
|
15
|
+
* `cap env:unset[VARIABLE_NAME,VARIABLE_NAME]` – To delete an environment variable
|
16
|
+
* `cap env:set[VARIABLE_NAME=VALUE,VARIABLE_NAME=VALUE]` – To set an environment variable
|
17
17
|
* `cap env:sync` – To synchronise the environment configuration across servers
|
18
18
|
|
19
19
|
If you need to programatically manipulate the environment you can use the
|
@@ -22,25 +22,46 @@ If you need to programatically manipulate the environment you can use the
|
|
22
22
|
```ruby
|
23
23
|
require 'capistrano/env_config/environment'
|
24
24
|
|
25
|
-
environment = Capistrano::EnvConfig::Environment.new
|
26
|
-
environment.list
|
27
|
-
environment.get( 'VARIABLE' )
|
28
|
-
environment.set( 'VARIABLE', 'VALUE' )
|
29
|
-
environment.delete( 'VARIABLE' )
|
30
|
-
environment.sync
|
25
|
+
environment = Capistrano::EnvConfig::Environment.new # Reads and loads /etc/environment from all servers
|
26
|
+
environment.list # Returns a hash of all environment variables
|
27
|
+
environment.get( 'VARIABLE' ) # Gets a variable by name
|
28
|
+
environment.set( 'VARIABLE', 'VALUE' ) # Sets a variable
|
29
|
+
environment.delete( 'VARIABLE' ) # Deletes a variable
|
30
|
+
environment.sync # Uploads current confifuration to all servers
|
31
|
+
```
|
32
|
+
|
33
|
+
By default capistrano sets and reads the `/etc/environment` of all roles. This
|
34
|
+
behaviour can be changed by setting:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
set :env_config_roles, [ :web, :app ]
|
38
|
+
```
|
39
|
+
|
40
|
+
The `new` and `sync` methods also accept an optional argument for specifying
|
41
|
+
roles explicitly (overriding the value set in `:env_config_roles`):
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
environment.list( :app )
|
45
|
+
environment.sync( [ :web, :app ] )
|
31
46
|
```
|
32
47
|
|
33
48
|
Installation
|
34
49
|
------------
|
35
50
|
|
36
|
-
Add the gem to your Gemfile
|
51
|
+
Add the gem to your `Gemfile`:
|
37
52
|
|
38
|
-
```
|
53
|
+
```ruby
|
39
54
|
group :development do
|
40
55
|
gem 'capistrano-env_config'
|
41
56
|
end
|
42
57
|
```
|
43
58
|
|
59
|
+
And the following line to your `Capfile`:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
require 'capistrano/env_config'
|
63
|
+
```
|
64
|
+
|
44
65
|
In your server provisioning script, make sure the deploy user has write access
|
45
66
|
to the `/etc/environment` file, which is used to store the configured variables.
|
46
67
|
|
@@ -57,4 +78,4 @@ License
|
|
57
78
|
Copyright Itay Grudev (c) 2017.
|
58
79
|
|
59
80
|
This gem and all associated documentation is distributed under the terms of the
|
60
|
-
GNU GPL v3 license.
|
81
|
+
GNU GPL v3 license.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'lib/capistrano/env_config/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'capistrano-env_config'
|
@@ -28,4 +28,4 @@ Gem::Specification.new do |spec|
|
|
28
28
|
|
29
29
|
spec.add_development_dependency 'rspec', '~> 3.6'
|
30
30
|
spec.add_development_dependency 'simplecov', '~> 0.14'
|
31
|
-
end
|
31
|
+
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative 'capistrano/env_config/version'
|
2
|
+
require_relative 'capistrano/env_config/environment'
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require '
|
1
|
+
require 'byebug'
|
2
|
+
require_relative '../env_config/environment'
|
2
3
|
|
3
4
|
namespace :env do
|
4
5
|
desc 'Lists the environment variables set across servers'
|
@@ -16,33 +17,39 @@ namespace :env do
|
|
16
17
|
end
|
17
18
|
|
18
19
|
desc 'Sets an environment variable'
|
19
|
-
task :set
|
20
|
-
abort 'No key-value pair specified.' if args
|
21
|
-
key, value = args[:variable].split( '=', 2 )
|
20
|
+
task :set do |task, args|
|
21
|
+
abort 'No key-value pair specified.' if args.extras.empty?
|
22
22
|
environment = Capistrano::EnvConfig::Environment.new
|
23
|
-
|
23
|
+
args.extras.each do |variable|
|
24
|
+
key, value = variable.split( '=', 2 )
|
25
|
+
environment.set( key, value )
|
26
|
+
end
|
24
27
|
environment.sync
|
25
28
|
end
|
26
29
|
|
27
30
|
desc 'Prints an environment variable'
|
28
|
-
task :get
|
31
|
+
task :get do |task, args|
|
29
32
|
environment = Capistrano::EnvConfig::Environment.new
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
args.extras.each do |variable|
|
34
|
+
value = environment.get( variable )
|
35
|
+
if value.nil?
|
36
|
+
STDERR.puts "No such variable: #{variable.upcase}"
|
37
|
+
else
|
38
|
+
puts "#{variable.upcase}=#{value}"
|
39
|
+
end
|
35
40
|
end
|
36
41
|
end
|
37
42
|
|
38
43
|
desc 'Removes a environment variable'
|
39
|
-
task :unset
|
44
|
+
task :unset do |task, args|
|
40
45
|
environment = Capistrano::EnvConfig::Environment.new
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
args.extras.each do |variable|
|
47
|
+
if environment.get( variable.upcase ).nil?
|
48
|
+
abort "No such variable: #{variable.upcase}"
|
49
|
+
else
|
50
|
+
environment.delete( variable.upcase )
|
51
|
+
end
|
46
52
|
end
|
53
|
+
environment.sync
|
47
54
|
end
|
48
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-env_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Itay Grudev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|