Developers are expected to run the following prior to posting PRs.
make ci-jobThis will run the various linters, as well as required unit tests.
Full list linters and config can be found in .golangci.yml
-
The golangci-lint test can be run individually at any time during development (Note:
make ci-jobalso runs this)make golangci-lint
-
Or run the following to allow
golangci-lintfor any auto fixes (if available by linter)golangci-lint run --fix --config .golangci.yml
If you would like to suppress a false positive, consider in-line syntax. Please note that such suppressions should only be used in exceptional cases, however, rather than common practice.
An example error for gosec
lca-cli/ops/ops.go:162:17: G107: Potential HTTP request made with variable url (gosec)
resp, err := http.Get(healthzEndpoint)Suppress the error with the following syntax //nolint:mylinter1,mylinter2.
resp, err := http.Get(healthzEndpoint) //nolint:gosec- List of linters here. See
AutoFixcolumn for which ones can work with--fix. - More techniques for suppressing false positives here
Consider checking out the enhancement for latest features/tips and The OCP must-gather repo for examples.
Run locally
# $1 - path to local output dir. It will created if not present
./must-gather/collection-scripts/gather must-gather/tmpTo debug or run Stateroot job independently just print out the full CR after construction with the following.
import (
"sigs.k8s.io/yaml"
)
b, _ := yaml.Marshal(job)
log.Printf("Yaml of the job is: %q", string(b))📝 currently it's not idempotent, but experimentally it was achieved by calling
CleanupUnbootedStaterootsas a pre-condition in the cli.