Skip to content

Latest commit

 

History

History
77 lines (49 loc) · 2.2 KB

DEVELOPING.md

File metadata and controls

77 lines (49 loc) · 2.2 KB

Development guides and tips

Before Posting PR

Developers are expected to run the following prior to posting PRs.

make ci-job

This will run the various linters, as well as required unit tests.

Linting

Run golangci-lint

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-job also runs this)

    make golangci-lint
  • Or run the following to allow golangci-lint for any auto fixes (if available by linter)

    golangci-lint run --fix --config .golangci.yml

Suppress golangci-lint errors

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

Reference

  • List of linters here. See AutoFix column for which ones can work with --fix.
  • More techniques for suppressing false positives here

Must-Gather

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/tmp

Stateroot job

To 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 CleanupUnbootedStateroots as a pre-condition in the cli.