Skip to content

Commit

Permalink
fix: fail gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweaver87 committed Nov 23, 2023
1 parent bad3af6 commit 56c2b14
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions traefik/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,13 @@
{{- end }}
{{- end }}
{{- end }}
{{- if ne (typeOf .Values.experimental.plugins) "map[string]interface {}" }}
{{- fail (printf "ERROR: .Values.experimental.plugins should be a map (%s provided) !" (typeOf .Values.experimental.plugins)) }}
{{- end }}
{{- range $pluginName, $plugin := .Values.experimental.plugins }}
{{- if or (ne (typeOf $plugin) "map[string]interface {}") (not (hasKey $plugin "moduleName")) (not (hasKey $plugin "version")) }}
{{- fail (printf "ERROR: plugin %s is missing moduleName/version keys !" $pluginName) }}
{{- end }}
- --experimental.plugins.{{ $pluginName }}.moduleName={{ $plugin.moduleName }}
- --experimental.plugins.{{ $pluginName }}.version={{ $plugin.version }}
{{- end }}
Expand Down
19 changes: 19 additions & 0 deletions traefik/tests/traefik-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,25 @@ tests:
path: spec.template.spec.containers[0].args
content: "--experimental.plugins.demo.version=v0.2.1"

- it: should fail gracefully when using old syntax
set:
experimental:
plugins:
enabled: true
asserts:
- failedTemplate:
errorMessage: "ERROR: plugin enabled is missing moduleName/version keys !"

- it: should fail gracefully on missing plugins information
set:
experimental:
plugins:
demo:
moduleName: github.com/traefik/plugindemo
asserts:
- failedTemplate:
errorMessage: "ERROR: plugin demo is missing moduleName/version keys !"

- it: should have tls configuration args when specified in values.yaml for port
set:
ports:
Expand Down

0 comments on commit 56c2b14

Please sign in to comment.