rrx_config 0.1.0 → 0.1.2
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/Gemfile +0 -5
- data/Gemfile.lock +26 -23
- data/README.md +56 -12
- data/global.pem +3028 -0
- data/lib/rrx_config/aws.rb +63 -0
- data/lib/rrx_config/configuration.rb +8 -2
- data/lib/rrx_config/database_config/iam_hash_config.rb +87 -0
- data/lib/rrx_config/database_config.rb +39 -9
- data/lib/rrx_config/environment.rb +7 -0
- data/lib/rrx_config/error.rb +5 -0
- data/lib/rrx_config/railtie.rb +30 -0
- data/lib/rrx_config/sources/aws_secret_source.rb +11 -15
- data/lib/rrx_config/sources/base.rb +11 -6
- data/lib/rrx_config/sources/environment_source.rb +0 -1
- data/lib/rrx_config/version.rb +1 -1
- data/lib/rrx_config.rb +30 -5
- metadata +91 -7
- data/.idea/.gitignore +0 -8
- data/.idea/inspectionProfiles/Project_Default.xml +0 -7
- data/.idea/modules.xml +0 -8
- data/.idea/rrx_config.iml +0 -183
- data/.idea/vcs.xml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1cef46013f979c18dacbea0608b8a5634ff55dba92d4a3e8a60d544a666265f
|
4
|
+
data.tar.gz: 9a188dbcfb69d4551364df86c5d79ec31c23b698b9b593432577c3433071b6f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a10a0b572ad6a09237fc9321e97c19e9ced87777e04ff21280ebbd50742d484a354263662ddf6098ce42d62835f325112ec53cee90d5969e0753182de9b1fc4
|
7
|
+
data.tar.gz: fcca273e1e4b019a7a24a6adc06f085524fcef58a5bbe141d0539963651fc647ba9ba94dc9a1880b8bb5e7a4fb19b100d010f0c778c763e54964200cbb225754
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,28 +1,8 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ../rrx_dev
|
3
|
-
specs:
|
4
|
-
rrx_dev (0.1.1)
|
5
|
-
active_record_query_trace
|
6
|
-
activesupport (~> 7.1.0)
|
7
|
-
bootsnap
|
8
|
-
debug
|
9
|
-
factory_bot_rails
|
10
|
-
listen
|
11
|
-
railties (~> 7.1.0)
|
12
|
-
rake (>= 13.0)
|
13
|
-
rspec (>= 3.0)
|
14
|
-
rspec-parameterized
|
15
|
-
rspec-rails
|
16
|
-
rswag-specs
|
17
|
-
rubocop (>= 1.21)
|
18
|
-
rubocop-rails
|
19
|
-
spring
|
20
|
-
thor
|
21
|
-
|
22
1
|
PATH
|
23
2
|
remote: .
|
24
3
|
specs:
|
25
|
-
rrx_config (0.1.
|
4
|
+
rrx_config (0.1.2)
|
5
|
+
activesupport
|
26
6
|
railties
|
27
7
|
|
28
8
|
GEM
|
@@ -72,6 +52,9 @@ GEM
|
|
72
52
|
aws-partitions (~> 1, >= 1.651.0)
|
73
53
|
aws-sigv4 (~> 1.8)
|
74
54
|
jmespath (~> 1, >= 1.6.1)
|
55
|
+
aws-sdk-rds (1.213.0)
|
56
|
+
aws-sdk-core (~> 3, >= 3.188.0)
|
57
|
+
aws-sigv4 (~> 1.1)
|
75
58
|
aws-sdk-secretsmanager (1.88.0)
|
76
59
|
aws-sdk-core (~> 3, >= 3.188.0)
|
77
60
|
aws-sigv4 (~> 1.1)
|
@@ -122,6 +105,7 @@ GEM
|
|
122
105
|
minitest (5.20.0)
|
123
106
|
msgpack (1.7.2)
|
124
107
|
mutex_m (0.2.0)
|
108
|
+
mysql2 (0.5.5)
|
125
109
|
nokogiri (1.16.0-x86_64-linux)
|
126
110
|
racc (~> 1.4)
|
127
111
|
parallel (1.24.0)
|
@@ -170,6 +154,23 @@ GEM
|
|
170
154
|
reline (0.4.1)
|
171
155
|
io-console (~> 0.5)
|
172
156
|
rexml (3.2.6)
|
157
|
+
rrx_dev (0.1.2)
|
158
|
+
active_record_query_trace
|
159
|
+
activesupport (~> 7.1.0)
|
160
|
+
bootsnap
|
161
|
+
debug
|
162
|
+
factory_bot_rails
|
163
|
+
listen
|
164
|
+
railties (~> 7.1.0)
|
165
|
+
rake (>= 13.0)
|
166
|
+
rspec (>= 3.0)
|
167
|
+
rspec-parameterized
|
168
|
+
rspec-rails
|
169
|
+
rswag-specs
|
170
|
+
rubocop (>= 1.21)
|
171
|
+
rubocop-rails
|
172
|
+
spring
|
173
|
+
thor
|
173
174
|
rspec (3.12.0)
|
174
175
|
rspec-core (~> 3.12.0)
|
175
176
|
rspec-expectations (~> 3.12.0)
|
@@ -245,9 +246,11 @@ PLATFORMS
|
|
245
246
|
x86_64-linux
|
246
247
|
|
247
248
|
DEPENDENCIES
|
249
|
+
aws-sdk-rds
|
248
250
|
aws-sdk-secretsmanager
|
251
|
+
mysql2
|
249
252
|
rrx_config!
|
250
|
-
rrx_dev
|
253
|
+
rrx_dev
|
251
254
|
sqlite3
|
252
255
|
|
253
256
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# RrxConfig
|
2
2
|
|
3
|
-
|
4
|
-
TODO: Delete this and the text below, and describe your gem
|
5
|
-
|
6
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rrx_config`. To experiment with that code, run `bin/console` for an interactive prompt.
|
3
|
+
Ruby on Rails application configuration support.
|
7
4
|
|
8
5
|
## Installation
|
9
6
|
|
@@ -17,7 +14,8 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
17
14
|
|
18
15
|
## Usage
|
19
16
|
|
20
|
-
This gem loads runtime application configuration from an external source
|
17
|
+
This gem loads runtime application configuration from JSON provided by an external source.
|
18
|
+
Configurations are stored as immutable Ruby `Data` objects.
|
21
19
|
|
22
20
|
For example, with the JSON config
|
23
21
|
|
@@ -40,16 +38,20 @@ def my_code
|
|
40
38
|
end
|
41
39
|
```
|
42
40
|
|
43
|
-
|
41
|
+
You can test for optional values using standard mechanisms:
|
44
42
|
|
45
43
|
```ruby
|
46
|
-
optional_stuff if RrxConfig.
|
47
|
-
deep_optional_stuff if RrxConfig.optional_thing.
|
44
|
+
optional_stuff if RrxConfig.respond_to?(:optional_thing)
|
45
|
+
deep_optional_stuff if RrxConfig.optional_thing.include?(:deep_thoughts)
|
46
|
+
|
47
|
+
optional_flag = RrxConfig.try(:optional).try(:flag) || DEFAULT_FLAG
|
48
48
|
|
49
49
|
# Root-level configs can also be tested with the xxxx? syntax
|
50
50
|
optional_stuff if RrxConfig.optional_thing?
|
51
51
|
```
|
52
52
|
|
53
|
+
## Configuration Sources
|
54
|
+
|
53
55
|
### Environment
|
54
56
|
|
55
57
|
Set the `RRX_CONFIG` environment variable to the required JSON configuration
|
@@ -59,11 +61,53 @@ Set the `RRX_CONFIG` environment variable to the required JSON configuration
|
|
59
61
|
Loads configuration from an AWS secret that contains the required JSON configuration. Recommended when deploying on AWS.
|
60
62
|
By default will use the implicit AWS context that is assigned by the instance role.
|
61
63
|
|
62
|
-
Set the `RRX_CONFIG_AWS_SECRET` to the name of the secret to read.
|
64
|
+
Set the `RRX_CONFIG_AWS_SECRET` environment variable to the name of the secret to read.
|
63
65
|
|
64
|
-
For local integration testing, set `RRX_AWS_PROFILE` to use local AWS credentials. The profile must
|
66
|
+
For local integration testing, set `RRX_AWS_PROFILE` to use local AWS credentials. The profile must be
|
65
67
|
configured in the local AWS client (typically `~/.aws/credentials`).
|
66
68
|
|
69
|
+
### Local File Configuration
|
70
|
+
|
71
|
+
For development purposes, the gem will also check for the following files:
|
72
|
+
|
73
|
+
* `{rails_root}/spec/spec_config.json` if `RAILS_ENV=test`
|
74
|
+
* `{rails_root}/local_config.json`
|
75
|
+
|
76
|
+
## Database Support
|
77
|
+
|
78
|
+
If the loaded config contains a root-level `database` item then it will be used to configure the
|
79
|
+
application database instead of `database.yml`.
|
80
|
+
|
81
|
+
### AWS RDS IAM Authentication
|
82
|
+
|
83
|
+
The gem also adds support for AWS RDS authentication using IAM to MySQL/MariaDB databases. If the RDS instance
|
84
|
+
and user account has been configured correctly, replace the `password` argument with `iam: true`. This is supported
|
85
|
+
using the `database` configuration or `database.yml`.
|
86
|
+
|
87
|
+
The gem will automatically download the required CA certificates and set the necessary client options.
|
88
|
+
|
89
|
+
Using JSON configuration:
|
90
|
+
```json
|
91
|
+
{
|
92
|
+
"database": {
|
93
|
+
"adapter": "mysql2",
|
94
|
+
"host": "rds-db-address...rds.amazonaws.com",
|
95
|
+
"port": 3306,
|
96
|
+
"username": "my_app_user",
|
97
|
+
"iam": true
|
98
|
+
}
|
99
|
+
}
|
100
|
+
```
|
101
|
+
Using `database.yml`:
|
102
|
+
```yaml
|
103
|
+
production:
|
104
|
+
adapter: mysql2
|
105
|
+
host: rds-db-address...rds.amazonaws.com
|
106
|
+
port: 3306
|
107
|
+
username: my_app_user
|
108
|
+
iam: true
|
109
|
+
```
|
110
|
+
|
67
111
|
## Development
|
68
112
|
|
69
113
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -72,7 +116,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
72
116
|
|
73
117
|
## Contributing
|
74
118
|
|
75
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/rrx/rrx_config. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rrx_config/blob/main/CODE_OF_CONDUCT.md).
|
119
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rails-rrx/rrx_config. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rrx_config/blob/main/CODE_OF_CONDUCT.md).
|
76
120
|
|
77
121
|
## License
|
78
122
|
|
@@ -80,4 +124,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
80
124
|
|
81
125
|
## Code of Conduct
|
82
126
|
|
83
|
-
Everyone interacting in the RrxConfig project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
127
|
+
Everyone interacting in the RrxConfig project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rails-rrc/rrx_config/blob/main/CODE_OF_CONDUCT.md).
|