Skip to content

Commit 5191eac

Browse files
Copilotalikhil
andcommitted
refactor: extract node role label prefix as constant
Co-authored-by: alikhil <7482065+alikhil@users.noreply.github.com>
1 parent eae996e commit 5191eac

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

pkg/handlers/columns.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222

2323
const defaultReplicaCount = int32(1)
2424

25+
const nodeRoleLabelPrefix = "node-role.kubernetes.io/"
26+
2527
func labelToColumnHeader(label string) string {
2628
parts := strings.Split(label, "/")
2729
//nolint:mnd // common case to have prefix with slash
@@ -333,8 +335,8 @@ func getNodeStatus(node *v1.Node) string {
333335
func getNodeRoles(node *v1.Node) string {
334336
var roles []string
335337
for key := range node.Labels {
336-
if strings.HasPrefix(key, "node-role.kubernetes.io/") {
337-
role := strings.TrimPrefix(key, "node-role.kubernetes.io/")
338+
if strings.HasPrefix(key, nodeRoleLabelPrefix) {
339+
role := strings.TrimPrefix(key, nodeRoleLabelPrefix)
338340
if role != "" {
339341
roles = append(roles, role)
340342
}

0 commit comments

Comments
 (0)