Skip to content

Commit 1880d49

Browse files
authored
feat(common): add traefik middlewares (truecharts#30529)
**Description** <!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. --> ⚒️ Fixes # <!--(issue)--> **⚙️ Type of change** - [x] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** <!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration --> **📃 Notes:** <!-- Please enter any other relevant information here --> **✔️ Checklist:** - [x] ⚖️ My code follows the style guidelines of this project - [x] 👀 I have performed a self-review of my own code - [x] #️⃣ I have commented my code, particularly in hard-to-understand areas - [x] 📄 I have made corresponding changes to the documentation - [x] ⚠️ My changes generate no new warnings - [x] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [x] ⬆️ I increased versions for any altered app according to semantic versioning - [x] I made sure the title starts with `feat(chart-name):`, `fix(chart-name):` or `chore(chart-name):` **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._
1 parent 02752b7 commit 1880d49

File tree

86 files changed

+7205
-115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+7205
-115
lines changed

.github/workflows/common-tests.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ on:
2020
workflow_dispatch:
2121

2222
jobs:
23-
2423
check_changes:
2524
runs-on: ubuntu-latest
2625
outputs:
@@ -81,7 +80,7 @@ jobs:
8180
name: Unit Tests
8281
runs-on: ubuntu-24.04
8382
env:
84-
helmUnitVersion: 0.5.0
83+
helmUnitVersion: 0.7.1
8584
strategy:
8685
fail-fast: false
8786
matrix:

charts/library/common-test/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ apiVersion: v2
77
appVersion: unknown
88
dependencies:
99
- name: common
10-
version: ~25.3.0
10+
version: ~25.4.0
1111
repository: file://../common/
1212
condition: ""
1313
alias: ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
suite: middlewares metadata test
2+
templates:
3+
- common.yaml
4+
chart:
5+
appVersion: &appVer v9.9.9
6+
release:
7+
name: test-release-name
8+
namespace: test-release-namespace
9+
tests:
10+
- it: should pass with middlewares created with labels and annotations
11+
set:
12+
label1: label1
13+
label2: global_label2
14+
annotation1: annotation1
15+
annotation2: global_annotation2
16+
global:
17+
labels:
18+
g_label1: global_label1
19+
g_label2: "{{ .Values.label2 }}"
20+
annotations:
21+
g_annotation1: global_annotation1
22+
g_annotation2: "{{ .Values.annotation2 }}"
23+
middlewares:
24+
my-middleware1:
25+
enabled: true
26+
type: buffering
27+
labels:
28+
label1: "{{ .Values.label1 }}"
29+
label2: label2
30+
annotations:
31+
annotation1: "{{ .Values.annotation1 }}"
32+
annotation2: annotation2
33+
data:
34+
foo: bar
35+
asserts:
36+
- documentIndex: &middlewareDoc 0
37+
isKind:
38+
of: Middleware
39+
- documentIndex: *middlewareDoc
40+
equal:
41+
path: metadata.annotations
42+
value:
43+
annotation1: annotation1
44+
annotation2: annotation2
45+
g_annotation1: global_annotation1
46+
g_annotation2: global_annotation2
47+
- documentIndex: *middlewareDoc
48+
equal:
49+
path: metadata.labels
50+
value:
51+
app: common-test-1.0.0
52+
release: test-release-name
53+
helm-revision: "0"
54+
helm.sh/chart: common-test-1.0.0
55+
app.kubernetes.io/name: common-test
56+
app.kubernetes.io/instance: test-release-name
57+
app.kubernetes.io/managed-by: Helm
58+
app.kubernetes.io/version: *appVer
59+
g_label1: global_label1
60+
g_label2: global_label2
61+
label1: label1
62+
label2: label2
63+
- documentIndex: *middlewareDoc
64+
equal:
65+
path: metadata.namespace
66+
value: test-release-namespace
67+
68+
- it: should pass with middlewares created with namespace
69+
set:
70+
middlewares:
71+
my-middleware1:
72+
enabled: true
73+
type: buffering
74+
namespace: some-namespace
75+
data:
76+
foo: bar
77+
asserts:
78+
- documentIndex: *middlewareDoc
79+
equal:
80+
path: metadata.namespace
81+
value: some-namespace
82+
83+
- it: should pass with middlewares created with object namespace from tpl
84+
set:
85+
key: some-namespace
86+
middlewares:
87+
my-middleware1:
88+
enabled: true
89+
type: buffering
90+
namespace: "{{ .Values.key }}"
91+
data:
92+
foo: bar
93+
asserts:
94+
- documentIndex: *middlewareDoc
95+
equal:
96+
path: metadata.namespace
97+
value: some-namespace
98+
99+
- it: should pass with middlewares created with namespace from global with tpl
100+
set:
101+
key: global-namespace
102+
global:
103+
namespace: "{{ .Values.key }}"
104+
middlewares:
105+
my-middleware1:
106+
enabled: true
107+
type: buffering
108+
data:
109+
foo: bar
110+
asserts:
111+
- documentIndex: *middlewareDoc
112+
equal:
113+
path: metadata.namespace
114+
value: global-namespace
115+
116+
- it: should pass with middlewares created with namespace from root with tpl
117+
set:
118+
key: local-namespace
119+
namespace: "{{ .Values.key }}"
120+
global:
121+
namespace: global-namespace
122+
middlewares:
123+
my-middleware1:
124+
enabled: true
125+
type: buffering
126+
data:
127+
foo: bar
128+
asserts:
129+
- documentIndex: *middlewareDoc
130+
equal:
131+
path: metadata.namespace
132+
value: local-namespace
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
suite: add-prefix middleware test
2+
templates:
3+
- common.yaml
4+
release:
5+
name: test-release-name
6+
namespace: test-release-namespace
7+
tests:
8+
- it: should pass with all set
9+
set:
10+
middlewares:
11+
my-middleware1:
12+
enabled: true
13+
type: add-prefix
14+
data:
15+
prefix: some-prefix
16+
asserts:
17+
- documentIndex: &middlewareDoc 0
18+
isKind:
19+
of: Middleware
20+
- documentIndex: *middlewareDoc
21+
equal:
22+
path: spec
23+
value:
24+
addPrefix:
25+
prefix: some-prefix
26+
27+
- it: should fail with missing prefix
28+
set:
29+
middlewares:
30+
my-middleware1:
31+
enabled: true
32+
type: add-prefix
33+
data:
34+
foo: bar
35+
asserts:
36+
- failedTemplate:
37+
errorMessage: Middleware (add-prefix) - Expected [prefix] to be set
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
suite: basicAuth middleware test
2+
templates:
3+
- common.yaml
4+
release:
5+
name: test-release-name
6+
namespace: test-release-namespace
7+
tests:
8+
- it: should pass with all set
9+
set:
10+
middlewares:
11+
my-middleware1:
12+
enabled: true
13+
type: basic-auth
14+
data:
15+
secret: some-secret
16+
my-middleware2:
17+
enabled: true
18+
type: basic-auth
19+
data:
20+
users:
21+
- username: some-username
22+
password: some-password
23+
- username: some-other-username
24+
password: some-other-password
25+
asserts:
26+
- documentIndex: &middlewareDoc 0
27+
isKind:
28+
of: Middleware
29+
- documentIndex: *middlewareDoc
30+
equal:
31+
path: spec
32+
value:
33+
basicAuth:
34+
secret: some-secret
35+
- documentIndex: &otherMiddlewareDoc 1
36+
isKind:
37+
of: Middleware
38+
- documentIndex: *otherMiddlewareDoc
39+
equal:
40+
path: spec
41+
value:
42+
basicAuth:
43+
secret: test-release-name-common-test-my-middleware2
44+
- documentIndex: &secretDoc 2
45+
isKind:
46+
of: Secret
47+
- documentIndex: *secretDoc
48+
equal:
49+
path: metadata.name
50+
value: test-release-name-common-test-my-middleware2
51+
- documentIndex: *secretDoc
52+
matchRegex:
53+
path: stringData.users
54+
pattern: some-username:.+\nsome-other-username:.+
55+
56+
- it: should fail with missing both users and secret
57+
set:
58+
middlewares:
59+
my-middleware1:
60+
enabled: true
61+
type: basic-auth
62+
data:
63+
foo: bar
64+
asserts:
65+
- failedTemplate:
66+
errorMessage: Middleware (basic-auth) - Expected at least one of [users] or [secret] to be set
67+
68+
- it: should fail with both secret and users set
69+
set:
70+
middlewares:
71+
my-middleware1:
72+
enabled: true
73+
type: basic-auth
74+
data:
75+
secret: some-secret
76+
users:
77+
- username: some-username
78+
password: some-password
79+
asserts:
80+
- failedTemplate:
81+
errorMessage: Middleware (basic-auth) - Expected either [users] or [secret] to be set, but not both
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
suite: buffering middleware test
2+
templates:
3+
- common.yaml
4+
release:
5+
name: test-release-name
6+
namespace: test-release-namespace
7+
tests:
8+
- it: should pass with all set
9+
set:
10+
middlewares:
11+
my-middleware1:
12+
enabled: true
13+
type: buffering
14+
data:
15+
maxRequestBodyBytes: 1024
16+
memRequestBodyBytes: 1024
17+
maxResponseBodyBytes: 1024
18+
memResponseBodyBytes: 1024
19+
retryExpression: some-expression
20+
asserts:
21+
- documentIndex: &middlewareDoc 0
22+
isKind:
23+
of: Middleware
24+
- documentIndex: *middlewareDoc
25+
equal:
26+
path: spec
27+
value:
28+
buffering:
29+
maxRequestBodyBytes: 1024
30+
memRequestBodyBytes: 1024
31+
maxResponseBodyBytes: 1024
32+
memResponseBodyBytes: 1024
33+
retryExpression: "some-expression"
34+
35+
- it: should pass with only maxRequestBodyBytes set
36+
set:
37+
middlewares:
38+
my-middleware1:
39+
enabled: true
40+
type: buffering
41+
data:
42+
maxRequestBodyBytes: 1024
43+
asserts:
44+
- documentIndex: *middlewareDoc
45+
equal:
46+
path: spec
47+
value:
48+
buffering:
49+
maxRequestBodyBytes: 1024
50+
51+
- it: should render 0 and non-null values
52+
set:
53+
middlewares:
54+
my-middleware1:
55+
enabled: true
56+
type: buffering
57+
data:
58+
maxRequestBodyBytes: 0
59+
memRequestBodyBytes: null
60+
maxResponseBodyBytes: 1024
61+
memResponseBodyBytes: 1024
62+
retryExpression: ""
63+
asserts:
64+
- documentIndex: *middlewareDoc
65+
equal:
66+
path: spec
67+
value:
68+
buffering:
69+
maxRequestBodyBytes: 0
70+
maxResponseBodyBytes: 1024
71+
memResponseBodyBytes: 1024
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
suite: chain middleware test
2+
templates:
3+
- common.yaml
4+
release:
5+
name: test-release-name
6+
namespace: test-release-namespace
7+
tests:
8+
- it: should pass with all set
9+
set:
10+
middlewares:
11+
my-middleware1:
12+
enabled: true
13+
type: chain
14+
data:
15+
middlewares:
16+
- name: some-name
17+
expandObjectName: false
18+
- name: some-other-name
19+
asserts:
20+
- documentIndex: &middlewareDoc 0
21+
isKind:
22+
of: Middleware
23+
- documentIndex: *middlewareDoc
24+
equal:
25+
path: spec
26+
value:
27+
chain:
28+
middlewares:
29+
- name: some-name
30+
- name: test-release-name-common-test-some-other-name
31+
32+
- it: should fail with missing middlewares
33+
set:
34+
middlewares:
35+
my-middleware1:
36+
enabled: true
37+
type: chain
38+
data:
39+
middlewares: []
40+
asserts:
41+
- failedTemplate:
42+
errorMessage: Middleware (chain) - Expected [middlewares] to be set

0 commit comments

Comments
 (0)