Skip to content

Conversation

nmn3m
Copy link
Member

@nmn3m nmn3m commented Sep 29, 2025

What this PR does / why we need it:
This PR fixes an issue where test files contained inconsistent indentation (spaces and tabs) that were not caught by linting.
We now normalize leading whitespace in test parsing by using:

trimmedLine := strings.TrimLeft(l, " \t")

Additionally, some failing tests were updated to align with the corrected logic.

How does this change affect the cardinality of KSM:
does not change cardinality

Which issue(s) this PR fixes:
Fixes #2776

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 29, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nmn3m
Once this PR has been reviewed and has the lgtm label, please assign dgrisonnet for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Sep 29, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If kube-state-metrics contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@github-project-automation github-project-automation bot moved this to Needs Triage in SIG Instrumentation Sep 29, 2025
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 29, 2025

for _, l := range lines {
trimmedLine = strings.TrimSpace(l)
trimmedLine = strings.TrimLeft(l, " \t")
Copy link
Member

Choose a reason for hiding this comment

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

why do we need to check for tabs as well? Could we only do spaces?

Copy link
Member Author

Choose a reason for hiding this comment

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

I went with strings.TrimLeft(l, " \t") instead of just " " because when I only trimmed spaces, a lot of tests failed. Using both spaces and tabs handled the mixed indentation and fixed the test failures.

Copy link
Member

Choose a reason for hiding this comment

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

Can we fix the indentation instead to only use spaces or won't that work?

Copy link
Member Author

@nmn3m nmn3m Sep 30, 2025

Choose a reason for hiding this comment

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

I tried to fix the indentation using the white spaces, and the tests failed.
I think using the combination between white spaces and tab will be a good choice in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

Test Files Pass CI Despite Improper Indentation
3 participants