Categorygithub.com/gibizer/operator-lint
modulepackage
0.5.0
Repository: https://github.com/gibizer/operator-lint.git
Documentation: pkg.go.dev

# 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

CheckCategoryAdded inDescription
T001EnvTestv0.1.0checks that Gomega's Eventually and Consistently blocks use a local Gomega instance for asserts
------------
C001CRDv0.1.0detects incompatible Required and Optional kubebuilder markers
C002CRDv0.1.0detects incompatible Required kubebuilder marker and omitemty golang tag
C003CRDv0.2.2detects 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.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author