mina-secrets-transfer 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 99eea53a14899220eea0f95c9b44d701a21c433988222b6c068731327b91f41d
4
+ data.tar.gz: e4884379ec899b01e48fb65c751193a98753f596975a36956f6e89a50dbaef21
5
+ SHA512:
6
+ metadata.gz: 201ec108799416349ba1a4fff989fe5231465d100fcaabaeb77ffe57401b4faa56dfcd8c260bd71210385fa41c2a9b8dbd85f779d45618b4a5a649ec5cce6649
7
+ data.tar.gz: 003f16cbdf4e855b0b21a7cc13da3a954d93ce6ab53d2f1a39185dc09f33145bd77c0746402a7910bfcde7cf433e4fe9fc7e40b314010cb7b89df5bbc571aaa0
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .idea
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mina_multistage.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2022 Vladimir Elchinov
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,80 @@
1
+
2
+
3
+ # Mina::Secrets
4
+
5
+ Plugin for Mina that helps handling secrets files (those that are not stored in repo).
6
+
7
+ Typical candidates are `master.key`, `database.yml`, `.env` etc. Anything you usualy create/upload manually during initial setup.
8
+
9
+ ## Installation & Usage
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```rb
14
+ gem 'mina-secrets-transfer', require: false
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ ```shell
20
+ $ bundle
21
+ ```
22
+
23
+ Require `mina/secrets` in your `config/deploy.rb`:
24
+
25
+ ```rb
26
+ require 'mina/bundler'
27
+ require 'mina/rails'
28
+ require 'mina/git'
29
+ require 'mina/secrets'
30
+
31
+ ...
32
+
33
+ task :setup do
34
+ ...
35
+ end
36
+
37
+ desc 'Deploys the current version to the server.'
38
+ task :deploy do
39
+ ...
40
+ end
41
+ ```
42
+
43
+
44
+ Update setup task:
45
+
46
+ ```rb
47
+ # config/deploy.rb
48
+
49
+ desc 'Deploys the current version to the server.'
50
+ task :setup do
51
+ ...
52
+ # add new task
53
+ invoke :'secrets:upload'
54
+ ...
55
+ end
56
+ ```
57
+
58
+ ## Configuration
59
+
60
+ * `secrets_files` - list of secrets files (`["config/master.key", "config/credentials/#{fetch(:rails_env)}.key"]` by default)
61
+
62
+ Keep in mind that directories must be present in `shared_dirs`. All paths are relative to app root locally and to `shared_dir` on remote server.
63
+
64
+ ## Tasks
65
+ | Name | Description
66
+ |-------------------------|----------------------------------------------------------------------------------------
67
+ |`secrets:upload` | Safely upload secrets files to the server. Missing local files do not throw an exception. Existing remote files are NOT overwritten.
68
+ |`secrets:upload:force` | Upload secrets files to the server. Missing local files do not throw an exception. Existing remote files ARE overwritten.
69
+ |`secrets:download` | Safely download secrets files from the server. Missing local files are NOT overwritten. Missing remote files do not throw an exception.
70
+ |`secrets:download:force` | Download secrets files from the server. Missing local files ARE overwritten. Missing remote files do not throw an exception.
71
+
72
+ Use download tasks when you reinstall your local environment
73
+
74
+ ## Contributing
75
+
76
+ 1. Fork it
77
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
78
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
79
+ 4. Push to the branch (`git push origin my-new-feature`)
80
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ module Mina
2
+ module Secrets
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,53 @@
1
+ set :secrets_files, -> { ["config/master.key", "config/credentials/#{fetch(:rails_env)}.key"] }
2
+
3
+ desc "Copy secrets files to the server."
4
+ task :'secrets:upload' do
5
+ comment "Copying secrets files"
6
+ fetch(:secrets_files).each do |file|
7
+ if File.exist?(file)
8
+ command "[ ! -f #{fetch(:shared_path)}/#{file} ] && echo -n '#{File.open(file).read}' > #{fetch(:shared_path)}/#{file} || echo 'Skiping existing file #{file}'"
9
+ else
10
+ command "echo 'Local file #{file} does not exist'"
11
+ end
12
+ end
13
+ end
14
+
15
+ desc "Copy secrets files to the server. Overwrite existing files."
16
+ task :'secrets:upload:force' do
17
+ comment "Copying secrets files"
18
+ fetch(:secrets_files).each do |file|
19
+ if File.exist?(file)
20
+ command "[ -f #{fetch(:shared_path)}/#{file} ] && echo 'Overwriting existing file #{file}' ; echo -n '#{File.open(file).read}' > #{fetch(:shared_path)}/#{file}"
21
+ else
22
+ command "echo 'Local file #{file} does not exist'"
23
+ end
24
+ end
25
+ end
26
+
27
+
28
+ desc "Download secrets files from the server."
29
+ task :'secrets:download' do
30
+ comment "Downloading secrets files"
31
+ run(:local) do
32
+ fetch(:secrets_files).each do |file|
33
+ if File.exist?(file)
34
+ comment "Skiping existing file #{file}"
35
+ else
36
+ command "scp #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:shared_path)}/#{file} #{file} 2>/dev/null || echo 'Remote file #{file} does not exist'"
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ desc "Download secrets files from the server. Overwrite existing local files."
43
+ task :'secrets:download:force' do
44
+ comment "Downloading secrets files"
45
+ run(:local) do
46
+ fetch(:secrets_files).each do |file|
47
+ if File.exist?(file)
48
+ comment "Overwriting existing file #{file}"
49
+ end
50
+ command "scp #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:shared_path)}/#{file} #{file} 2>/dev/null || echo 'Remote file #{file} does not exist'"
51
+ end
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mina-secrets-transfer
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Vladimir Elchinov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-09-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mina
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.5
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Helps handling secrets files in Mina
56
+ email:
57
+ - elik@elik.ru
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/mina/secrets.rb
68
+ - lib/mina/secrets/version.rb
69
+ homepage: https://github.com/railsblueprint/mina-secrets-transfer/
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubygems_version: 3.0.3
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: Helps handling secrets files in Mina
92
+ test_files: []