Skip to content

Conversation

@pohly
Copy link
Contributor

@pohly pohly commented Jun 12, 2023

This implements the new interface from
golangci/golangci-lint#3887 with two fields in the "settings":

type settings struct {
      Check  map[string]bool `json:"check"`
      Config string          `json:"config"`
}

This is the actual config data, not the name of a config file. This is intentional because

  • relative file paths wouldn't work (plugin cannot resolve them)
  • loading additional file content wouldn't invalidate cached linter results the that embedding the data inside the main config does

The include text template method ensures that logcheck.conf gets injected automatically. Having it as separate file has the advantage that manual invocations of the stand-alone logcheck linter still work.

This implements the new interface from
golangci/golangci-lint#3887 with two fields in the
"settings":

type settings struct {
      Check  map[string]bool `json:"check"`
      Config string          `json:"config"`
}

This is the actual config *data*, not the name of a config file. This is
intentional because
- relative file paths wouldn't work (plugin cannot resolve them)
- loading additional file content wouldn't invalidate cached linter
  results the that embedding the data inside the main config does

The `include` text template method ensures that logcheck.conf gets injected
automatically. Having it as separate file has the advantage that manual
invocations of the stand-alone logcheck linter still work.
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pohly

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

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 12, 2023
@k8s-ci-robot k8s-ci-robot requested review from dims and logicalhan June 12, 2023 12:57
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 12, 2023
@pohly
Copy link
Contributor Author

pohly commented Jun 12, 2023

/hold

golangci/golangci-lint#3887 should get merged first, to ensure that the new plugin API doesn't change anymore.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 12, 2023
@logicalhan
Copy link

/triage accepted
/assign

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 15, 2023
//
// The downside is that format errors are less user-friendly.
var buffer bytes.Buffer
if err := json.NewEncoder(&buffer).Encode(pluginSettings); err != nil {

Choose a reason for hiding this comment

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

If we don't mind adding a third dependency of "github.com/mitchellh/mapstructure", it's simpler the parse pluginSettings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

golangci-lint already depends on it, so it wouldn't make a difference for Kubernetes in hack/tools. But here I prefer to avoid such a heavy dependency.

I am also not sure whether mapstructure would provide better error messages. Does it?

Choose a reason for hiding this comment

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

mapstructure provides detailed error messages but I think it is most useful for decoding purposes.

This fixes random parser failures.
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 8, 2023
@pohly
Copy link
Contributor Author

pohly commented Aug 9, 2023

/hold cancel

The new API is going to be supported by golangci-lint in a new release expected tomorrow, and that release will warn about logcheck when it only supports the old API. We should merge this PR and use the updated logcheck in Kubernetes.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 9, 2023
@pohly
Copy link
Contributor Author

pohly commented Aug 9, 2023

A test PR with this modified logcheck is here: kubernetes/kubernetes#119860

Copy link

@Namanl2001 Namanl2001 left a comment

Choose a reason for hiding this comment

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

on a higher level, the changes looks good to me

@pohly
Copy link
Contributor Author

pohly commented Aug 10, 2023

@Namanl2001: are you confident enough with the changes to do a formal LGTM?

@Namanl2001
Copy link

@Namanl2001: are you confident enough with the changes to do a formal LGTM?

yes

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 10, 2023
@k8s-ci-robot k8s-ci-robot merged commit 1a6e22d into kubernetes-sigs:main Aug 10, 2023
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants