1
0
Fork 0

docs: expand examples

This commit is contained in:
ssube 2019-06-15 21:08:21 -05:00
parent 53018cfc01
commit ce75930a3c
1 changed files with 73 additions and 20 deletions

View File

@ -1,13 +1,21 @@
# SALTY DOG # SALTY DOG
JSON **s**chema **a**nalysis, **l**inting, and **t**ransformation for **Y**AML, featuring **d**efaults, **o**ptional YAML linter/validator.
fields, and other **g**ood stuff.
Or, as an acronym, JSON **s**chema **a**nalysis, **l**inting, and **t**ransformation for **Y**AML, featuring
**d**efaults, **o**ptional fields, and other **g**ood stuff.
- [SALTY DOG](#salty-dog) - [SALTY DOG](#salty-dog)
- [Build](#build) - [Build](#build)
- [Usage](#usage) - [Usage](#usage)
- [Validate](#validate)
- [Validate File](#validate-file)
- [Validate URL](#validate-url)
- [Validate Rules](#validate-rules)
- [Options](#options) - [Options](#options)
- [Count](#count) - [Count](#count)
- [Dest](#dest)
- [Format](#format)
- [Exclude](#exclude) - [Exclude](#exclude)
- [Exclude Level](#exclude-level) - [Exclude Level](#exclude-level)
- [Exclude Name](#exclude-name) - [Exclude Name](#exclude-name)
@ -22,6 +30,8 @@ fields, and other **g**ood stuff.
## Build ## Build
This project is written in Typescript and requires Node to be built.
```shell ```shell
> git clone git@github.com:ssube/salty-dog.git > git clone git@github.com:ssube/salty-dog.git
> make > make
@ -29,36 +39,60 @@ fields, and other **g**ood stuff.
## Usage ## Usage
To validate the rules in the `rules/` directory: ### Validate
```shell `salty-dog` can validate JSON and YAML from files and streams, and emit it to a file or stream (with logs going
> make run-rules elsewhere).
...
{"name":"salty-dog","hostname":"cerberus","pid":29403,"level":30,"msg":"all rules passed","time":"2019-06-16T00:56:55.132Z","v":0} #### Validate File
```
To validate a file: To validate a file:
```shell ```shell
> cat rules/examples/kubernetes-require-resources-fail.yml |\ > salty-dog \
salty-dog \ --rules rules/kubernetes.yml \
--rules rules/kubernetes.yml \ --source rules/examples/kubernetes-require-resources-fail.yml \
--source - \ --tag important
--tag important |\
./node_modules/.bin/bunyan
...
[2019-06-15T23:56:04.764Z] ERROR: salty-dog/22211 on cerberus: some rules failed (errors=1) [2019-06-15T23:56:04.764Z] ERROR: salty-dog/22211 on cerberus: some rules failed (errors=1)
> cat rules/examples/kubernetes-require-resources-pass.yml |\ > cat rules/examples/kubernetes-require-resources-pass.yml | salty-dog \
salty-dog \ --rules rules/kubernetes.yml \
--rules rules/kubernetes.yml \ --source - \
--source - \ --tag important
--tag important |\
./node_modules/.bin/bunyan
...
[2019-06-15T23:53:34.223Z] INFO: salty-dog/19839 on cerberus: all rules passed [2019-06-15T23:53:34.223Z] INFO: salty-dog/19839 on cerberus: all rules passed
``` ```
#### Validate URL
To validate a URL:
```shell
> curl https://raw.githubusercontent.com/ssube/k8s-shards/master/roles/apps/gitlab/server/templates/ingress.yml | salty-dog \
--rules rules/kubernetes.yml \
--source - \
--tag important | kubectl apply --dry-run -f -
...
{"name":"salty-dog","hostname":"cerberus","pid":7860,"level":30,"msg":"all rules passed","time":"2019-06-16T02:04:37.797Z","v":0}
ingress.extensions/gitlab created (dry run)
...
```
#### Validate Rules
To validate the rules in the `rules/` directory using the meta-rules:
```shell
> make run-rules
...
{"name":"salty-dog","hostname":"cerberus","pid":29403,"level":30,"msg":"all rules passed","time":"2019-06-16T00:56:55.132Z","v":0}
```
### Options ### Options
#### Count #### Count
@ -67,6 +101,25 @@ To validate a file:
Exit with the error count (max of 255) rather than `0` or `1`. Exit with the error count (max of 255) rather than `0` or `1`.
#### Dest
- Alias: `d`
- Default: `-`
Path to write output data.
Defaults to stdout (`-`).
#### Format
- Default: `yaml`
Output format.
Options:
- `yaml`
#### Exclude #### Exclude
Excludes take priority over includes: a rule matching some of both will be excluded. Excludes take priority over includes: a rule matching some of both will be excluded.