operator-lint

command module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

pre-commit.ci status

operator-lint

Static analysis library for k8s operators created by operator-sdk

Usage

  go install github.com/gibizer/operator-lint/
  go vet -vettool=$(which operator-lint)

Checks

Check Category Added in Description
T001 EnvTest v0.1.0 checks that Gomega's Eventually and Consistently blocks use a local Gomega instance for asserts
--- --- --- ---
C001 CRD v0.1.0 detects incompatible Required and Optional kubebuilder markers
C002 CRD v0.1.0 detects incompatible Required kubebuilder marker and omitemty golang tag
C003 CRD v0.2.2 detects incompatible defaulting via Optional kubebuilder marker and omitemty golang tag
Flags

Command line flags can be used to configure each check in the form of:

go vet -vettool=$(which operator-lint) -<check name>.<flag>

Common flags supported by each check:

  • <check name>.skip: can be used to disable the given check. E.g. the following command will not execute the check C003:
    go vet -vettool=$(which operator-lint) -C003.skip
    

You can use go vet -vettool=$(which operator-lint) -flags to print out all the supported flags

Adding a new check

  • Use make new-lint to generate a new empty linter under linters.
  • Update the README.md with the description of the check
  • If the test data for the check has dependencies then
    • Those dependencies needs to be imported in force_test_deps.go
    • The vendor directory needs to be symlinked to the directory holding the test data
    • Need to run
      go get <dep>
      go mod tidy
      go mod vendor
      

This whole dance is needed as the analysistest package does not support Go Modules currently.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
lint-template
linters
pkg

Jump to

Keyboard shortcuts

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