Skip to content

Commit

Permalink
Support passing options to Helm template and Kubeval
Browse files Browse the repository at this point in the history
  • Loading branch information
garethr committed Aug 11, 2019
1 parent fa4e0b1 commit 7476464
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```


39 changes: 33 additions & 6 deletions scripts/run.sh
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[@]}"

0 comments on commit 7476464

Please sign in to comment.