blinkist-config 1.4.0 → 1.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 +4 -4
- data/.github/workflows/ci.yml +22 -16
- data/.github/workflows/tag-release.yml +54 -0
- data/.github/workflows/version-guard.yml +43 -0
- data/.gitignore +3 -1
- data/Dockerfile +3 -33
- data/Gemfile +0 -3
- data/README.md +62 -119
- data/Taskfile.yml +68 -0
- data/docker-compose.yml +7 -16
- data/lib/blinkist/config/adapters/adapter.rb +1 -0
- data/lib/blinkist/config/adapters/env_over_ssm_adapter.rb +24 -0
- data/lib/blinkist/config/adapters.rb +2 -1
- data/lib/blinkist/config/version.rb +1 -1
- data/lib/blinkist/config.rb +2 -0
- metadata +7 -7
- data/.github/workflows/codeql-analysis.yml +0 -70
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 24385caf244b70efe62c358af91e8c21a665e4a58ce0f19c5afcfa8e3c880167
|
|
4
|
+
data.tar.gz: 0b2f4916ea3d0ce9d8383c6509b6f2ce842643ac1a3d85e8300a9be9cea2ebcb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 86cb037791f449c78beb09fdceeffc122ddf84908a0ae9da2df2f4fe6d846fb04a452d0618ca27f8b4ca224a3907743958ca41e7ad85ec8c5c83dd39d84c2f06
|
|
7
|
+
data.tar.gz: cd8e50cddeee5da4f9d2be914b5dbf2e0806cbbb035e8dbdd11b6f05c253157ecbf3e14961b9e760a96752b4246b52c20efd62b06af0b1a038875c7fc1ce34b1
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -2,26 +2,32 @@ name: CI
|
|
|
2
2
|
|
|
3
3
|
on: [push]
|
|
4
4
|
|
|
5
|
+
permissions:
|
|
6
|
+
contents: read
|
|
7
|
+
|
|
5
8
|
jobs:
|
|
6
|
-
|
|
7
|
-
name:
|
|
9
|
+
lint:
|
|
10
|
+
name: StandardRB
|
|
8
11
|
runs-on: ubuntu-latest
|
|
9
|
-
|
|
10
12
|
steps:
|
|
11
13
|
- uses: actions/checkout@v4
|
|
12
|
-
|
|
13
|
-
- name: Set up Ruby
|
|
14
|
-
uses: ruby/setup-ruby@v1
|
|
14
|
+
- uses: ruby/setup-ruby@v1
|
|
15
15
|
with:
|
|
16
|
-
ruby-version:
|
|
16
|
+
ruby-version: "4.0"
|
|
17
17
|
bundler-cache: true
|
|
18
|
-
|
|
18
|
+
- run: bundle exec standardrb
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
test:
|
|
21
|
+
name: Test Ruby ${{ matrix.ruby }}
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
strategy:
|
|
24
|
+
fail-fast: false
|
|
25
|
+
matrix:
|
|
26
|
+
ruby: ["3.4", "4.0"]
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
- uses: ruby/setup-ruby@v1
|
|
30
|
+
with:
|
|
31
|
+
ruby-version: ${{ matrix.ruby }}
|
|
32
|
+
bundler-cache: true
|
|
33
|
+
- run: bundle exec rspec
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: Tag release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
id-token: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
release:
|
|
13
|
+
name: Publish gem & release
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
environment: release
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0
|
|
20
|
+
|
|
21
|
+
- name: Read version
|
|
22
|
+
id: v
|
|
23
|
+
run: |
|
|
24
|
+
ver="$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+' lib/blinkist/config/version.rb | head -1)"
|
|
25
|
+
echo "tag=v$ver" >> "$GITHUB_OUTPUT"
|
|
26
|
+
|
|
27
|
+
- name: Check whether tag exists
|
|
28
|
+
id: exists
|
|
29
|
+
run: |
|
|
30
|
+
if git ls-remote --exit-code --tags origin "refs/tags/${{ steps.v.outputs.tag }}" >/dev/null 2>&1; then
|
|
31
|
+
echo "Tag ${{ steps.v.outputs.tag }} already exists, skipping."
|
|
32
|
+
echo "exists=true" >> "$GITHUB_OUTPUT"
|
|
33
|
+
else
|
|
34
|
+
echo "exists=false" >> "$GITHUB_OUTPUT"
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
- uses: ruby/setup-ruby@v1
|
|
38
|
+
if: steps.exists.outputs.exists == 'false'
|
|
39
|
+
with:
|
|
40
|
+
ruby-version: "4.0"
|
|
41
|
+
bundler-cache: true
|
|
42
|
+
|
|
43
|
+
- name: Push gem to rubygems.org
|
|
44
|
+
if: steps.exists.outputs.exists == 'false'
|
|
45
|
+
uses: rubygems/release-gem@v1
|
|
46
|
+
|
|
47
|
+
- name: Create GitHub release
|
|
48
|
+
if: steps.exists.outputs.exists == 'false'
|
|
49
|
+
env:
|
|
50
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
51
|
+
run: |
|
|
52
|
+
gh release create "${{ steps.v.outputs.tag }}" \
|
|
53
|
+
--title "${{ steps.v.outputs.tag }}" \
|
|
54
|
+
--generate-notes
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: Version guard
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [main]
|
|
6
|
+
types: [opened, synchronize, reopened]
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
version-guard:
|
|
13
|
+
name: Ensure version bump
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
env:
|
|
16
|
+
BASE_REF: ${{ github.event.pull_request.base.ref }}
|
|
17
|
+
VERSION_FILE: lib/blinkist/config/version.rb
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
with:
|
|
21
|
+
fetch-depth: 0
|
|
22
|
+
|
|
23
|
+
- name: Compare version against base
|
|
24
|
+
run: |
|
|
25
|
+
git fetch origin "$BASE_REF" --quiet
|
|
26
|
+
extract() { grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1; }
|
|
27
|
+
base="$(git show "origin/$BASE_REF:$VERSION_FILE" | extract)"
|
|
28
|
+
head="$(extract < "$VERSION_FILE")"
|
|
29
|
+
echo "base ($BASE_REF): $base"
|
|
30
|
+
echo "head (this PR): $head"
|
|
31
|
+
|
|
32
|
+
if [ "$base" = "$head" ]; then
|
|
33
|
+
echo "::error file=$VERSION_FILE::Version not bumped. Update VERSION in $VERSION_FILE."
|
|
34
|
+
exit 1
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
highest="$(printf '%s\n%s\n' "$base" "$head" | sort -V | tail -1)"
|
|
38
|
+
if [ "$highest" != "$head" ]; then
|
|
39
|
+
echo "::error file=$VERSION_FILE::Version $head is not greater than main's $base. Rebase and bump above $base."
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
echo "Version bump OK: $base -> $head"
|
data/.gitignore
CHANGED
data/Dockerfile
CHANGED
|
@@ -1,36 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
ARG RUBY_VERSION=4.0
|
|
2
|
+
FROM ruby:${RUBY_VERSION}-alpine
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
ENV LANG en_US.UTF-8
|
|
5
|
-
ENV LANGUAGE en_US.UTF-8
|
|
6
|
-
ENV LC_ALL en_US.UTF-8
|
|
7
|
-
ENV LC_CTYPE en_US.UTF-8
|
|
8
|
-
ENV XDG_CACHE_HOME /nonexistent/.cache
|
|
4
|
+
RUN apk add --no-cache build-base git
|
|
9
5
|
|
|
10
|
-
ENV RUNTIME_PACKAGES pkg-config git
|
|
11
|
-
|
|
12
|
-
RUN mkdir /tmp/tmpapp
|
|
13
|
-
WORKDIR /tmp/tmpapp
|
|
14
|
-
ADD . /tmp/tmpapp
|
|
15
|
-
|
|
16
|
-
RUN echo 'gem: --no-document' >> ~/.gemrc && \
|
|
17
|
-
apt-get clean && apt-get update -qq && \
|
|
18
|
-
apt-get install -y build-essential $RUNTIME_PACKAGES && \
|
|
19
|
-
gem install bundler --version 2.2.10 && \
|
|
20
|
-
gem install gem-release && \
|
|
21
|
-
bundle update && bundle install --jobs 20 --retry 5 && \
|
|
22
|
-
rm -Rf /tmp/tmpapp/ && \
|
|
23
|
-
rm -rf /usr/share/doc/ /usr/share/man/ /usr/share/locale/ && apt-get clean
|
|
24
|
-
|
|
25
|
-
RUN mkdir /app
|
|
26
|
-
ADD . /app
|
|
27
6
|
WORKDIR /app
|
|
28
|
-
|
|
29
|
-
RUN bundle install -j1
|
|
30
|
-
|
|
31
|
-
RUN mkdir -p /nonexistent && \
|
|
32
|
-
mkdir -p /nonexistent/.cache && \
|
|
33
|
-
chown -R nobody:nogroup /app /nonexistent
|
|
34
|
-
RUN whoami
|
|
35
|
-
USER nobody
|
|
36
|
-
RUN whoami
|
data/Gemfile
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
source "https://rubygems.org"
|
|
2
2
|
|
|
3
|
-
# Specify your gem's dependencies in blinkist-config.gemspec
|
|
4
3
|
gemspec
|
|
5
4
|
|
|
6
5
|
group :development do
|
|
7
|
-
gem "bundler", "~> 2.6.9"
|
|
8
6
|
gem "rake", "~> 13.0"
|
|
9
7
|
gem "standard", ">= 1.50.0"
|
|
10
8
|
end
|
|
11
9
|
|
|
12
10
|
group :test do
|
|
13
|
-
gem "codeclimate-test-reporter", "~> 1.0.0"
|
|
14
11
|
gem "rspec"
|
|
15
12
|
gem "simplecov"
|
|
16
13
|
end
|
data/README.md
CHANGED
|
@@ -1,182 +1,125 @@
|
|
|
1
1
|
# Blinkist::Config
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://codeclimate.com/github/blinkist/blinkist-config)
|
|
3
|
+
Read configuration values through one interface, backed by the store you pick: the process ENV, AWS SSM Parameter Store, Consul (via Diplomat), or ENV with an SSM fallback.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
### Using the ENV
|
|
5
|
+
## Installation
|
|
9
6
|
|
|
10
7
|
```ruby
|
|
11
|
-
|
|
8
|
+
gem "blinkist-config"
|
|
9
|
+
```
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
config.url = "http://172.17.0.1:8500"
|
|
15
|
-
end
|
|
11
|
+
## Setup
|
|
16
12
|
|
|
13
|
+
Configure the gem once, before anything else loads. In Rails, put this in a `config.rb` and require it from `application.rb` right after `boot`.
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
17
16
|
Blinkist::Config.env = ENV["RAILS_ENV"]
|
|
18
17
|
Blinkist::Config.app_name = "my_nice_app"
|
|
19
|
-
Blinkist::Config.adapter_type = :env
|
|
18
|
+
Blinkist::Config.adapter_type = :env # :env, :aws_ssm, :env_over_ssm or :diplomat
|
|
20
19
|
Blinkist::Config.error_handler = :strict
|
|
21
|
-
|
|
22
|
-
my_config_value = Blinkist::Config.get! "some/folder/config"
|
|
23
|
-
|
|
24
|
-
# This is being translated to ENV["SOME_FOLDER_CONFIG"]
|
|
25
20
|
```
|
|
26
21
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
When configured with `Blinkist::Config.error_handler = :strict` (as recommended)
|
|
30
|
-
reading a configuration entry for which the value is missing
|
|
31
|
-
(for example missing enviroment variables) will cause
|
|
32
|
-
`Blinkist::Config::ValueMissingError` to be raised.
|
|
22
|
+
## Reading values
|
|
33
23
|
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
```ruby
|
|
25
|
+
Blinkist::Config.get! "some/folder/config"
|
|
26
|
+
```
|
|
36
27
|
|
|
37
|
-
|
|
28
|
+
With `:env` this reads `ENV["SOME_FOLDER_CONFIG"]`. With `:aws_ssm` it reads `/application/my_nice_app/some/folder/config`. With `:diplomat` it reads `my_nice_app/some/folder/config`.
|
|
38
29
|
|
|
39
|
-
###
|
|
30
|
+
### Default value
|
|
40
31
|
|
|
41
|
-
|
|
42
|
-
configuration entries then you canprovide a default value as a second
|
|
43
|
-
paramter to `get!`:
|
|
32
|
+
Pass a default as the second argument. Then a missing value returns the default instead of raising.
|
|
44
33
|
|
|
45
34
|
```ruby
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
# If ENV["SOME_FOLDER_CONFIG"] is nil, "default value" will be returned
|
|
35
|
+
Blinkist::Config.get! "some/folder/config", "default value"
|
|
49
36
|
```
|
|
50
37
|
|
|
51
|
-
###
|
|
38
|
+
### Scope
|
|
52
39
|
|
|
53
|
-
|
|
54
|
-
**WARNING**: This will cut into our SSM quota on AWS - please use this with caution and behind another way of caching.
|
|
55
|
-
See [AWS SSM Quota](https://docs.aws.amazon.com/general/latest/gr/ssm.html#parameter-store) for more information.
|
|
40
|
+
A scope replaces the app name in the key path. The `:env` adapter ignores it.
|
|
56
41
|
|
|
57
42
|
```ruby
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
#
|
|
43
|
+
Blinkist::Config.get! "another/config", scope: "global"
|
|
44
|
+
# aws_ssm: /application/global/another/config
|
|
45
|
+
# diplomat: global/another/config
|
|
61
46
|
```
|
|
62
47
|
|
|
63
|
-
###
|
|
64
|
-
|
|
65
|
-
If you want to use Consul's key value store, simply use our diplomat adapter.
|
|
48
|
+
### Refetch
|
|
66
49
|
|
|
67
|
-
|
|
68
|
-
- [https://github.com/WeAreFarmGeek/diplomat](https://github.com/WeAreFarmGeek/diplomat)
|
|
69
|
-
|
|
70
|
-
The GEM expects consul to listen to `http://172.17.0.1:8500`
|
|
50
|
+
Values are cached after the first read. Pass `refetch: true` to read from the store again. This costs SSM quota, so use it with care.
|
|
71
51
|
|
|
72
52
|
```ruby
|
|
73
|
-
|
|
74
|
-
Blinkist::Config.env = ENV["RAILS_ENV"]
|
|
75
|
-
Blinkist::Config.app_name = "my_nice_app"
|
|
76
|
-
Blinkist::Config.adapter_type = ENV["CONSUL_AVAILABLE"] == "true" ? :diplomat : :env
|
|
77
|
-
|
|
78
|
-
my_config_value = Blinkist::Config.get! "some/folder/config"
|
|
79
|
-
|
|
80
|
-
# This is will try to get a value from Consul's KV store at "my_nice_app/some/folder/config"
|
|
53
|
+
Blinkist::Config.get! "some/folder/config", refetch: true
|
|
81
54
|
```
|
|
82
55
|
|
|
83
|
-
###
|
|
56
|
+
### Error handling
|
|
84
57
|
|
|
85
|
-
|
|
86
|
-
|
|
58
|
+
- `:strict` raises `Blinkist::Config::ValueMissingError` when a value is missing. Recommended.
|
|
59
|
+
- `:heuristic` raises only when `env == "production"`. This is the default for backwards compatibility.
|
|
87
60
|
|
|
88
|
-
|
|
61
|
+
## Adapters
|
|
89
62
|
|
|
90
|
-
|
|
91
|
-
# With :env the scope will simply be ignored
|
|
92
|
-
```
|
|
63
|
+
### `:env`
|
|
93
64
|
|
|
94
|
-
|
|
65
|
+
Reads from `ENV`. The key is upcased and `/` becomes `_`.
|
|
95
66
|
|
|
96
|
-
|
|
67
|
+
### `:aws_ssm`
|
|
97
68
|
|
|
98
|
-
|
|
69
|
+
Reads from AWS SSM Parameter Store with decryption. The code must run with IAM access to the parameters.
|
|
99
70
|
|
|
100
71
|
```ruby
|
|
101
|
-
Blinkist::Config.
|
|
102
|
-
Blinkist::Config.app_name = "my_nice_app"
|
|
103
|
-
Blinkist::Config.adapter_type = ENV["SSM_AVAILABLE"] == "true" ? :aws_ssm : :env
|
|
72
|
+
Blinkist::Config.adapter_type = :aws_ssm
|
|
104
73
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
# This is will try to get a parameter from SSM at "/application/my_nice_app/some/folder/config"
|
|
108
|
-
|
|
109
|
-
# You can also preload all parameters to avoid later calls to SSM
|
|
74
|
+
# Load all parameters of a scope in one call to avoid later lookups
|
|
110
75
|
Blinkist::Config.preload
|
|
111
|
-
Blinkist::Config.preload scope: "global"
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Using SSM with a folder scope
|
|
115
|
-
|
|
116
|
-
```ruby
|
|
117
|
-
# Here we setting a scope outside of the app
|
|
118
|
-
|
|
119
|
-
my_config_value = Blinkist::Config.get! "another/config", scope: "global"
|
|
120
|
-
|
|
121
|
-
# This will replace `my_nice_app` with `global` and try to resolve "/application/global/another/config"
|
|
76
|
+
Blinkist::Config.preload scope: "global"
|
|
122
77
|
```
|
|
123
78
|
|
|
124
|
-
|
|
79
|
+
### `:env_over_ssm`
|
|
125
80
|
|
|
126
|
-
|
|
81
|
+
Reads from `ENV` first. When the ENV has no value, it falls back to SSM. This lets you override single SSM values locally or in CI without touching the parameter store.
|
|
127
82
|
|
|
128
83
|
```ruby
|
|
129
|
-
|
|
130
|
-
```
|
|
84
|
+
Blinkist::Config.adapter_type = :env_over_ssm
|
|
131
85
|
|
|
132
|
-
|
|
86
|
+
Blinkist::Config.get! "database/url"
|
|
87
|
+
# 1. ENV["DATABASE_URL"] if set
|
|
88
|
+
# 2. otherwise /application/my_nice_app/database/url from SSM
|
|
89
|
+
```
|
|
133
90
|
|
|
134
|
-
|
|
91
|
+
`scope`, `refetch` and `preload` apply to the SSM part only.
|
|
135
92
|
|
|
136
|
-
|
|
137
|
-
Blinkist::Config.env = "production" || "test" || "development"
|
|
138
|
-
Blinkist::Config.app_name = "your_app_name" # Used only with diplomat adapter
|
|
139
|
-
Blinkist::Config.adapter_type = :diplomat || :env
|
|
140
|
-
```
|
|
93
|
+
### `:diplomat`
|
|
141
94
|
|
|
142
|
-
|
|
95
|
+
Reads from Consul's key value store through [Diplomat](https://github.com/WeAreFarmGeek/diplomat). Configure Diplomat yourself before use.
|
|
143
96
|
|
|
144
97
|
```ruby
|
|
145
|
-
|
|
146
|
-
|
|
98
|
+
Diplomat.configure do |config|
|
|
99
|
+
config.url = "http://172.17.0.1:8500"
|
|
100
|
+
end
|
|
147
101
|
|
|
148
|
-
|
|
149
|
-
# ...
|
|
102
|
+
Blinkist::Config.adapter_type = :diplomat
|
|
150
103
|
```
|
|
151
104
|
|
|
152
105
|
## Development
|
|
153
106
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
```
|
|
157
|
-
docker compose run rake
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
This will execute rake and run all specs by auto correcting the code with StandardRB.
|
|
107
|
+
Requires [Task](https://taskfile.dev) and Docker.
|
|
161
108
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
109
|
+
```sh
|
|
110
|
+
task bundle # install gems for all supported Ruby versions
|
|
111
|
+
task test # run specs on all supported Ruby versions
|
|
112
|
+
task test:local # run specs on the default Ruby version
|
|
113
|
+
task test:3.4 # run specs on one Ruby version
|
|
114
|
+
task lint # run StandardRB
|
|
115
|
+
task shell # open a shell in the container
|
|
166
116
|
```
|
|
167
117
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
```
|
|
171
|
-
docker compose run gem release
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
You'll have to have proper rights to access rubygems.org
|
|
175
|
-
|
|
176
|
-
## Contributing
|
|
118
|
+
## Release
|
|
177
119
|
|
|
178
|
-
|
|
120
|
+
1. Bump `VERSION` in `lib/blinkist/config/version.rb`. The `version-guard` workflow fails a PR to `main` without a bump.
|
|
121
|
+
2. Merge to `main`.
|
|
179
122
|
|
|
180
123
|
## License
|
|
181
124
|
|
|
182
|
-
|
|
125
|
+
MIT, see [LICENSE](LICENSE).
|
data/Taskfile.yml
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
version: "3"
|
|
2
|
+
|
|
3
|
+
tasks:
|
|
4
|
+
default:
|
|
5
|
+
desc: List all available tasks
|
|
6
|
+
cmds:
|
|
7
|
+
- task --list-all
|
|
8
|
+
silent: true
|
|
9
|
+
|
|
10
|
+
bundle:
|
|
11
|
+
desc: Bundles the gem in Docker for all supported Ruby versions
|
|
12
|
+
deps:
|
|
13
|
+
- bundle:3.4
|
|
14
|
+
- bundle:4.0
|
|
15
|
+
# we need stty sane to fix terminal output after running task bundle in parallel
|
|
16
|
+
cmd: stty sane
|
|
17
|
+
|
|
18
|
+
bundle:*:
|
|
19
|
+
env:
|
|
20
|
+
RUBY_VERSION: "{{index .MATCH 0}}"
|
|
21
|
+
cmds:
|
|
22
|
+
- docker compose run --rm ruby bundle install -j8
|
|
23
|
+
|
|
24
|
+
test:
|
|
25
|
+
desc: Runs tests against all supported Ruby versions
|
|
26
|
+
cmds:
|
|
27
|
+
- task: test:3.4
|
|
28
|
+
- task: test:4.0
|
|
29
|
+
|
|
30
|
+
test:local:
|
|
31
|
+
desc: Runs tests against the default Ruby version
|
|
32
|
+
cmds:
|
|
33
|
+
- task: test:4.0
|
|
34
|
+
vars:
|
|
35
|
+
CLI_ARGS: "{{.CLI_ARGS}}"
|
|
36
|
+
|
|
37
|
+
test:*:
|
|
38
|
+
env:
|
|
39
|
+
RUBY_VERSION: "{{index .MATCH 0}}"
|
|
40
|
+
cmds:
|
|
41
|
+
- docker compose run --rm ruby bundle exec rspec {{.CLI_ARGS}}
|
|
42
|
+
|
|
43
|
+
lint:
|
|
44
|
+
desc: Runs StandardRB
|
|
45
|
+
env:
|
|
46
|
+
RUBY_VERSION: "4.0"
|
|
47
|
+
cmds:
|
|
48
|
+
- docker compose run --rm ruby bundle exec standardrb {{.CLI_ARGS}}
|
|
49
|
+
|
|
50
|
+
run:
|
|
51
|
+
desc: Runs an arbitrary command in the default Ruby container
|
|
52
|
+
env:
|
|
53
|
+
RUBY_VERSION: "4.0"
|
|
54
|
+
cmds:
|
|
55
|
+
- docker compose run --rm ruby {{.CLI_ARGS}}
|
|
56
|
+
|
|
57
|
+
shell:
|
|
58
|
+
desc: Opens a shell in the default Ruby container
|
|
59
|
+
env:
|
|
60
|
+
RUBY_VERSION: "4.0"
|
|
61
|
+
cmds:
|
|
62
|
+
- docker compose run --rm ruby ash
|
|
63
|
+
|
|
64
|
+
docker:clean:
|
|
65
|
+
desc: Purges local Docker setup
|
|
66
|
+
cmds:
|
|
67
|
+
- docker compose down -v --remove-orphans --rmi local
|
|
68
|
+
- rm -rf .docker-compose/*
|
data/docker-compose.yml
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
services:
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
ruby:
|
|
3
|
+
image: blinkist-config-ruby:${RUBY_VERSION:-4.0}
|
|
4
4
|
build:
|
|
5
5
|
context: .
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
args:
|
|
7
|
+
RUBY_VERSION: ${RUBY_VERSION:-4.0}
|
|
8
|
+
tty: true
|
|
9
9
|
volumes:
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
gem:
|
|
13
|
-
build:
|
|
14
|
-
context: .
|
|
15
|
-
entrypoint: gem
|
|
16
|
-
volumes:
|
|
17
|
-
- .:/app
|
|
18
|
-
- ~/.gitconfig:/nonexistent/.gitconfig
|
|
19
|
-
- ~/.ssh:/nonexistent/.ssh
|
|
20
|
-
- ~/.gem:/nonexistent/.gem
|
|
10
|
+
- ./:/app
|
|
11
|
+
- .docker-compose/bundle-${RUBY_VERSION:-4.0}:/usr/local/bundle
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require_relative "adapter"
|
|
2
|
+
require_relative "env_adapter"
|
|
3
|
+
require_relative "aws_ssm_adapter"
|
|
4
|
+
|
|
5
|
+
module Blinkist
|
|
6
|
+
class Config
|
|
7
|
+
class EnvOverSsmAdapter < Adapter
|
|
8
|
+
def initialize(env, app_name)
|
|
9
|
+
super
|
|
10
|
+
|
|
11
|
+
@env_adapter = EnvAdapter.new(env, app_name)
|
|
12
|
+
@ssm_adapter = AwsSsmAdapter.new(env, app_name)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def get(key, default = nil, scope: nil, refetch: false)
|
|
16
|
+
@env_adapter.get(key) || @ssm_adapter.get(key, default, scope: scope, refetch: refetch)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def preload(scope: nil)
|
|
20
|
+
@ssm_adapter.preload(scope: scope)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
data/lib/blinkist/config.rb
CHANGED
|
@@ -10,6 +10,7 @@ require_relative "config/error_handlers"
|
|
|
10
10
|
require_relative "config/adapters/env_adapter"
|
|
11
11
|
require_relative "config/adapters/diplomat_adapter"
|
|
12
12
|
require_relative "config/adapters/aws_ssm_adapter"
|
|
13
|
+
require_relative "config/adapters/env_over_ssm_adapter"
|
|
13
14
|
require_relative "config/adapters"
|
|
14
15
|
|
|
15
16
|
module Blinkist
|
|
@@ -26,6 +27,7 @@ module Blinkist
|
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
extend Gem::Deprecate
|
|
30
|
+
|
|
29
31
|
deprecate :get, "get!", 2017, 12
|
|
30
32
|
|
|
31
33
|
def get!(key, *args, scope: nil, refetch: false)
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: blinkist-config
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sebastian Schleicher, Blinks Labs GmbH
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: aws-sdk-ssm
|
|
@@ -49,7 +48,8 @@ extensions: []
|
|
|
49
48
|
extra_rdoc_files: []
|
|
50
49
|
files:
|
|
51
50
|
- ".github/workflows/ci.yml"
|
|
52
|
-
- ".github/workflows/
|
|
51
|
+
- ".github/workflows/tag-release.yml"
|
|
52
|
+
- ".github/workflows/version-guard.yml"
|
|
53
53
|
- ".gitignore"
|
|
54
54
|
- Dockerfile
|
|
55
55
|
- Gemfile
|
|
@@ -57,6 +57,7 @@ files:
|
|
|
57
57
|
- LICENSE.txt
|
|
58
58
|
- README.md
|
|
59
59
|
- Rakefile
|
|
60
|
+
- Taskfile.yml
|
|
60
61
|
- bin/console
|
|
61
62
|
- bin/setup
|
|
62
63
|
- blinkist-config.gemspec
|
|
@@ -67,6 +68,7 @@ files:
|
|
|
67
68
|
- lib/blinkist/config/adapters/aws_ssm_adapter.rb
|
|
68
69
|
- lib/blinkist/config/adapters/diplomat_adapter.rb
|
|
69
70
|
- lib/blinkist/config/adapters/env_adapter.rb
|
|
71
|
+
- lib/blinkist/config/adapters/env_over_ssm_adapter.rb
|
|
70
72
|
- lib/blinkist/config/error.rb
|
|
71
73
|
- lib/blinkist/config/error_handlers.rb
|
|
72
74
|
- lib/blinkist/config/error_handlers/error_handler.rb
|
|
@@ -81,7 +83,6 @@ licenses:
|
|
|
81
83
|
- MIT
|
|
82
84
|
metadata:
|
|
83
85
|
rubygems_mfa_required: 'true'
|
|
84
|
-
post_install_message:
|
|
85
86
|
rdoc_options: []
|
|
86
87
|
require_paths:
|
|
87
88
|
- lib
|
|
@@ -96,8 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
96
97
|
- !ruby/object:Gem::Version
|
|
97
98
|
version: '0'
|
|
98
99
|
requirements: []
|
|
99
|
-
rubygems_version:
|
|
100
|
-
signing_key:
|
|
100
|
+
rubygems_version: 4.0.20
|
|
101
101
|
specification_version: 4
|
|
102
102
|
summary: Simple adapter based configuration handler (supports ENV and Consul/Diplomat).
|
|
103
103
|
test_files: []
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# For most projects, this workflow file will not need changing; you simply need
|
|
2
|
-
# to commit it to your repository.
|
|
3
|
-
#
|
|
4
|
-
# You may wish to alter this file to override the set of languages analyzed,
|
|
5
|
-
# or to provide custom queries or build logic.
|
|
6
|
-
#
|
|
7
|
-
# ******** NOTE ********
|
|
8
|
-
# We have attempted to detect the languages in your repository. Please check
|
|
9
|
-
# the `language` matrix defined below to confirm you have the correct set of
|
|
10
|
-
# supported CodeQL languages.
|
|
11
|
-
#
|
|
12
|
-
name: "CodeQL"
|
|
13
|
-
|
|
14
|
-
on:
|
|
15
|
-
push:
|
|
16
|
-
branches: [ main ]
|
|
17
|
-
pull_request:
|
|
18
|
-
# The branches below must be a subset of the branches above
|
|
19
|
-
branches: [ main ]
|
|
20
|
-
schedule:
|
|
21
|
-
- cron: '35 19 * * 6'
|
|
22
|
-
|
|
23
|
-
jobs:
|
|
24
|
-
analyze:
|
|
25
|
-
name: Analyze
|
|
26
|
-
runs-on: ubuntu-latest
|
|
27
|
-
permissions:
|
|
28
|
-
actions: read
|
|
29
|
-
contents: read
|
|
30
|
-
security-events: write
|
|
31
|
-
|
|
32
|
-
strategy:
|
|
33
|
-
fail-fast: false
|
|
34
|
-
matrix:
|
|
35
|
-
language: [ 'ruby' ]
|
|
36
|
-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
|
37
|
-
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
|
38
|
-
|
|
39
|
-
steps:
|
|
40
|
-
- name: Checkout repository
|
|
41
|
-
uses: actions/checkout@v2
|
|
42
|
-
|
|
43
|
-
# Initializes the CodeQL tools for scanning.
|
|
44
|
-
- name: Initialize CodeQL
|
|
45
|
-
uses: github/codeql-action/init@v1
|
|
46
|
-
with:
|
|
47
|
-
languages: ${{ matrix.language }}
|
|
48
|
-
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
49
|
-
# By default, queries listed here will override any specified in a config file.
|
|
50
|
-
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
51
|
-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
|
52
|
-
|
|
53
|
-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
|
54
|
-
# If this step fails, then you should remove it and run the build manually (see below)
|
|
55
|
-
- name: Autobuild
|
|
56
|
-
uses: github/codeql-action/autobuild@v1
|
|
57
|
-
|
|
58
|
-
# ℹ️ Command-line programs to run using the OS shell.
|
|
59
|
-
# 📚 https://git.io/JvXDl
|
|
60
|
-
|
|
61
|
-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
|
62
|
-
# and modify them (or add more) to build your code if your project
|
|
63
|
-
# uses a compiled language
|
|
64
|
-
|
|
65
|
-
#- run: |
|
|
66
|
-
# make bootstrap
|
|
67
|
-
# make release
|
|
68
|
-
|
|
69
|
-
- name: Perform CodeQL Analysis
|
|
70
|
-
uses: github/codeql-action/analyze@v1
|