Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/store/endpointslice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ func TestEndpointSliceStore(t *testing.T) {
# HELP kube_endpointslice_endpoints Endpoints attached to the endpointslice.
# HELP kube_endpointslice_endpoints_hints Topology routing hints attached to endpoints
# TYPE kube_endpointslice_endpoints gauge
# TYPE kube_endpointslice_endpoints_hints gauge
# TYPE kube_endpointslice_endpoints_hints gauge
kube_endpointslice_endpoints_hints{address="10.0.0.1",endpointslice="test_endpointslice-endpoints",for_zone="zone1",namespace="test"} 1
kube_endpointslice_endpoints{address="10.0.0.1",endpoint_nodename="node",endpoint_zone="west",endpointslice="test_endpointslice-endpoints",hostname="",namespace="test",ready="true",serving="false",targetref_kind="",targetref_name="",targetref_namespace="",terminating="host"} 1
kube_endpointslice_endpoints{address="192.168.1.10",endpoint_nodename="node",endpoint_zone="west",endpointslice="test_endpointslice-endpoints",hostname="",namespace="test",ready="true",serving="false",targetref_kind="",targetref_name="",targetref_namespace="",terminating="host"} 1
kube_endpointslice_endpoints{address="192.168.1.10",endpoint_nodename="node",endpoint_zone="west",endpointslice="test_endpointslice-endpoints",hostname="",namespace="test",ready="true",serving="false",targetref_kind="",targetref_name="",targetref_namespace="",terminating="host"} 1
`,

MetricNames: []string{
Expand Down
2 changes: 1 addition & 1 deletion internal/store/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func removeUnusedWhitespace(s string) string {
)

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.


if len(trimmedLine) > 0 {
trimmedLines = append(trimmedLines, trimmedLine)
Expand Down
2 changes: 1 addition & 1 deletion internal/store/testutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ kube_pod_container_info{container="container3",container_id="docker://ef789",ima
}

func TestRemoveUnusedWhitespace(t *testing.T) {
in := " kube_cron_job_info \n kube_pod_container_info \n kube_config_map_info "
in := "kube_cron_job_info\nkube_pod_container_info\nkube_config_map_info"

want := "kube_cron_job_info\nkube_pod_container_info\nkube_config_map_info"

Expand Down