Skip to content

NO-JIRA: Sort and verify imports#1328

Open
hongkailiu wants to merge 2 commits intoopenshift:mainfrom
hongkailiu:openshift-goimports
Open

NO-JIRA: Sort and verify imports#1328
hongkailiu wants to merge 2 commits intoopenshift:mainfrom
hongkailiu:openshift-goimports

Conversation

@hongkailiu
Copy link
Member

@hongkailiu hongkailiu commented Feb 27, 2026

We will use it to sort imports.

I tried openshift-goimports [1] and it did not work out
for us because

  • It does not work with comments [2].
  • We do have a comment to make golang linter happy [3].

[1]. https://github.com/openshift-eng/openshift-goimports

[2]. openshift-eng/openshift-goimports#16

[3].

//nolint:staticcheck // verify,Verifier from openshift/library-go uses a type from this deprecated package (needs to be addressed there)
"golang.org/x/crypto/openpgp"

It may change the auto-generated file lib/resourceread/resourceread.go and lib/resourcebuilder/resourcebuilder.go.
So in theory, we need to run make imports after ./hack/generate-lib-resources.py (or fix the script ./hack/generate-lib-resources.py).
The CI would signal if we forget doing it.

Summary by CodeRabbit

  • Chores
    • Standardized and cleaned up import grouping and formatting across the codebase for consistent style and maintainability.
    • Added a public import-format check to the build workflow and updated the verification flow to run it before update steps.
    • Minor non-functional formatting tweaks across tests and components to improve readability.

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

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

Details

In response to this:

We do not need to do it manually any more and it is the OpenShift best practices.

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.

@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between e528692 and 0d49844.

📒 Files selected for processing (69)
  • Makefile
  • cmd/cluster-version-operator/image.go
  • cmd/cluster-version-operator/main.go
  • cmd/cluster-version-operator/render.go
  • cmd/cluster-version-operator/start.go
  • cmd/cluster-version-operator/version.go
  • hack/cluster-version-util/main.go
  • hack/cluster-version-util/task_graph.go
  • lib/capability/capability_test.go
  • lib/resourceapply/admissionregistration.go
  • lib/resourceapply/apiext.go
  • lib/resourceapply/apps.go
  • lib/resourceapply/batch.go
  • lib/resourceapply/core.go
  • lib/resourceapply/cv.go
  • lib/resourceapply/imagestream.go
  • lib/resourceapply/operators.go
  • lib/resourceapply/rbac.go
  • lib/resourceapply/security.go
  • lib/resourcebuilder/podspec_test.go
  • lib/resourcebuilder/resourcebuilder.go
  • lib/resourcedelete/operators.go
  • lib/resourcemerge/admissionregistration_test.go
  • lib/resourcemerge/apiext_test.go
  • lib/resourcemerge/batch_test.go
  • lib/resourcemerge/core_test.go
  • lib/resourcemerge/imagestream_test.go
  • lib/resourcemerge/operators.go
  • lib/resourcemerge/operators_test.go
  • lib/resourcemerge/rbac_test.go
  • lib/resourcemerge/security_test.go
  • lib/resourceread/resourceread.go
  • pkg/cincinnati/cincinnati.go
  • pkg/cincinnati/cincinnati_test.go
  • pkg/clusterconditions/clusterconditions_test.go
  • pkg/clusterconditions/promql/promql.go
  • pkg/cvo/availableupdates.go
  • pkg/cvo/availableupdates_test.go
  • pkg/cvo/cvo_test.go
  • pkg/cvo/egress.go
  • pkg/cvo/internal/generic.go
  • pkg/cvo/internal/operatorstatus.go
  • pkg/cvo/internal/operatorstatus_test.go
  • pkg/cvo/metrics.go
  • pkg/cvo/metrics_test.go
  • pkg/cvo/reconciliation_issues.go
  • pkg/cvo/reconciliation_issues_test.go
  • pkg/cvo/status.go
  • pkg/cvo/status_history_test.go
  • pkg/cvo/status_test.go
  • pkg/cvo/sync_test.go
  • pkg/cvo/sync_worker.go
  • pkg/cvo/sync_worker_test.go
  • pkg/cvo/updatepayload.go
  • pkg/cvo/updatepayload_test.go
  • pkg/cvo/upgradeable.go
  • pkg/cvo/upgradeable_test.go
  • pkg/payload/payload.go
  • pkg/payload/payload_test.go
  • pkg/payload/precondition/clusterversion/gianthop.go
  • pkg/payload/precondition/clusterversion/gianthop_test.go
  • pkg/payload/precondition/clusterversion/rollback.go
  • pkg/payload/precondition/clusterversion/rollback_test.go
  • pkg/payload/precondition/clusterversion/upgradeable.go
  • pkg/payload/precondition/clusterversion/upgradeable_test.go
  • pkg/payload/render.go
  • pkg/payload/task_graph_test.go
  • pkg/payload/task_test.go
  • pkg/start/start.go
✅ Files skipped from review due to trivial changes (42)
  • lib/resourcemerge/core_test.go
  • pkg/payload/precondition/clusterversion/rollback_test.go
  • cmd/cluster-version-operator/start.go
  • lib/resourcemerge/admissionregistration_test.go
  • pkg/payload/precondition/clusterversion/upgradeable_test.go
  • pkg/clusterconditions/promql/promql.go
  • pkg/cvo/status_history_test.go
  • lib/resourcemerge/security_test.go
  • pkg/cvo/sync_worker.go
  • lib/resourcemerge/apiext_test.go
  • lib/resourcebuilder/podspec_test.go
  • pkg/payload/precondition/clusterversion/gianthop.go
  • lib/resourcemerge/batch_test.go
  • lib/resourceapply/operators.go
  • pkg/cvo/cvo_test.go
  • pkg/cvo/updatepayload_test.go
  • pkg/cvo/sync_worker_test.go
  • cmd/cluster-version-operator/main.go
  • pkg/payload/precondition/clusterversion/rollback.go
  • pkg/payload/precondition/clusterversion/upgradeable.go
  • cmd/cluster-version-operator/image.go
  • lib/resourcemerge/rbac_test.go
  • hack/cluster-version-util/task_graph.go
  • lib/capability/capability_test.go
  • pkg/cvo/upgradeable_test.go
  • pkg/cvo/status.go
  • pkg/cvo/availableupdates.go
  • hack/cluster-version-util/main.go
  • pkg/payload/task_test.go
  • lib/resourceapply/core.go
  • pkg/cincinnati/cincinnati_test.go
  • pkg/cvo/metrics_test.go
  • pkg/cvo/availableupdates_test.go
  • lib/resourceapply/cv.go
  • lib/resourcemerge/imagestream_test.go
  • pkg/payload/task_graph_test.go
  • pkg/start/start.go
  • lib/resourcemerge/operators.go
  • pkg/payload/precondition/clusterversion/gianthop_test.go
  • lib/resourceread/resourceread.go
  • pkg/payload/payload.go
  • pkg/cvo/internal/operatorstatus.go
🚧 Files skipped from review as they are similar to previous changes (10)
  • pkg/cincinnati/cincinnati.go
  • pkg/cvo/internal/operatorstatus_test.go
  • lib/resourceapply/rbac.go
  • pkg/cvo/status_test.go
  • pkg/cvo/reconciliation_issues.go
  • pkg/cvo/metrics.go
  • lib/resourceapply/batch.go
  • lib/resourceapply/apps.go
  • lib/resourceapply/admissionregistration.go
  • pkg/cvo/sync_test.go

Walkthrough

Adds a new imports Makefile target (and marks it phony), makes verify-update depend on imports, and applies widespread import reordering / blank-line formatting changes across many Go source and test files; no functional code logic changes.

Changes

Cohort / File(s) Summary
Makefile
Makefile
Added public imports: target (installs/runs goimports and formats imports) and declared .PHONY: imports; updated verify-update dependency from update to imports update.
Resource apply files
lib/resourceapply/{admissionregistration.go,apiext.go,apps.go,batch.go,cv.go,imagestream.go,rbac.go,security.go,core.go,operators.go}
Reordered import blocks (moved lib/resourcemerge and related imports), minor import alias/spacing adjustments; no behavioral changes.
Resource builder / delete / merge / read
lib/resourcebuilder/resourcebuilder.go, lib/resourcedelete/operators.go, lib/resourcemerge/*, lib/resourceread/resourceread.go
Grouped/moved imports into separate blocks or reordered imports; removed duplicate import occurrence; tests received spacing tweaks.
pkg/cvo and cincinnati areas
pkg/cvo/*, pkg/cincinnati/*, pkg/clusterconditions/*
Inserted blank lines between import groups, added/relocated manifest and crypto imports, and adjusted import ordering; changes are formatting-only.
pkg/payload & preconditions
pkg/payload/*, pkg/payload/precondition/clusterversion/*
Reordered imports and added spacing between groups; imported/relocated errors/manifest/capability as formatting adjustments.
cmd and hack tools
cmd/cluster-version-operator/{version.go,image.go,main.go,render.go,start.go}, hack/cluster-version-util/*
Added blank lines and minor reordering in import blocks; no logic changes.
Tests across the repo
multiple *_test.go files (e.g., pkg/cvo/*_test.go, lib/resourcemerge/*_test.go, lib/resourcebuilder/*_test.go, pkg/payload/*_test.go)
Added blank lines between import groups or slightly reordered imports for consistency; no functional changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'NO-JIRA: Sort and verify imports' accurately summarizes the main objective of the PR, which is to reorganize and verify imports across the codebase using goimports-like formatting.
Stable And Deterministic Test Names ✅ Passed Pull request exclusively modifies import statements and formatting; no changes to test titles, declarations, or logic detected.
Test Structure And Quality ✅ Passed This PR exclusively focuses on import sorting and formatting across 50+ files including tests, with no modifications to test logic or structure.

✏️ 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.

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 27, 2026
@hongkailiu hongkailiu force-pushed the openshift-goimports branch 2 times, most recently from 86134d0 to e528692 Compare February 27, 2026 16:26
We will use it to sort imports.

I tried openshift-goimports [1] and it did not work out
for us because

* It does not work with comments [2].
* We do have a comment to make golang linter happy [3].

[1]. https://github.com/openshift-eng/openshift-goimports

[2]. openshift-eng/openshift-goimports#16

[3]. https://github.com/openshift/cluster-version-operator/blob/ac127d3a5d45f60eb54e5c5acc3711a284728499/pkg/cvo/updatepayload_test.go#L14-L15
Copy link
Member

@wking wking left a comment

Choose a reason for hiding this comment

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

/lgtm

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

openshift-ci bot commented Feb 27, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hongkailiu, wking

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
Copy link
Contributor

openshift-ci bot commented Feb 27, 2026

@hongkailiu: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-agnostic-ovn 0d49844 link true /test e2e-agnostic-ovn
ci/prow/e2e-aws-ovn-techpreview 0d49844 link true /test e2e-aws-ovn-techpreview

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.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants