openbox 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3b2286d2b3b83ce60a50ead93f7f3b293612cd7a9386f21309b2078467acf3e
4
- data.tar.gz: e1b3b12fe3c36503c9cfe1c72ac38163b1c7850eeda7e4395adf79c665abc19e
3
+ metadata.gz: 2c0d83b1900aaf94e908bf6cdca2c74226a6e3634a43e22799b98ec6e7d6b0bc
4
+ data.tar.gz: 5061979673b6b027be1d4926dec24dcd54d0bf1d52b6d862641bd2579f8154bf
5
5
  SHA512:
6
- metadata.gz: 741418382ee5a71631d3ff8303ea421091527338f72b6a42cfc441c94acdad51b7ede680b44515724bacd3c715e8878e339ed84b80b16186f14750c2c4f3edb9
7
- data.tar.gz: ba0bfebc3ed03a62a4321e389202992f7bf988cf00a3a99d6651569fedd46d1496839a35d037f7815e5b336c5ca2af54ae5e60cdd46544b2fdb87d28a128d381
6
+ metadata.gz: '09da76c126d5e6b30d27153db1f8ac4415a134b7c427485dd8f740d1aacd186d6311a9bde8a26dabba17ba4a048cf3837367baa2bf0eec6e23094ffd3d986a9a'
7
+ data.tar.gz: 1f2389789c16745950eadb85a69406a95b24a71cd4a54e13568e62c20ab97c24d7b743bdac03dec7e6036681cfc4f802f3f92fee151cf91b1e6f3a259d0e271b
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openbox (0.4.0)
4
+ openbox (0.5.0)
5
+ dotenv
5
6
  thor (~> 1.0)
6
7
 
7
8
  GEM
@@ -14,6 +15,7 @@ GEM
14
15
  childprocess (4.1.0)
15
16
  diff-lcs (1.4.4)
16
17
  docile (1.4.0)
18
+ dotenv (2.7.6)
17
19
  iniparse (1.5.0)
18
20
  overcommit (0.58.0)
19
21
  childprocess (>= 0.6.3, < 5)
data/README.md CHANGED
@@ -44,14 +44,7 @@ The commands are pre-defined for the Rack and Rails applications.
44
44
  | `seed` | `rails` | Run database seed |
45
45
  | `sidekiq` | `sidekiq` | Run sidekiq server |
46
46
 
47
- ### Environments
48
-
49
- | Name | Description |
50
- |------------------|--------------------------------------------------------------------------------------|
51
- | `AUTO_MIGRATION` | When present, the `migrate` will run before `server` started |
52
- | `DATABASE_URL` | When `pg` or `mysql2` gem present, Openbox will use it to ensure database connection |
53
-
54
- ### Customize Commands
47
+ #### Customize Commands
55
48
 
56
49
  When `openbox` execute, the `lib/openbox/commands/*/**.rb` will be scanned and require before started.
57
50
  We can register new command by adding files to `lib/openbox/commands` directory.
@@ -70,6 +63,33 @@ Openbox::Entrypoint.register Daemon, :daemon, :daemon, 'Run a daemon'
70
63
 
71
64
  > The Rails are not loaded to speed up bootstrap, if you need Rails please load by yourself.
72
65
 
66
+ ### Environments
67
+
68
+ | Name | Example | Description |
69
+ |------------------|----------------------------------------|--------------------------------------------------------------------------------------|
70
+ | `AUTO_MIGRATION` | `yes` | When present, the `migrate` will run before `server` started |
71
+ | `DATABASE_URL` | `postgres://user:pass@postgres/dbname` | When `pg` or `mysql2` gem present, Openbox will use it to ensure database connection |
72
+ | `SWARM_SECRETS` | `app-env` | List the Docker Swarm secret names to load as environment file |
73
+
74
+ ## Environment Loader
75
+
76
+ To rotate secrets easier, we may not use Rails credentials but inject secrets via the environment variables.
77
+
78
+ Openbox provides a before hook before the command is executed and load the environments from a security source.
79
+
80
+ ### Docker Swarm
81
+
82
+ When use Docker Swarm, the secret will put into `/run/secrets` directory, you can load these files via Dotenv.
83
+
84
+ ```yaml
85
+ # Docker Swarm Stack
86
+ services:
87
+ application:
88
+ environment:
89
+ - SWARM_SECRETS=sahred-secret,applicate-secret
90
+ # ...
91
+ ```
92
+
73
93
  ## Roadmap
74
94
 
75
95
  * [ ] `config/openbox.rb` config
@@ -87,7 +107,10 @@ Openbox::Entrypoint.register Daemon, :daemon, :daemon, 'Run a daemon'
87
107
  * [x] `openbox migrate` to `rails db:migrate`
88
108
  * [x] `openbox seed` to `rails db:seed`
89
109
  * [x] Use `AUTO_MIGRATION` to run migration before server started
90
-
110
+ * [ ] Load Secrets as Environment
111
+ * [ ] AWS Secrets Manager
112
+ * [ ] Hashicorp Valut
113
+ * [ ] Docker Swarm Secrets
91
114
 
92
115
  ## Development
93
116
 
@@ -1,12 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'thor'
4
+ require 'dotenv'
4
5
 
5
6
  module Openbox
6
7
  # The base command of openbox
7
8
  #
8
9
  # @since 0.1.0
9
10
  class Command < Thor::Group
11
+ # Before execute command
12
+ #
13
+ # @since 0.5.0
14
+ def before_execute
15
+ # TODO: Add AWS KMS, Vault support
16
+ return if ENV['SWARM_SECRETS'].nil?
17
+
18
+ paths = ENV['SWARM_SECRETS'].split(',').map { |name| "/run/secrets/#{name}" }
19
+ Dotenv.load(*paths)
20
+ end
21
+
10
22
  # Execute command
11
23
  #
12
24
  # @since 0.1.0
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Openbox
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
data/openbox.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ['lib']
30
30
 
31
- # Uncomment to register a new dependency of your gem
31
+ spec.add_dependency 'dotenv'
32
32
  spec.add_dependency 'thor', '~> 1.0'
33
33
 
34
34
  # For more information and examples about making a new gem, checkout our
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 蒼時弦也
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-22 00:00:00.000000000 Z
11
+ date: 2022-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dotenv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: thor
15
29
  requirement: !ruby/object:Gem::Requirement