Skip to content

more flexible loading of custom plugins #3826

Open
@pohly

Description

@pohly

Your feature request related to a problem? Please describe.

In Kubernetes, we have a hack/golangci-lint.yaml with a path for a logcheck.so which is relative to that config:
https://github.com/kubernetes/kubernetes/blob/b09b7e5bdb1c763c6d7e47e2c792d54f37f7d9a2/hack/golangci.yaml#L42

That works because normally, _output contains build artifacts. It fails when using containerized builds where build artifacts are located elsewhere:
kubernetes/kubernetes#117831

Describe the solution you'd like.

When loading a plugin, golangci-lint could first try the absolute or relative path and if that file doesn't exist, fall back to searching for the plugin in directories specified via env variables. This could be PATH (kind of convenient because the plugin gets compiled together with the golangci-lint binary to ensure that both use the same Go and compile options and already gets placed in the same directory) or a custom variable like GOLANGCI_LINT_CUSTOM_PLUGIN_PATH.

Describe alternatives you've considered.

  • An absolute path doesn't work, developers check out there source in different locations.
  • Patching the config file is ugly (dirty repository during the build).
  • Copying the config file elsewhere and modifying it there messes with other relative paths.

Additional context.

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvementlinter: customAbout custom/private lintersno decisionNo decision to fix or not

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions