Skip to content

Commit

Permalink
docs: add bin/renderlocal to README w/examples
Browse files Browse the repository at this point in the history
- examples should be copy/paste-able from the root of the repo
- included:
  - single and multiple `--env` arguments
  - with and without `--out` option
  • Loading branch information
charlesthomas committed Jun 28, 2022
1 parent 6ad352a commit ae02d79
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 1 deletion.
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -608,3 +608,60 @@ before enabling impersonation, any user on the cluster that is allowed to create
razeedeploy resources will be able to impersonate any other user. Once the ImpersonationWebhook
controller is installed and all necessary config and authorizations in place, impersonation
can be safely enabled in the `razeedeploy-config` configmap.

## Local Testing with `bin/renderlocal`

`bin/renderlocal` can be used to see what the resources generated by a
MustacheTemplate would look like.

`bin/renderlocal` arguments:

- `--mtp` a path to the template you want to render.
- `--env` a path to a file containing `ConfigMaps`, `Secrets`, or other
resources used to render the template. Any number of `--env` files can be
added; at least one is required.
- `--out` if provided, the path to write the resulting rendered resources
[OPTIONAL]

### Example

```shell
bin/renderlocal --mtp test/example/hello-mtp.yaml --env test/example/hello-cm.yaml
{..."failed to get env: {\"name\":\"greeting\",... # expected warning
kind: ConfigMap
apiVersion: v1
metadata:
name: result
namespace: default
data:
result: hello, Razee!
```

```shell
bin/renderlocal --mtp test/example/hello-mtp.yaml \
--env test/example/hello-cm.yaml --env test/example/alternate-greeting-cm.yaml
kind: ConfigMap
apiVersion: v1
metadata:
name: result
namespace: default
data:
result: howdy, Razee!
```

```shell
bin/renderlocal --mtp test/example/hello-mtp.yaml \
--env test/example/hello-cm.yaml --env test/example/alternate-greeting-cm.yaml \
--out /tmp/output.yaml \
&& cat /tmp/output.yaml
kind: ConfigMap
apiVersion: v1
metadata:
name: result
namespace: default
data:
result: howdy, Razee!
```
26 changes: 25 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions test/example/alternate-greeting-cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
kind: ConfigMap
apiVersion: v1
metadata:
name: alternate-greeting-cm
namespace: default
data:
greeting: howdy
8 changes: 8 additions & 0 deletions test/example/hello-cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
kind: ConfigMap
apiVersion: v1
metadata:
name: hello-cm
namespace: default
data:
name: Razee
28 changes: 28 additions & 0 deletions test/example/hello-mtp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
kind: MustacheTemplate
apiVersion: "deploy.razee.io/v1alpha2"
metadata:
name: hello-mtp
namespace: default
spec:
env:
- name: name
valueFrom:
configMapKeyRef:
name: hello-cm
key: name
- name: greeting
valueFrom:
configMapKeyRef:
name: alternate-greeting-cm
key: greeting
optional: true
default: "hello"
templates:
- kind: ConfigMap
apiVersion: v1
metadata:
name: result
namespace: default
data:
result: "{{greeting}}, {{name}}!"

0 comments on commit ae02d79

Please sign in to comment.