capistrano-ejson 0.0.2 → 0.1.0
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/README.md +6 -3
- data/capistrano-ejson.gemspec +1 -1
- data/lib/capistrano/tasks/ejson.cap +19 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c75a5ea99c26f925da5027f2c67c87fdef37a224
|
4
|
+
data.tar.gz: 6c608aeca7b796b3513a353e41405d7e830d70d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7983e551b2b57f5035af6f2e7d1ccaa6df4e9f5e038b954cb1e21eba5c2e38e17752af06c49f2ec4651e67f88b68955aa2f1cbb7240c32d9e7ea0bc42e31cbbc
|
7
|
+
data.tar.gz: 4d40a140b7857823171a366e9416c8de0dcf6798011689f70f23b199b721641f75611050aadb45a9ec058fdbf778b46da185c9f6d0efbe5c7ba14d89db159874
|
data/README.md
CHANGED
@@ -26,14 +26,17 @@ Require in `Capfile` to use the default task:
|
|
26
26
|
require 'capistrano/ejson'
|
27
27
|
```
|
28
28
|
|
29
|
-
The task `ejson:
|
29
|
+
The task `ejson:upload_config_file` will run after `deploy:updated`.
|
30
30
|
|
31
|
-
By default
|
31
|
+
By default the file `config/secrets.ejson` will be decrypted to `config/secrets.json`. You can change this behavior by specifying the following config variables:
|
32
32
|
|
33
33
|
```ruby
|
34
|
-
set :
|
34
|
+
set :ejson_file, "config/secrets.ejson"
|
35
|
+
set :ejson_output_file, "config/secrets.json"
|
35
36
|
```
|
36
37
|
|
38
|
+
By default `capistrano-ejson` decrypts the secrets file from the machine that does the deploy and then uploads the resulting config to the servers. You can set `:ejson_deploy_mode` to `:remote` to perform the decryption remotely, which will run something like `ejson decrypt -o config/secrets.json config/secrets.ejson` on the remote hosts. If you need to use `sudo` or `bundle exec`, you should use the [SSHKit command map](https://github.com/capistrano/sshkit#the-command-map).
|
39
|
+
|
37
40
|
## Contributing
|
38
41
|
|
39
42
|
1. Fork it
|
data/capistrano-ejson.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "capistrano-ejson"
|
7
|
-
spec.version = "0.0
|
7
|
+
spec.version = "0.1.0"
|
8
8
|
spec.authors = ["Bouke van der Bijl"]
|
9
9
|
spec.email = ["bouke@shopify.com"]
|
10
10
|
spec.description = spec.summary = %q{Automatic EJSON decryption for Capistrano}
|
@@ -3,28 +3,41 @@ require 'open3'
|
|
3
3
|
namespace :ejson do
|
4
4
|
desc "Decrypt and upload ejson config files"
|
5
5
|
|
6
|
-
task :
|
7
|
-
fetch(:
|
8
|
-
|
6
|
+
task :upload_config_file do
|
7
|
+
ejson_file = fetch(:ejson_file)
|
8
|
+
ejson_output_file = fetch(:ejson_output_file)
|
9
|
+
ejson_deploy_mode = fetch(:ejson_deploy_mode)
|
9
10
|
|
11
|
+
case ejson_deploy_mode
|
12
|
+
when :local
|
10
13
|
Open3.popen3('bundle', 'exec', 'ejson', 'decrypt', ejson_file) do |stdin, stdout, stderr, wait_thr|
|
11
14
|
if wait_thr.value == 0
|
12
15
|
contents = stdout.read
|
13
16
|
on roles(:all) do
|
14
|
-
upload! StringIO.new(contents), File.join(release_path,
|
17
|
+
upload! StringIO.new(contents), File.join(release_path, ejson_output_file)
|
15
18
|
end
|
16
19
|
else
|
17
20
|
raise "Failed to decrypt file #{stderr.read}"
|
18
21
|
end
|
19
22
|
end
|
23
|
+
when :remote
|
24
|
+
on roles(:all) do
|
25
|
+
within release_path do
|
26
|
+
execute :ejson, :decrypt, "-o", ejson_output_file, ejson_file
|
27
|
+
end
|
28
|
+
end
|
29
|
+
else
|
30
|
+
raise "Unknown ejson_deploy_mode: #{ejson_deploy_mode.inspect}"
|
20
31
|
end
|
21
32
|
end
|
22
33
|
|
23
|
-
after 'deploy:updated', 'ejson:
|
34
|
+
after 'deploy:updated', 'ejson:upload_config_file'
|
24
35
|
end
|
25
36
|
|
26
37
|
namespace :load do
|
27
38
|
task :defaults do
|
28
|
-
set :
|
39
|
+
set :ejson_file, 'config/secrets.ejson'
|
40
|
+
set :ejson_output_file, 'config/secrets.json'
|
41
|
+
set :ejson_deploy_mode, :local
|
29
42
|
end
|
30
43
|
end
|