forked from instrumenta/helm-kubeval
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support passing options to Helm template and Kubeval
- Loading branch information
Showing
2 changed files
with
43 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,7 @@ As an example of usage, here is `helm kubeval` running against one of the stable | |
|
||
```console | ||
$ git clone [email protected]:helm/charts.git | ||
$ cd charts/stable/nginx-ingress | ||
$ helm kubeval | ||
$ helm kubeval charts/stable/nginx-ingress | ||
The file nginx-ingress/templates/serviceaccount.yaml contains a valid ServiceAccount | ||
The file nginx-ingress/templates/clusterrole.yaml contains a valid ClusterRole | ||
The file nginx-ingress/templates/clusterrolebinding.yaml contains a valid ClusterRoleBinding | ||
|
@@ -46,8 +45,16 @@ The file nginx-ingress/templates/udp-configmap.yaml contains an empty YAML docum | |
You can also specify a specific Kubernetes version to validate the chart against. | ||
|
||
``` | ||
helm kubeval -v 1.9.0 | ||
helm kubeval . -v 1.9.0 | ||
``` | ||
|
||
Kubeval has a number of flags which can alter it's behaviour, from ignoring specific resources to | ||
exiting on the first error to disallowing properties not specified in the schema. Kubeval options | ||
automatically passed to Kubeval, with any other options being passed to Helm in the same way as | ||
`helm template`. This means you could set values before validating the chart. eg. | ||
|
||
``` | ||
helm kubeval charts/stable/nginx-ingress --set controller.image.tag=latest | ||
``` | ||
|
||
|
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 |
---|---|---|
@@ -1,10 +1,37 @@ | ||
#! /bin/bash -e | ||
|
||
if [[ $1 == "--version" || $1 == "--help" ]]; then | ||
$HELM_PLUGIN_DIR/bin/kubeval $1 | ||
exit | ||
fi | ||
helm_options=() | ||
kubeval_options=() | ||
eoo=0 | ||
|
||
render=$(helm template .) | ||
while [[ $1 ]] | ||
do | ||
if ! ((eoo)); then | ||
case "$1" in | ||
--version|--help) | ||
$HELM_PLUGIN_DIR/bin/kubeval $1 | ||
exit | ||
;; | ||
--strict|--exit-on-error|--openshift|--force-color|--ignore-missing-schemas) | ||
kubeval_options+=("$1") | ||
shift | ||
;; | ||
--output|-o|--kubernetes-version|-v|--schema-location|-s|--skip-kinds) | ||
kubeval_options+=("$1") | ||
kubeval_options+=("$2") | ||
shift 2 | ||
;; | ||
*) | ||
helm_options+=("$1") | ||
shift | ||
;; | ||
esac | ||
else | ||
helm_options+=("$1") | ||
shift | ||
fi | ||
done | ||
|
||
echo "$render" | $HELM_PLUGIN_DIR/bin/kubeval ${@} | ||
render=$(helm template "${helm_options[@]}") | ||
|
||
echo "$render" | $HELM_PLUGIN_DIR/bin/kubeval "${kubeval_options[@]}" |