-
-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(common): add traefik middlewares (#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._
- Loading branch information
Showing
86 changed files
with
7,205 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
charts/library/common-test/tests/traefik/metadata_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
suite: middlewares metadata test | ||
templates: | ||
- common.yaml | ||
chart: | ||
appVersion: &appVer v9.9.9 | ||
release: | ||
name: test-release-name | ||
namespace: test-release-namespace | ||
tests: | ||
- it: should pass with middlewares created with labels and annotations | ||
set: | ||
label1: label1 | ||
label2: global_label2 | ||
annotation1: annotation1 | ||
annotation2: global_annotation2 | ||
global: | ||
labels: | ||
g_label1: global_label1 | ||
g_label2: "{{ .Values.label2 }}" | ||
annotations: | ||
g_annotation1: global_annotation1 | ||
g_annotation2: "{{ .Values.annotation2 }}" | ||
middlewares: | ||
my-middleware1: | ||
enabled: true | ||
type: buffering | ||
labels: | ||
label1: "{{ .Values.label1 }}" | ||
label2: label2 | ||
annotations: | ||
annotation1: "{{ .Values.annotation1 }}" | ||
annotation2: annotation2 | ||
data: | ||
foo: bar | ||
asserts: | ||
- documentIndex: &middlewareDoc 0 | ||
isKind: | ||
of: Middleware | ||
- documentIndex: *middlewareDoc | ||
equal: | ||
path: metadata.annotations | ||
value: | ||
annotation1: annotation1 | ||
annotation2: annotation2 | ||
g_annotation1: global_annotation1 | ||
g_annotation2: global_annotation2 | ||
- documentIndex: *middlewareDoc | ||
equal: | ||
path: metadata.labels | ||
value: | ||
app: common-test-1.0.0 | ||
release: test-release-name | ||
helm-revision: "0" | ||
helm.sh/chart: common-test-1.0.0 | ||
app.kubernetes.io/name: common-test | ||
app.kubernetes.io/instance: test-release-name | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/version: *appVer | ||
g_label1: global_label1 | ||
g_label2: global_label2 | ||
label1: label1 | ||
label2: label2 | ||
- documentIndex: *middlewareDoc | ||
equal: | ||
path: metadata.namespace | ||
value: test-release-namespace | ||
|
||
- it: should pass with middlewares created with namespace | ||
set: | ||
middlewares: | ||
my-middleware1: | ||
enabled: true | ||
type: buffering | ||
namespace: some-namespace | ||
data: | ||
foo: bar | ||
asserts: | ||
- documentIndex: *middlewareDoc | ||
equal: | ||
path: metadata.namespace | ||
value: some-namespace | ||
|
||
- it: should pass with middlewares created with object namespace from tpl | ||
set: | ||
key: some-namespace | ||
middlewares: | ||
my-middleware1: | ||
enabled: true | ||
type: buffering | ||
namespace: "{{ .Values.key }}" | ||
data: | ||
foo: bar | ||
asserts: | ||
- documentIndex: *middlewareDoc | ||
equal: | ||
path: metadata.namespace | ||
value: some-namespace | ||
|
||
- it: should pass with middlewares created with namespace from global with tpl | ||
set: | ||
key: global-namespace | ||
global: | ||
namespace: "{{ .Values.key }}" | ||
middlewares: | ||
my-middleware1: | ||
enabled: true | ||
type: buffering | ||
data: | ||
foo: bar | ||
asserts: | ||
- documentIndex: *middlewareDoc | ||
equal: | ||
path: metadata.namespace | ||
value: global-namespace | ||
|
||
- it: should pass with middlewares created with namespace from root with tpl | ||
set: | ||
key: local-namespace | ||
namespace: "{{ .Values.key }}" | ||
global: | ||
namespace: global-namespace | ||
middlewares: | ||
my-middleware1: | ||
enabled: true | ||
type: buffering | ||
data: | ||
foo: bar | ||
asserts: | ||
- documentIndex: *middlewareDoc | ||
equal: | ||
path: metadata.namespace | ||
value: local-namespace |
37 changes: 37 additions & 0 deletions
37
charts/library/common-test/tests/traefik/middleware_addPrefix_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
suite: add-prefix middleware test | ||
templates: | ||
- common.yaml | ||
release: | ||
name: test-release-name | ||
namespace: test-release-namespace | ||
tests: | ||
- it: should pass with all set | ||
set: | ||
middlewares: | ||
my-middleware1: | ||
enabled: true | ||
type: add-prefix | ||
data: | ||
prefix: some-prefix | ||
asserts: | ||
- documentIndex: &middlewareDoc 0 | ||
isKind: | ||
of: Middleware | ||
- documentIndex: *middlewareDoc | ||
equal: | ||
path: spec | ||
value: | ||
addPrefix: | ||
prefix: some-prefix | ||
|
||
- it: should fail with missing prefix | ||
set: | ||
middlewares: | ||
my-middleware1: | ||
enabled: true | ||
type: add-prefix | ||
data: | ||
foo: bar | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: Middleware (add-prefix) - Expected [prefix] to be set |
81 changes: 81 additions & 0 deletions
81
charts/library/common-test/tests/traefik/middleware_basicAuth_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
suite: basicAuth middleware test | ||
templates: | ||
- common.yaml | ||
release: | ||
name: test-release-name | ||
namespace: test-release-namespace | ||
tests: | ||
- it: should pass with all set | ||
set: | ||
middlewares: | ||
my-middleware1: | ||
enabled: true | ||
type: basic-auth | ||
data: | ||
secret: some-secret | ||
my-middleware2: | ||
enabled: true | ||
type: basic-auth | ||
data: | ||
users: | ||
- username: some-username | ||
password: some-password | ||
- username: some-other-username | ||
password: some-other-password | ||
asserts: | ||
- documentIndex: &middlewareDoc 0 | ||
isKind: | ||
of: Middleware | ||
- documentIndex: *middlewareDoc | ||
equal: | ||
path: spec | ||
value: | ||
basicAuth: | ||
secret: some-secret | ||
- documentIndex: &otherMiddlewareDoc 1 | ||
isKind: | ||
of: Middleware | ||
- documentIndex: *otherMiddlewareDoc | ||
equal: | ||
path: spec | ||
value: | ||
basicAuth: | ||
secret: test-release-name-common-test-my-middleware2 | ||
- documentIndex: &secretDoc 2 | ||
isKind: | ||
of: Secret | ||
- documentIndex: *secretDoc | ||
equal: | ||
path: metadata.name | ||
value: test-release-name-common-test-my-middleware2 | ||
- documentIndex: *secretDoc | ||
matchRegex: | ||
path: stringData.users | ||
pattern: some-username:.+\nsome-other-username:.+ | ||
|
||
- it: should fail with missing both users and secret | ||
set: | ||
middlewares: | ||
my-middleware1: | ||
enabled: true | ||
type: basic-auth | ||
data: | ||
foo: bar | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: Middleware (basic-auth) - Expected at least one of [users] or [secret] to be set | ||
|
||
- it: should fail with both secret and users set | ||
set: | ||
middlewares: | ||
my-middleware1: | ||
enabled: true | ||
type: basic-auth | ||
data: | ||
secret: some-secret | ||
users: | ||
- username: some-username | ||
password: some-password | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: Middleware (basic-auth) - Expected either [users] or [secret] to be set, but not both |
71 changes: 71 additions & 0 deletions
71
charts/library/common-test/tests/traefik/middleware_buffering_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
suite: buffering middleware test | ||
templates: | ||
- common.yaml | ||
release: | ||
name: test-release-name | ||
namespace: test-release-namespace | ||
tests: | ||
- it: should pass with all set | ||
set: | ||
middlewares: | ||
my-middleware1: | ||
enabled: true | ||
type: buffering | ||
data: | ||
maxRequestBodyBytes: 1024 | ||
memRequestBodyBytes: 1024 | ||
maxResponseBodyBytes: 1024 | ||
memResponseBodyBytes: 1024 | ||
retryExpression: some-expression | ||
asserts: | ||
- documentIndex: &middlewareDoc 0 | ||
isKind: | ||
of: Middleware | ||
- documentIndex: *middlewareDoc | ||
equal: | ||
path: spec | ||
value: | ||
buffering: | ||
maxRequestBodyBytes: 1024 | ||
memRequestBodyBytes: 1024 | ||
maxResponseBodyBytes: 1024 | ||
memResponseBodyBytes: 1024 | ||
retryExpression: "some-expression" | ||
|
||
- it: should pass with only maxRequestBodyBytes set | ||
set: | ||
middlewares: | ||
my-middleware1: | ||
enabled: true | ||
type: buffering | ||
data: | ||
maxRequestBodyBytes: 1024 | ||
asserts: | ||
- documentIndex: *middlewareDoc | ||
equal: | ||
path: spec | ||
value: | ||
buffering: | ||
maxRequestBodyBytes: 1024 | ||
|
||
- it: should render 0 and non-null values | ||
set: | ||
middlewares: | ||
my-middleware1: | ||
enabled: true | ||
type: buffering | ||
data: | ||
maxRequestBodyBytes: 0 | ||
memRequestBodyBytes: null | ||
maxResponseBodyBytes: 1024 | ||
memResponseBodyBytes: 1024 | ||
retryExpression: "" | ||
asserts: | ||
- documentIndex: *middlewareDoc | ||
equal: | ||
path: spec | ||
value: | ||
buffering: | ||
maxRequestBodyBytes: 0 | ||
maxResponseBodyBytes: 1024 | ||
memResponseBodyBytes: 1024 |
42 changes: 42 additions & 0 deletions
42
charts/library/common-test/tests/traefik/middleware_chain_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
suite: chain middleware test | ||
templates: | ||
- common.yaml | ||
release: | ||
name: test-release-name | ||
namespace: test-release-namespace | ||
tests: | ||
- it: should pass with all set | ||
set: | ||
middlewares: | ||
my-middleware1: | ||
enabled: true | ||
type: chain | ||
data: | ||
middlewares: | ||
- name: some-name | ||
expandObjectName: false | ||
- name: some-other-name | ||
asserts: | ||
- documentIndex: &middlewareDoc 0 | ||
isKind: | ||
of: Middleware | ||
- documentIndex: *middlewareDoc | ||
equal: | ||
path: spec | ||
value: | ||
chain: | ||
middlewares: | ||
- name: some-name | ||
- name: test-release-name-common-test-some-other-name | ||
|
||
- it: should fail with missing middlewares | ||
set: | ||
middlewares: | ||
my-middleware1: | ||
enabled: true | ||
type: chain | ||
data: | ||
middlewares: [] | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: Middleware (chain) - Expected [middlewares] to be set |
Oops, something went wrong.