Documentation ¶
Overview ¶
KAL is a linter for Kubernetes API types, that implements API conventions and best practices.
This package provides a GolangCI-Lint plugin that can be used to build a custom linter for Kubernetes API types. The custom golangci-lint binary can be built by checking out the KAL repository and running `make build-golangci`. This will generate a custom golangci-lint binary in the `bin` directory.
The custom golangci-lint binary can be run with the `run` command, and the KAL linters can be enabled by setting the `kal` linter in the `.golangci.yml` configuration file.
Example `.golangci.yml` configuration file:
linters-settings: custom: kal: type: "module" description: KAL is the Kube-API-Linter and lints Kube like APIs based on API conventions and best practices. settings: linters: enabled: [] disabled: [] lintersConfig: jsonTags: jsonTagRegex: "" optionalOrRequired: preferredOptionalMarker: "" preferredRequiredMarker: "" linters: disable-all: true enable: - kal
New linters can be added in the github.com/JoelSpeed/kal/pkg/analysis package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GolangCIPlugin ¶
type GolangCIPlugin struct {
// contains filtered or unexported fields
}
GolangCIPlugin constructs a new plugin for the golangci-lint plugin pattern. This allows golangci-lint to build a version of itself, containing all of the anaylzers included in KAL.
func (*GolangCIPlugin) BuildAnalyzers ¶
func (f *GolangCIPlugin) BuildAnalyzers() ([]*analysis.Analyzer, error)
BuildAnalyzers returns all of the analyzers to run, based on the configuration.
func (*GolangCIPlugin) GetLoadMode ¶
func (f *GolangCIPlugin) GetLoadMode() string
GetLoadMode implements the golangci-lint plugin interface.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
pkg
|
|
analysis
analysis providers a linter registry and a set of linters that can be used to analyze Go code.
|
analysis providers a linter registry and a set of linters that can be used to analyze Go code. |
analysis/commentstart
commentstart is a simple analysis tool that checks if the first line of a comment is the same as the json tag.
|
commentstart is a simple analysis tool that checks if the first line of a comment is the same as the json tag. |
analysis/conditions
conditions is a linter that verifies that the conditions field within the struct is correctly defined.
|
conditions is a linter that verifies that the conditions field within the struct is correctly defined. |
analysis/helpers
helpers contains utility functions that are used by the analysis package.
|
helpers contains utility functions that are used by the analysis package. |
analysis/helpers/extractjsontags
extractjsontags is a helper package that extracts JSON tags from a struct field.
|
extractjsontags is a helper package that extracts JSON tags from a struct field. |
analysis/helpers/markers
markers is a helper used to extract marker information from types.
|
markers is a helper used to extract marker information from types. |
analysis/integers
integers is an analyzer that checks for usage of unsupported integer types.
|
integers is an analyzer that checks for usage of unsupported integer types. |
analysis/jsontags
jsontags provides a linter to ensure that JSON tags are present on struct fields, and that they match a given regex.
|
jsontags provides a linter to ensure that JSON tags are present on struct fields, and that they match a given regex. |
analysis/nobools
nobools is an analyzer that checks for usage of bool types.
|
nobools is an analyzer that checks for usage of bool types. |
analysis/optionalorrequired
optionalorrequired is a linter to ensure that all fields are marked as either optional or required.
|
optionalorrequired is a linter to ensure that all fields are marked as either optional or required. |
analysis/requiredfields
requiredFields is a linter to check that fields that are marked as required are not pointers, and do not have the omitempty tag.
|
requiredFields is a linter to check that fields that are marked as required are not pointers, and do not have the omitempty tag. |