Skip to content

NO-JIRA: add golangci-lint#835

Merged
openshift-merge-bot[bot] merged 2 commits intoopenshift:mainfrom
simonpasquier:add-golangci-lint
Mar 12, 2026
Merged

NO-JIRA: add golangci-lint#835
openshift-merge-bot[bot] merged 2 commits intoopenshift:mainfrom
simonpasquier:add-golangci-lint

Conversation

@simonpasquier
Copy link
Contributor

@simonpasquier simonpasquier commented Mar 11, 2026

See also openshift/release#76147

Summary by CodeRabbit

  • Chores

    • Integrated linting tool into the build pipeline and updated build configuration for enhanced code quality assurance.
    • Updated version control ignore patterns to exclude build artifacts.
  • Refactor

    • Optimized internal code structure with minor reorganization and removal of unused helper functions.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 11, 2026
@openshift-ci-robot
Copy link

@simonpasquier: This pull request explicitly references no jira issue.

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@simonpasquier
Copy link
Contributor Author

/cc @jgbernalp
/cc @jan--f

@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

Walkthrough

Introduces GolangCI-Lint configuration and integrates it into the build pipeline via Makefile, with supporting configuration for linting rules. Includes minor code refactoring: import reordering across multiple files and removal of an internal error handling helper function. No functional changes to runtime behavior.

Changes

