kots-lint

command module
v0.3.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

kots-lint is a service used for linting Replicated KOTS yaml files.

Linting with this service includes:

  • Detecting YAML syntax errors
  • Validating with Kubeval
  • Utilizing OPA to lint for best practices and some special errors and warnings

Using the production API

$ tar cvf - path/to/folder | curl -XPOST --data-binary @- https://lint.replicated.com/v1/lint

To lint our example

$ 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.

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.

$ 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

$ make test

Updating specs

Generated specs can be copied from the source project directly. File names should match, but since projects will change independently, care should be taken when copying.

Troubleshoot

cp <troubleshoot root>/schemas/*.json <kots-lint root>/kubernetes_json_schema/schema/v1.23.6-standalone-strict/

KOTS

cp <kots root>/kotskinds/schemas/*.json <kots-lint root>/kubernetes_json_schema/schema/v1.23.6-standalone-strict/

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL