Skip to content

Conversation

ialidzhikov
Copy link
Member

@ialidzhikov ialidzhikov commented Jul 29, 2025

How to categorize this PR?

/area dev-productivity
/kind cleanup

What this PR does / why we need it:
Usually, gardener/gardener's golangci-lint config is also reused by extension repos.

This PR updates the golangci-lint config:

  • Removes exclusions of non-existing paths
  • Remove import alias rule for non-existing pkgs
  • Updates import alias rules for changed pkg names

Which issue(s) this PR fixes:
N/A

Special notes for your reviewer:
ℹ️ Check the commit messages for reasoning/details for each commit.

Release note:

NONE

Extension clients are no longer generated after gardener#4592.
I don't find in the project a path matching `builtin$`.
I don't find in the project a path matching `examples$`. We have a dir named `example/`, not `examples/`.
With gardener#11673, the fluent-operator imports were updated from `github.com/fluent/fluent-operator/v2` to `github.com/fluent/fluent-operator/v3`.
`github.com/gardener/gardener/extensions/pkg/apis/config` was removed with gardener#11056.
Internal component config APIs were removed. See gardener#11043
@gardener-prow gardener-prow bot added area/dev-productivity Developer productivity related (how to improve development) kind/cleanup Something that is not needed anymore and can be cleaned up labels Jul 29, 2025
@gardener-prow gardener-prow bot requested review from ary1992 and marc1404 July 29, 2025 07:31
@gardener-prow gardener-prow bot added cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 29, 2025
`pkg/client/security` contains generated clientset, informers and listers. Similar to the other generated dirs, it should be excluded.
Introduced with gardener#11545. The correct pkg is `github.com/gardener/etcd-druid/api/core/v1alpha1/crds`, not `github.com/gardener/etcd-druid/api/core/crds`.
Copy link
Member

@ScheererJ ScheererJ left a comment

Choose a reason for hiding this comment

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

Thanks for bringing the configuration up-to-date.

Do you think that we should add the example folder as it might be what was intended when examples was added? Then again, it did not cause any issues so far. Hence, removing it should also work.
WDYT?

Apart from that, everything looks good.

@ialidzhikov
Copy link
Member Author

/hold

@gardener-prow gardener-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 30, 2025
Copy link
Member

@marc1404 marc1404 left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning up and improving the golangci-lint config! 🧹 ✨
+1 for the great commit structure and explanations, makes it easy to follow :)

I'm aware the PR is on hold, but for the changes overall:
/lgtm

@gardener-prow gardener-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jul 30, 2025
Copy link
Contributor

gardener-prow bot commented Jul 30, 2025

LGTM label has been added.

Git tree hash: 231989a9929cc1c033b480422c58bbd84e026452

@ialidzhikov
Copy link
Member Author

I put the PR on hold because @dimitar-kostadinov explained me that we already use lax mode. Ref gardener/gardener-extension-registry-cache#416 (comment).

From the docs:

# - `lax`: sources are excluded if they contain lines like `autogenerated file`, `code generated`, `do not edit`, etc.

Hence, maybe we don't need to exclude autogenerated paths at all as that's the idea of lax mode - to detect and automatically ignore generated file.

We already use `linters.exclusions.generated=lax`. `lax` mode should automatically detect and ignore generated files.
Ref https://golangci-lint.run/usage/configuration/#linters-configuration
In the Makefile, we explicitly pass the paths to be checked. `third_party` is not among them. Hence, there is no need to exclude it as we don't check for it.
https://github.com/gardener/gardener/blob/v1.124.0/Makefile#L165
`third_party` currently contains a forked dependency and generated mocks. Hence, I don't see much value for checking for imports there as it does not contain a pkg which is not generated or not copied.
@gardener-prow gardener-prow bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 31, 2025
@gardener-prow gardener-prow bot requested a review from marc1404 July 31, 2025 05:58
@gardener-prow gardener-prow bot removed the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 31, 2025
@gardener-prow gardener-prow bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 31, 2025
@ialidzhikov
Copy link
Member Author

Do you think that we should add the example folder as it might be what was intended when examples was added? Then again, it did not cause any issues so far. Hence, removing it should also work.
WDYT?

I cleaned up all exclusions as we explicitly specify in the Makefile for make check which pkgs to be checked. See

@hack/check.sh --golangci-lint-config=./.golangci.yaml ./charts/... ./cmd/... ./extensions/... ./pkg/... ./plugin/... ./test/...

I don't see value excluding a path when this path is not among the ones we check.

@ialidzhikov
Copy link
Member Author

/hold cancel

@gardener-prow gardener-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 31, 2025
@ialidzhikov ialidzhikov requested a review from ScheererJ July 31, 2025 06:10
@ialidzhikov
Copy link
Member Author

/cc @dimitar-kostadinov

Copy link
Member

@marc1404 marc1404 left a comment

Choose a reason for hiding this comment

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

/lgtm

@gardener-prow gardener-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jul 31, 2025
Copy link
Contributor

gardener-prow bot commented Jul 31, 2025

LGTM label has been added.

Git tree hash: 39e802cbbd752078488fecb3367c6da59075a8e3

Copy link
Contributor

@dimitar-kostadinov dimitar-kostadinov left a comment

Choose a reason for hiding this comment

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

Only one nit, otherwise lgtm

@gardener-prow gardener-prow bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 13, 2025
@gardener-prow gardener-prow bot requested a review from marc1404 August 13, 2025 12:16
Copy link
Contributor

@dimitar-kostadinov dimitar-kostadinov left a comment

Choose a reason for hiding this comment

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

/lgtm

@gardener-prow gardener-prow bot added the lgtm Indicates that a PR is ready to be merged. label Aug 13, 2025
Copy link
Contributor

gardener-prow bot commented Aug 13, 2025

LGTM label has been added.

Git tree hash: ec0493f44a889878057a4aff027cc3db93f25667

Copy link
Member

@marc1404 marc1404 left a comment

Choose a reason for hiding this comment

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

/approve

Copy link
Contributor

gardener-prow bot commented Aug 13, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: marc1404

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

The pull request process is described here

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

@gardener-prow gardener-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 13, 2025
@gardener-prow gardener-prow bot merged commit 8566291 into gardener:master Aug 13, 2025
19 checks passed
@ialidzhikov ialidzhikov deleted the cleanup/golangci-lint-config branch August 14, 2025 06:59
Duciwuci pushed a commit to stackitcloud/gardener that referenced this pull request Sep 1, 2025
* Clean up exclusion of non-existing `pkg/client/extensions` path

Extension clients are no longer generated after gardener#4592.

* Clean up exclusion of non-existing `builtin$` path

I don't find in the project a path matching `builtin$`.

* Clean up exclusion of non-existing `examples$` path

I don't find in the project a path matching `examples$`. We have a dir named `example/`, not `examples/`.

* Update fluent-operator import alias

With gardener#11673, the fluent-operator imports were updated from `github.com/fluent/fluent-operator/v2` to `github.com/fluent/fluent-operator/v3`.

* Clean up import alias for non-existing pkg

`github.com/gardener/gardener/extensions/pkg/apis/config` was removed with gardener#11056.

* Clean up import alias for non-existing pkg(s)

Internal component config APIs were removed. See gardener#11043

* Add `pkg/client/security` to the list of excluded dirs

`pkg/client/security` contains generated clientset, informers and listers. Similar to the other generated dirs, it should be excluded.

* Update the import alias for etcd-druid crds pkg

Introduced with gardener#11545. The correct pkg is `github.com/gardener/etcd-druid/api/core/v1alpha1/crds`, not `github.com/gardener/etcd-druid/api/core/crds`.

* Clean up paths with generated code from `linters.exclusions.paths`

We already use `linters.exclusions.generated=lax`. `lax` mode should automatically detect and ignore generated files.
Ref https://golangci-lint.run/usage/configuration/#linters-configuration

* Clean up the exclusion of the `third_party` path

In the Makefile, we explicitly pass the paths to be checked. `third_party` is not among them. Hence, there is no need to exclude it as we don't check for it.
https://github.com/gardener/gardener/blob/v1.124.0/Makefile#L165

* Don't check for imports under `third_party`

`third_party` currently contains a forked dependency and generated mocks. Hence, I don't see much value for checking for imports there as it does not contain a pkg which is not generated or not copied.

* Address PR review feedback from dimitar-kostadinov
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. area/dev-productivity Developer productivity related (how to improve development) cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. kind/cleanup Something that is not needed anymore and can be cleaned up lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants