Skip to content

Conversation

@bernot-dev
Copy link
Collaborator

@bernot-dev bernot-dev commented Dec 2, 2025

Bump golangci-lint to 2.6.2.

The removals of omitempty in json struct tags have been verified by modernize to be ineffective. omitzero was not added to avoid behavior changes. Corresponding fields have been explicitly marked optional. This results in some updates to the documentation, but no changes to the CRDs themselves.

Instances of interface{} have been changed to any.

String formatting functions have been replaced when they do not use actual formatting placeholders.

TestMain implicitly calls os.Exit since 1.15.

The pattern of splitting and then iterating over the parts has been replaced with SplitSeq, which is more efficient.

@bernot-dev bernot-dev self-assigned this Dec 2, 2025
@bernot-dev bernot-dev force-pushed the golangci-lint-2.6.2 branch 2 times, most recently from 24f83f9 to ebd82b9 Compare December 3, 2025 18:01
Copy link
Collaborator

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks! Majority changes make sense, just few suggestions.

The removals of omitempty in json struct tags have been verified by modernize to be ineffective. omitzero was not added to avoid behavior changes. Corresponding fields have been explicitly marked optional. This results in some updates to the documentation, but no changes to the CRDs themselves.

Hm, are we sure about the modernize check? This is true for std json, but we don't use std json decoding but that yaml.v3 which does have a unique omitempty-almost-like-omitzero behaviour - https://pkg.go.dev/gopkg.in/yaml.v3#section-readme:~:text=Only%20include%20the%20field%20if%20it%27s%20not%20set%20to%20the%20zero

Notably zero value is omitted in our yaml parsing (also what k8s is using) (!), so I think this can potentially break things. Can we ignore that modernize rule just to be safe (unless we have time to test this thoroughly)?

Comment on lines 345 to 346
if _, err := fmt.Fprintln(w, "rule-evaluator is Ready."); err != nil {
_ = level.Error(logger).Log("msg", "Unable to write readiness check message", "err", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we have a global ignore for logging and fmt.Fprintln? It's 99% not needed.

E.g. here we never handle error for HTTP response bytes (best effort), even in the most high quality prod servers I worked with.

SourceLabels: prommodel.LabelNames{objectLabelPresent + sanitizeLabelName(exp.Key)},
Regex: relabel.MustNewRegexp("true"),
})
default:
Copy link
Collaborator

Choose a reason for hiding this comment

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

TODO for myself (or anyone else): Double check if this is for sure all cases in op.Operator.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

// The last time this condition was updated.
// +optional
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
LastUpdateTime metav1.Time `json:"lastUpdateTime"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, I think those are not safe to remove. Modernize is doing this assuming we use std JSON encoder/decoder but I wonder if that's true (we use yaml.v3, same k8s).

metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
metav1.TypeMeta `json:",inline"`
// +optional
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is manual change for kubebuilder not modernize change right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. I think it's safe to just make these required....you can't have a valid resource without a name. But it changes the CRD spec and explicitly marks it as required unless it's marked optional.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we do nothing (what was before?) 🙃

Just to pick our battles?

type PodMonitoring struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// +kubebuilder:validation:Optional
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, sometimes +optional is used too. Which one we want? Can we skip kubebuilder vs linter changes to separate PRs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants