metatron 0.11.4 → 0.12.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/.dockerignore +9 -0
- data/.github/workflows/ci.yml +66 -1
- data/.release-please-manifest.json +1 -1
- data/.rubocop.yml +4 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +30 -0
- data/CONTRIBUTING.md +32 -1
- data/Gemfile +5 -0
- data/Gemfile.lock +16 -10
- data/README.md +55 -0
- data/Rakefile +5 -0
- data/integration/Dockerfile +29 -0
- data/integration/controller/Gemfile +9 -0
- data/integration/controller/Gemfile.lock +32 -0
- data/integration/controller/config.ru +21 -0
- data/integration/controller/lib/request_logger.rb +18 -0
- data/integration/controller/lib/widget_controller.rb +84 -0
- data/integration/manifests/composite-controller.yaml +62 -0
- data/integration/manifests/controller.yaml +70 -0
- data/integration/manifests/crd.yaml +46 -0
- data/integration/manifests/namespace.yaml +6 -0
- data/integration/manifests/sample-widget.yaml +9 -0
- data/lib/metatron/composite_controller.rb +4 -1
- data/lib/metatron/controller.rb +49 -7
- data/lib/metatron/middleware/auth.rb +103 -0
- data/lib/metatron/middleware/body_limit.rb +85 -0
- data/lib/metatron/problem.rb +47 -0
- data/lib/metatron/template.rb +4 -0
- data/lib/metatron/version.rb +1 -1
- data/lib/metatron.rb +10 -1
- data/metatron.gemspec +7 -4
- data/script/integration +182 -0
- metadata +48 -16
data/script/integration
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# Run Metatron's integration suite against a real Metacontroller installation
|
|
4
|
+
# in a throwaway k3d cluster.
|
|
5
|
+
#
|
|
6
|
+
# Usage:
|
|
7
|
+
# script/integration # create cluster, run specs, delete cluster
|
|
8
|
+
# script/integration --keep # leave the cluster running for debugging
|
|
9
|
+
# script/integration --metacontroller-version v4.17.6
|
|
10
|
+
# script/integration --k3d-version v5.9.0
|
|
11
|
+
#
|
|
12
|
+
# Environment:
|
|
13
|
+
# K3D_CLUSTER_NAME cluster name (default: metatron-integration)
|
|
14
|
+
# K3D_VERSION expected k3d version, verified when set
|
|
15
|
+
# METATRON_IT_NAMESPACE namespace for the fixture controller
|
|
16
|
+
# METATRON_IT_IMAGE fixture image tag (default: metatron-integration:test)
|
|
17
|
+
# METATRON_IT_AUTH_TOKEN bearer token shared with Metacontroller
|
|
18
|
+
# METACONTROLLER_VERSION release tag to install (default: v4.17.6)
|
|
19
|
+
# METACONTROLLER_REPO local Metacontroller clone; used when the tag exists
|
|
20
|
+
set -euo pipefail
|
|
21
|
+
|
|
22
|
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
23
|
+
|
|
24
|
+
CLUSTER="${K3D_CLUSTER_NAME:-metatron-integration}"
|
|
25
|
+
K3D_VERSION="${K3D_VERSION:-}"
|
|
26
|
+
NAMESPACE="${METATRON_IT_NAMESPACE:-metatron-integration}"
|
|
27
|
+
IMAGE="${METATRON_IT_IMAGE:-metatron-integration:test}"
|
|
28
|
+
AUTH_TOKEN="${METATRON_IT_AUTH_TOKEN:-integration-secret-token}"
|
|
29
|
+
METACONTROLLER_VERSION="${METACONTROLLER_VERSION:-v4.17.6}"
|
|
30
|
+
METACONTROLLER_REPO="${METACONTROLLER_REPO:-$HOME/Development/golang/metacontroller}"
|
|
31
|
+
KEEP=0
|
|
32
|
+
|
|
33
|
+
usage() {
|
|
34
|
+
sed -n '2,/^set -euo pipefail$/p' "$0" | sed '$d' | sed 's/^# \{0,1\}//'
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
while [[ $# -gt 0 ]]; do
|
|
38
|
+
case "$1" in
|
|
39
|
+
--keep)
|
|
40
|
+
KEEP=1
|
|
41
|
+
shift
|
|
42
|
+
;;
|
|
43
|
+
--metacontroller-version)
|
|
44
|
+
METACONTROLLER_VERSION="${2:?missing version}"
|
|
45
|
+
shift 2
|
|
46
|
+
;;
|
|
47
|
+
--k3d-version)
|
|
48
|
+
K3D_VERSION="${2:?missing version}"
|
|
49
|
+
shift 2
|
|
50
|
+
;;
|
|
51
|
+
-h|--help)
|
|
52
|
+
usage
|
|
53
|
+
exit 0
|
|
54
|
+
;;
|
|
55
|
+
*)
|
|
56
|
+
echo "unknown argument: $1" >&2
|
|
57
|
+
usage >&2
|
|
58
|
+
exit 1
|
|
59
|
+
;;
|
|
60
|
+
esac
|
|
61
|
+
done
|
|
62
|
+
|
|
63
|
+
for command in docker k3d kubectl; do
|
|
64
|
+
if ! command -v "$command" >/dev/null 2>&1; then
|
|
65
|
+
echo "error: $command is required but not installed" >&2
|
|
66
|
+
exit 1
|
|
67
|
+
fi
|
|
68
|
+
done
|
|
69
|
+
|
|
70
|
+
if ! docker info >/dev/null 2>&1; then
|
|
71
|
+
echo "error: the Docker daemon is not reachable" >&2
|
|
72
|
+
exit 1
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
if [[ -n "$K3D_VERSION" ]]; then
|
|
76
|
+
installed_k3d="$(k3d version | awk '/^k3d version/ {print $3; exit}')"
|
|
77
|
+
if [[ "$installed_k3d" != "$K3D_VERSION" ]]; then
|
|
78
|
+
echo "error: requested k3d $K3D_VERSION but $installed_k3d is installed" >&2
|
|
79
|
+
exit 1
|
|
80
|
+
fi
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
KUBECONFIG_FILE=""
|
|
84
|
+
cleanup() {
|
|
85
|
+
status=$?
|
|
86
|
+
if [[ "$KEEP" -eq 0 ]]; then
|
|
87
|
+
k3d cluster delete "$CLUSTER" >/dev/null 2>&1 || true
|
|
88
|
+
else
|
|
89
|
+
echo
|
|
90
|
+
echo "Cluster '$CLUSTER' left running."
|
|
91
|
+
echo " export KUBECONFIG=$KUBECONFIG_FILE"
|
|
92
|
+
echo " kubectl -n $NAMESPACE get widgets,deployments,services,configmaps,secrets"
|
|
93
|
+
fi
|
|
94
|
+
if [[ "$KEEP" -eq 0 && -n "$KUBECONFIG_FILE" ]]; then
|
|
95
|
+
rm -f "$KUBECONFIG_FILE"
|
|
96
|
+
fi
|
|
97
|
+
exit "$status"
|
|
98
|
+
}
|
|
99
|
+
trap cleanup EXIT INT TERM
|
|
100
|
+
|
|
101
|
+
dump_debug() {
|
|
102
|
+
echo "=== cluster state ===" >&2
|
|
103
|
+
kubectl get pods -A >&2 || true
|
|
104
|
+
echo "=== fixture controller logs ===" >&2
|
|
105
|
+
kubectl -n "$NAMESPACE" logs -l app=widget-controller --tail=200 >&2 || true
|
|
106
|
+
}
|
|
107
|
+
trap dump_debug ERR
|
|
108
|
+
|
|
109
|
+
render_manifest() {
|
|
110
|
+
sed -e "s|__NAMESPACE__|$NAMESPACE|g" \
|
|
111
|
+
-e "s|__IMAGE__|$IMAGE|g" \
|
|
112
|
+
-e "s|__AUTH_TOKEN__|$AUTH_TOKEN|g" \
|
|
113
|
+
"$1"
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
apply_metacontroller_manifest() {
|
|
117
|
+
local file="$1"
|
|
118
|
+
if [[ -n "$LOCAL_MANIFESTS" ]]; then
|
|
119
|
+
git -C "$METACONTROLLER_REPO" show "$METACONTROLLER_VERSION:manifests/production/$file" | kubectl apply -f -
|
|
120
|
+
else
|
|
121
|
+
kubectl apply -f "$REMOTE_MANIFESTS/$file"
|
|
122
|
+
fi
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
# Prefer the local Metacontroller clone when it has the requested tag, so
|
|
126
|
+
# local runs do not depend on GitHub. CI falls back to the pinned release URL.
|
|
127
|
+
LOCAL_MANIFESTS=""
|
|
128
|
+
REMOTE_MANIFESTS=""
|
|
129
|
+
if [[ -d "$METACONTROLLER_REPO/.git" ]] && \
|
|
130
|
+
git -C "$METACONTROLLER_REPO" rev-parse -q --verify "refs/tags/$METACONTROLLER_VERSION" >/dev/null; then
|
|
131
|
+
LOCAL_MANIFESTS=1
|
|
132
|
+
echo "Using Metacontroller $METACONTROLLER_VERSION manifests from $METACONTROLLER_REPO"
|
|
133
|
+
else
|
|
134
|
+
REMOTE_MANIFESTS="https://raw.githubusercontent.com/metacontroller/metacontroller/${METACONTROLLER_VERSION}/manifests/production"
|
|
135
|
+
echo "Using Metacontroller $METACONTROLLER_VERSION manifests from $REMOTE_MANIFESTS"
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
echo "Creating k3d cluster '$CLUSTER'"
|
|
139
|
+
k3d cluster delete "$CLUSTER" >/dev/null 2>&1 || true
|
|
140
|
+
k3d cluster create "$CLUSTER" \
|
|
141
|
+
--agents 1 \
|
|
142
|
+
--wait \
|
|
143
|
+
--timeout 180s \
|
|
144
|
+
--kubeconfig-update-default=false \
|
|
145
|
+
--kubeconfig-switch-context=false
|
|
146
|
+
|
|
147
|
+
KUBECONFIG_FILE="$(mktemp)"
|
|
148
|
+
k3d kubeconfig write "$CLUSTER" --output "$KUBECONFIG_FILE" >/dev/null
|
|
149
|
+
export KUBECONFIG="$KUBECONFIG_FILE"
|
|
150
|
+
|
|
151
|
+
echo "Building fixture controller image '$IMAGE'"
|
|
152
|
+
docker build --file "$ROOT/integration/Dockerfile" --tag "$IMAGE" "$ROOT"
|
|
153
|
+
|
|
154
|
+
echo "Importing '$IMAGE' into '$CLUSTER'"
|
|
155
|
+
k3d image import "$IMAGE" --cluster "$CLUSTER"
|
|
156
|
+
|
|
157
|
+
echo "Installing Metacontroller $METACONTROLLER_VERSION"
|
|
158
|
+
apply_metacontroller_manifest metacontroller-namespace.yaml
|
|
159
|
+
apply_metacontroller_manifest metacontroller-crds-v1.yaml
|
|
160
|
+
apply_metacontroller_manifest metacontroller-rbac.yaml
|
|
161
|
+
apply_metacontroller_manifest metacontroller.yaml
|
|
162
|
+
|
|
163
|
+
kubectl wait --for=condition=Established --timeout=120s \
|
|
164
|
+
crd/compositecontrollers.metacontroller.k8s.io
|
|
165
|
+
kubectl -n metacontroller rollout status statefulset/metacontroller --timeout=180s
|
|
166
|
+
|
|
167
|
+
echo "Deploying fixture controller in namespace '$NAMESPACE'"
|
|
168
|
+
render_manifest "$ROOT/integration/manifests/namespace.yaml" | kubectl apply -f -
|
|
169
|
+
render_manifest "$ROOT/integration/manifests/crd.yaml" | kubectl apply -f -
|
|
170
|
+
kubectl wait --for=condition=Established --timeout=120s \
|
|
171
|
+
crd/widgets.metatron.therubyist.org
|
|
172
|
+
render_manifest "$ROOT/integration/manifests/controller.yaml" | kubectl apply -f -
|
|
173
|
+
kubectl -n "$NAMESPACE" rollout status deployment/widget-controller --timeout=180s
|
|
174
|
+
render_manifest "$ROOT/integration/manifests/composite-controller.yaml" | kubectl apply -f -
|
|
175
|
+
|
|
176
|
+
export RUN_INTEGRATION=1
|
|
177
|
+
export METATRON_IT_NAMESPACE="$NAMESPACE"
|
|
178
|
+
export METATRON_IT_RUN_ID="${METATRON_IT_RUN_ID:-$(date +%s)-$$}"
|
|
179
|
+
export METATRON_IT_AUTH_TOKEN="$AUTH_TOKEN"
|
|
180
|
+
|
|
181
|
+
cd "$ROOT"
|
|
182
|
+
bundle exec rspec spec/integration --format documentation
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metatron
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Gnagy
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
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: base64
|
|
@@ -28,23 +27,43 @@ dependencies:
|
|
|
28
27
|
name: json
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
|
-
- - "
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 2.21.2
|
|
33
|
+
- - "<"
|
|
32
34
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
35
|
+
version: '3'
|
|
34
36
|
type: :runtime
|
|
35
37
|
prerelease: false
|
|
36
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
39
|
requirements:
|
|
38
|
-
- - "
|
|
40
|
+
- - ">="
|
|
39
41
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
42
|
+
version: 2.21.2
|
|
43
|
+
- - "<"
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '3'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: logger
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '0'
|
|
53
|
+
type: :runtime
|
|
54
|
+
prerelease: false
|
|
55
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '0'
|
|
41
60
|
- !ruby/object:Gem::Dependency
|
|
42
61
|
name: rack
|
|
43
62
|
requirement: !ruby/object:Gem::Requirement
|
|
44
63
|
requirements:
|
|
45
64
|
- - ">="
|
|
46
65
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 2.2.
|
|
66
|
+
version: 2.2.25
|
|
48
67
|
- - "<"
|
|
49
68
|
- !ruby/object:Gem::Version
|
|
50
69
|
version: '4'
|
|
@@ -54,7 +73,7 @@ dependencies:
|
|
|
54
73
|
requirements:
|
|
55
74
|
- - ">="
|
|
56
75
|
- !ruby/object:Gem::Version
|
|
57
|
-
version: 2.2.
|
|
76
|
+
version: 2.2.25
|
|
58
77
|
- - "<"
|
|
59
78
|
- !ruby/object:Gem::Version
|
|
60
79
|
version: '4'
|
|
@@ -62,14 +81,14 @@ dependencies:
|
|
|
62
81
|
name: bundler
|
|
63
82
|
requirement: !ruby/object:Gem::Requirement
|
|
64
83
|
requirements:
|
|
65
|
-
- - "
|
|
84
|
+
- - ">="
|
|
66
85
|
- !ruby/object:Gem::Version
|
|
67
86
|
version: '2.3'
|
|
68
87
|
type: :development
|
|
69
88
|
prerelease: false
|
|
70
89
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
90
|
requirements:
|
|
72
|
-
- - "
|
|
91
|
+
- - ">="
|
|
73
92
|
- !ruby/object:Gem::Version
|
|
74
93
|
version: '2.3'
|
|
75
94
|
- !ruby/object:Gem::Dependency
|
|
@@ -226,13 +245,13 @@ dependencies:
|
|
|
226
245
|
- - "~>"
|
|
227
246
|
- !ruby/object:Gem::Version
|
|
228
247
|
version: '0.9'
|
|
229
|
-
description:
|
|
230
248
|
email:
|
|
231
249
|
- jonathan.gnagy@gmail.com
|
|
232
250
|
executables: []
|
|
233
251
|
extensions: []
|
|
234
252
|
extra_rdoc_files: []
|
|
235
253
|
files:
|
|
254
|
+
- ".dockerignore"
|
|
236
255
|
- ".github/workflows/ci.yml"
|
|
237
256
|
- ".github/workflows/release.yml"
|
|
238
257
|
- ".gitignore"
|
|
@@ -249,10 +268,24 @@ files:
|
|
|
249
268
|
- README.md
|
|
250
269
|
- Rakefile
|
|
251
270
|
- bin/console
|
|
271
|
+
- integration/Dockerfile
|
|
272
|
+
- integration/controller/Gemfile
|
|
273
|
+
- integration/controller/Gemfile.lock
|
|
274
|
+
- integration/controller/config.ru
|
|
275
|
+
- integration/controller/lib/request_logger.rb
|
|
276
|
+
- integration/controller/lib/widget_controller.rb
|
|
277
|
+
- integration/manifests/composite-controller.yaml
|
|
278
|
+
- integration/manifests/controller.yaml
|
|
279
|
+
- integration/manifests/crd.yaml
|
|
280
|
+
- integration/manifests/namespace.yaml
|
|
281
|
+
- integration/manifests/sample-widget.yaml
|
|
252
282
|
- lib/metatron.rb
|
|
253
283
|
- lib/metatron/composite_controller.rb
|
|
254
284
|
- lib/metatron/controller.rb
|
|
255
285
|
- lib/metatron/controllers/ping.rb
|
|
286
|
+
- lib/metatron/middleware/auth.rb
|
|
287
|
+
- lib/metatron/middleware/body_limit.rb
|
|
288
|
+
- lib/metatron/problem.rb
|
|
256
289
|
- lib/metatron/railtie.rb
|
|
257
290
|
- lib/metatron/template.rb
|
|
258
291
|
- lib/metatron/templates/cluster_role.rb
|
|
@@ -302,6 +335,7 @@ files:
|
|
|
302
335
|
- lib/metatron/version.rb
|
|
303
336
|
- metatron.gemspec
|
|
304
337
|
- release-please-config.json
|
|
338
|
+
- script/integration
|
|
305
339
|
homepage: https://github.com/jgnagy/metatron
|
|
306
340
|
licenses:
|
|
307
341
|
- MIT
|
|
@@ -309,7 +343,6 @@ metadata:
|
|
|
309
343
|
homepage_uri: https://github.com/jgnagy/metatron
|
|
310
344
|
source_code_uri: https://github.com/jgnagy/metatron
|
|
311
345
|
changelog_uri: https://github.com/jgnagy/metatron/blob/main/CHANGELOG.md
|
|
312
|
-
post_install_message:
|
|
313
346
|
rdoc_options: []
|
|
314
347
|
require_paths:
|
|
315
348
|
- lib
|
|
@@ -317,15 +350,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
317
350
|
requirements:
|
|
318
351
|
- - ">="
|
|
319
352
|
- !ruby/object:Gem::Version
|
|
320
|
-
version: '3.
|
|
353
|
+
version: '3.4'
|
|
321
354
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
322
355
|
requirements:
|
|
323
356
|
- - ">="
|
|
324
357
|
- !ruby/object:Gem::Version
|
|
325
358
|
version: '0'
|
|
326
359
|
requirements: []
|
|
327
|
-
rubygems_version:
|
|
328
|
-
signing_key:
|
|
360
|
+
rubygems_version: 4.0.20
|
|
329
361
|
specification_version: 4
|
|
330
362
|
summary: So meta
|
|
331
363
|
test_files: []
|