klint

command module
v0.0.0-...-6aac043 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

README

Klint

Klint lints Kubernetes resources, using an arbitrary ruleset.

Pre-Alpha: The development of Klint has just started and is far from finished. It probably does not work.

It does not ship with rules itself (yet), however these are very easy to write, in Golang:

// filename: rule.klint
package main

import (
    "github.com/grafana/tanka/pkg/kubernetes/manifest"
    "github.com/sh0rez/klint/pkg/klint"
)

func lint(m manifest.Manifest) (klint.Findings, error) {
    if m.Metadata().Namespace() == "" {
        f := klint.Finding{
            Level:   klint.Warning,
            Field:   "metadata.namespace",
            Message: "Namespace is required for all resources",
        }

        return klint.Found(f), nil
    }

    return nil, nil
}

The key part here is the lint function, which must follow exactly above function signature. It receives a single Kubernetes manifest (map[string]interface{} in a helper type) and may return any number of findings on that resource.

Rules are dynamically loaded at runtime, and produce such a result:

$ klint deployment.yaml

Deployment/nginx-deployment:
 WARN – rule.klint – metadata.namespace: Namespace is required for all resources

Example

For an example, check the example directory.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
example
rules/no-latest command
pkg

Jump to

Keyboard shortcuts

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