https://github.com/replicatedhq/kots-lint
Lint a KOTS application before deploying it
https://github.com/replicatedhq/kots-lint
best-practices kots kubeval lint
Last synced: 4 months ago
JSON representation
Lint a KOTS application before deploying it
- Host: GitHub
- URL: https://github.com/replicatedhq/kots-lint
- Owner: replicatedhq
- License: apache-2.0
- Created: 2020-03-25T18:49:25.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-11-01T18:46:25.000Z (about 1 year ago)
- Last Synced: 2024-11-01T19:22:21.532Z (about 1 year ago)
- Topics: best-practices, kots, kubeval, lint
- Language: Go
- Homepage: https://kots.io
- Size: 4.77 MB
- Stars: 6
- Watchers: 17
- Forks: 3
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## kots-lint is a service used for linting Replicated [KOTS](https://kots.io) yaml files.
### Linting with this service includes:
- Detecting YAML syntax errors
- Validating with [Kubeval](https://github.com/instrumenta/kubeval)
- Utilizing [OPA](https://github.com/open-policy-agent/opa) to lint for best practices and some special errors and warnings
## Using the production API
```shell
$ tar cvf - path/to/folder | curl -XPOST --data-binary @- https://lint.replicated.com/v1/lint
```
To lint our example
```shell
$ tar cvf - example/files-to-lint | curl -XPOST --data-binary @- https://lint.replicated.com/v1/lint
```
## Development
Development for the applications in this project is done through [Okteto](https://replicated.okteto.dev).
### Debugging Rego files
Rego supports the use of `print()` function. To enable printing to stderr, add `EnablePrintStatements` and `PrintHook` to initialization code. For example:
```
buildersQuery, err := rego.New(
rego.Query("data.kots.spec.builders.lint"),
rego.Module("builders-opa.rego", string(buildersRegoContent)),
// The lines below allow using print() in the rego code to print to stderr
rego.EnablePrintStatements(true),
rego.PrintHook(topdown.NewPrintHook(os.Stderr)),
).PrepareForEval(ctx)
```
## Setup
1. Install the Okteto CLI (`brew install okteto`)
2. Setup Okteto CLI (`okteto context create https://replicated.okteto.dev`)
3. Setup Okteto context in kubectl (`okteto context update-kubeconfig`)
4. Deploy your current branch. (from the Vandoor root directory: `okteto pipeline deploy`)
The project can also be run with Skaffold for local development and testing.
```shell
$ skaffold dev
```
Once skaffold runs successfully, the service can be reached at http://localhost:30082/v1/lint
## Run tests
Tests can be run manually with
```shell
$ make test
```
## Updating specs
The `make schemas` command can be used to automatically update all Replicated schemas:
```shell
$ make schemas
```
This will update schemas for:
- KOTS (github.com/replicatedhq/kotskinds)
- Troubleshoot (github.com/replicatedhq/troubleshoot)
- Embedded Cluster (github.com/replicatedhq/embedded-cluster)
## Updating Kubernetes specs
```shell
make schemas-kubernetes
```
This will update the schemas for the Kubernetes VERSION specified in the Makefile.