Cohort / File(s) Summary
Build Configuration
.gitignore, .golangci-lint.yaml, Makefile
Adds GolangCI-Lint v2.11.3 integration to build pipeline with errcheck exclusions, generated code handling, and gci formatter configuration. Updates .gitignore to exclude _output/ directory. Makefile now downloads and runs linter as a dependency for deployment.
Code Refactoring
cmd/plugin-backend.go, pkg/proxy/proxy.go, pkg/server.go
Reorders import statements across files. Removes internal handleError function from proxy package. Updates pkg/server.go to access PluginServer embedded fields directly rather than through nested Server field reference, affecting Addr, ListenAndServeTLS, and ListenAndServe access patterns.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding golangci-lint integration to the project, which is the primary purpose across Makefile, .golangci-lint.yaml, and .gitignore modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Stable And Deterministic Test Names ✅ Passed No test files or Ginkgo test patterns were identified in the PR changes.
Test Structure And Quality ✅ Passed The custom check is designed to review Ginkgo test code, but this repository uses standard Go testing with testify, not Ginkgo.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Makefile`:
- Around line 95-98: Remove the destructive "go mod tidy" from the lint-backend
target so lint-backend (and any targets depending on it) remain read-only;
instead create a separate target (e.g., check-modules or verify-modules) that
runs "go mod tidy" followed by a check like "git diff --exit-code" to fail if
tidy would modify go.mod/go.sum, and update any higher-level targets that need
module validation (e.g., deploy) to depend on that new verify-modules target
rather than lint-backend; look for the lint-backend target and the golangci-lint
symbol to apply this change.
- Around line 87-93: The golangci-lint Makefile target currently only checks for
the binary file and uses the moving master installer URL; update the
golangci-lint target (and references to GOLANGCI_LINT and GOLANGCI_LINT_VERSION)
to verify the installed binary's version (e.g., run '$(GOLANGCI_LINT) --version'
and compare to '$(GOLANGCI_LINT_VERSION)') and if missing or mismatched
remove/reinstall, and switch the installer URL to the official pinned endpoint
'https://golangci-lint.run/install.sh' while passing the pinned
'$(GOLANGCI_LINT_VERSION)' to the installer so changing GOLANGCI_LINT_VERSION
triggers a reinstall.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 8a86dab6-7112-44e3-979c-62d662a361dd

📥 Commits

Reviewing files that changed from the base of the PR and between 4b2ccc0 and f2e2d1d.

📒 Files selected for processing (6)
  • .gitignore
  • .golangci-lint.yaml
  • Makefile
  • cmd/plugin-backend.go
  • pkg/proxy/proxy.go
  • pkg/server.go
💤 Files with no reviewable changes (1)
  • pkg/proxy/proxy.go

Comment on lines +87 to +93
# Download and install golangci-lint if not already installed
.PHONY: golangci-lint
golangci-lint:
@[ -f $(GOLANGCI_LINT) ] || { \
set -e ;\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) $(GOLANGCI_LINT_VERSION) ;\
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

golangci-lint install.sh official documentation recommended URL

💡 Result:

The golangci-lint docs recommend using the install script hosted at:

https://golangci-lint.run/install.sh

This recommendation appears in the official Local Installation → Binaries section (with example curl ... | sh -s ...). 1

Official install documentation page: 2

Citations:


🌐 Web query:

golangci-lint version checking best practices

💡 Result:

Best practices for golangci-lint version checking (and avoiding “works on my machine”)

  1. Pin a specific golangci-lint version in CI (avoid latest)
    The golangci-lint docs explicitly recommend installing a specific release for reproducible CI, because new/updated linters can suddenly break builds. [1]

  2. Use an install method that makes the version explicit

    • Install script / binary: pass an explicit tag (e.g., v2.11.3) and then you can sanity-check with golangci-lint --version. [2]
    • Docker: use a tagged image (e.g., golangci/golangci-lint:v2.11.3). [2]
  3. If you use GitHub Actions, pin both:

    • the action major (e.g., golangci/golangci-lint-action@v9)
    • and the linter version via version: or version-file: (e.g., .golangci-lint-version / .tool-versions). [3]
      Note: the action accepts v2.3 (minor) and will pick the latest patch for that minor; for maximum reproducibility, prefer pinning the full patch (e.g., v2.11.3) rather than only v2.11. [3]
  4. Version-control your config format and validate it in CI

    • Add version: "2" at the top of .golangci.yml to lock the config format. [4]
    • Keep config validation enabled (the action’s verify is on by default, and validation depends on the golangci-lint version you run). [3][4]
  5. Add a lightweight “version gate” for developers

    • Put the expected version in a file (e.g., .golangci-lint-version) and have make lint (or a pre-commit hook) compare golangci-lint --version to that value; fail fast with a clear message. (The action already supports reading such a file in CI.) [3]

Sources

[1] Golangci-lint CI installation docs (reproducible CI; recommend pinning a specific release) (golangci-lint.run)
[2] Golangci-lint local installation docs (install script with explicit tag; docker tags; --version) (golangci-lint.run)
[3] golangci-lint GitHub Action README (inputs version, version-file, behavior, config verification) (github.com)
[4] Golangci-lint configuration file docs (version: "2" is the only valid config version) (golangci-lint.run)

Citations:


🌐 Web query:

site:golangci-lint.run install.sh

💡 Result:

To install golangci-lint via the hosted install.sh script:

# Installs to $(go env GOPATH)/bin
curl -sSfL https://golangci-lint.run/install.sh | sh -s -- -b "$(go env GOPATH)/bin" v2.9.0

# Or install into ./bin (default)
curl -sSfL https://golangci-lint.run/install.sh | sh -s v2.9.0

# Alpine (no curl by default)
wget -O- -nv https://golangci-lint.run/install.sh | sh -s v2.9.0

Verify:

golangci-lint --version

[1]


🏁 Script executed:

# First, find and examine the Makefile to understand GOLANGCI_LINT variable
fd -type f -name "Makefile" | head -5

Repository: openshift/monitoring-plugin

Length of output: 241


🏁 Script executed:

# Check what golangci-lint --version outputs (simulate based on known behavior)
# Also verify the syntax: is it "version" or "--version"?
web_search_needed="golangci-lint --version output format"
echo "Need to verify: golangci-lint version output format and flag (--version vs version)"

Repository: openshift/monitoring-plugin

Length of output: 154


🏁 Script executed:

# Look at the Makefile to see variable definitions
cat Makefile | head -100

Repository: openshift/monitoring-plugin

Length of output: 2470


🏁 Script executed:

# Verify the exact golangci-lint command syntax for version checking
# Check web documentation or common usage
echo "Checking golangci-lint command syntax..."

Repository: openshift/monitoring-plugin

Length of output: 111


🌐 Web query:

golangci-lint version flag syntax --version vs version command

💡 Result:

In current golangci-lint (v2.x) you can get the version in two ways:

  • Flag (quick check): golangci-lint --version (global flag; “Print version”). [1]
  • Command (more control): golangci-lint version (supports --short, --json, --debug). [1]

Note: golangci-lint custom --version <ver> is a different flag meaning “which golangci-lint version to use to build the custom binary,” not “print my version.” [1]

Sources: [1] GolangCI-Lint CLI docs, [2] GolangCI-Lint local install docs (shows golangci-lint --version).


Make the golangci-lint bootstrap version-aware and use the official installer URL.

The binary existence check on line 90 only verifies file presence, so bumping GOLANGCI_LINT_VERSION will not refresh cached installs. Line 92 fetches the installer from the repository's moving master branch; the official golangci-lint documentation recommends https://golangci-lint.run/install.sh and explicitly advises pinning a specific release for reproducible builds.

Suggested change
 golangci-lint:
-	@[ -f $(GOLANGCI_LINT) ] || { \
+	@$(GOLANGCI_LINT) version 2>/dev/null | grep -q '$(GOLANGCI_LINT_VERSION)' || { \
 		set -e ;\
-		curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) $(GOLANGCI_LINT_VERSION) ;\
+		curl -sSfL https://golangci-lint.run/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) $(GOLANGCI_LINT_VERSION) ;\
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Download and install golangci-lint if not already installed
.PHONY: golangci-lint
golangci-lint:
@[ -f $(GOLANGCI_LINT) ] || { \
set -e ;\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) $(GOLANGCI_LINT_VERSION) ;\
}
# Download and install golangci-lint if not already installed
.PHONY: golangci-lint
golangci-lint:
@$(GOLANGCI_LINT) version 2>/dev/null | grep -q '$(GOLANGCI_LINT_VERSION)' || { \
set -e ;\
curl -sSfL https://golangci-lint.run/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) $(GOLANGCI_LINT_VERSION) ;\
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 87 - 93, The golangci-lint Makefile target currently
only checks for the binary file and uses the moving master installer URL; update
the golangci-lint target (and references to GOLANGCI_LINT and
GOLANGCI_LINT_VERSION) to verify the installed binary's version (e.g., run
'$(GOLANGCI_LINT) --version' and compare to '$(GOLANGCI_LINT_VERSION)') and if
missing or mismatched remove/reinstall, and switch the installer URL to the
official pinned endpoint 'https://golangci-lint.run/install.sh' while passing
the pinned '$(GOLANGCI_LINT_VERSION)' to the installer so changing
GOLANGCI_LINT_VERSION triggers a reinstall.

Comment on lines +95 to +98
.PHONY: lint-backend
lint-backend: golangci-lint
go mod tidy
$(GOLANGCI_LINT) -c $(shell pwd)/.golangci-lint.yaml run --verbose
Copy link

@coderabbitai coderabbitai bot Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Keep lint-backend read-only.

go mod tidy rewrites go.mod and go.sum by adding missing requirements and removing unused ones, so make lint-backend — and now make deploy via Line 78 — can mutate the worktree as a side effect of linting. Keep linting as analysis-only and validate module hygiene in a separate target. (go.dev)

🔧 Suggested change
 .PHONY: lint-backend
 lint-backend: golangci-lint
-	go mod tidy
 	$(GOLANGCI_LINT) -c $(shell pwd)/.golangci-lint.yaml run --verbose
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.PHONY: lint-backend
lint-backend: golangci-lint
go mod tidy
$(GOLANGCI_LINT) -c $(shell pwd)/.golangci-lint.yaml run --verbose
.PHONY: lint-backend
lint-backend: golangci-lint
$(GOLANGCI_LINT) -c $(shell pwd)/.golangci-lint.yaml run --verbose
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 95 - 98, Remove the destructive "go mod tidy" from the
lint-backend target so lint-backend (and any targets depending on it) remain
read-only; instead create a separate target (e.g., check-modules or
verify-modules) that runs "go mod tidy" followed by a check like "git diff
--exit-code" to fail if tidy would modify go.mod/go.sum, and update any
higher-level targets that need module validation (e.g., deploy) to depend on
that new verify-modules target rather than lint-backend; look for the
lint-backend target and the golangci-lint symbol to apply this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simonpasquier this seems legitime. Should we just use the golangci-lint?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the goal of running go mod tidy is indeed to ensure that the go.mod file is up-to-date.
openshift/release#76147 will check that after running make lint-backend , there's no uncommitted changes.

@jgbernalp
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 12, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 12, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jgbernalp, simonpasquier

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 12, 2026
@jgbernalp
Copy link
Contributor

/label qe-approved

@openshift-ci openshift-ci bot added the qe-approved Signifies that QE has signed off on this PR label Mar 12, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 12, 2026

@simonpasquier: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 7bcbe86 into openshift:main Mar 12, 2026
9 checks passed
@simonpasquier simonpasquier deleted the add-golangci-lint branch March 13, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. qe-approved Signifies that QE has signed off on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants