rrx_config 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec601c3c455ddac07928729e842a56bdf68169c7c79933a2f9fbf1f4f73ef731
4
- data.tar.gz: 5c6b2d173c96c364e8a950d8b73629d621bf2efe9ee6c0116e31b62b5249a264
3
+ metadata.gz: a1cef46013f979c18dacbea0608b8a5634ff55dba92d4a3e8a60d544a666265f
4
+ data.tar.gz: 9a188dbcfb69d4551364df86c5d79ec31c23b698b9b593432577c3433071b6f2
5
5
  SHA512:
6
- metadata.gz: 93bfbb4cd84cf2dd39781d68073c85e76a9dc77e66c64d034395870fb79c4c14d1016890720aa5bc312fdb8d21e91c832b6adbb4879dd8cb4cc9aafced95f5b2
7
- data.tar.gz: 9241012dda9185d410020eb2ed98fce23ec8061fc5c0821164578d83ef1a6997e893ee5457019ef0d7fee35f4debdcde54e7746691ae8f2c965996f90d47311d
6
+ metadata.gz: 9a10a0b572ad6a09237fc9321e97c19e9ced87777e04ff21280ebbd50742d484a354263662ddf6098ce42d62835f325112ec53cee90d5969e0753182de9b1fc4
7
+ data.tar.gz: fcca273e1e4b019a7a24a6adc06f085524fcef58a5bbe141d0539963651fc647ba9ba94dc9a1880b8bb5e7a4fb19b100d010f0c778c763e54964200cbb225754
data/Gemfile CHANGED
@@ -2,8 +2,3 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
  gemspec
5
-
6
- gem 'rrx_dev', path: '../rrx_dev'
7
-
8
- gem 'sqlite3'
9
- gem 'aws-sdk-secretsmanager'
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.0)
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
- Configurations are stored as immutable Ruby `Data` objects. You can test for optional values:
41
+ You can test for optional values using standard mechanisms:
44
42
 
45
43
  ```ruby
46
- optional_stuff if RrxConfig.members.include?(:optional_thing)
47
- deep_optional_stuff if RrxConfig.optional_thing.members.include?(:deep_thoughts)
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 have been
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/[USERNAME]/rrx_config/blob/main/CODE_OF_CONDUCT.md).
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).