Skip to content

Commit fe6e50d

Browse files
tedyuyutedz
authored andcommitted
Use map to check for long-running request
Signed-off-by: Ted Yu <[email protected]>
1 parent 1608578 commit fe6e50d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

pkg/kubelet/server/server.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -824,15 +824,17 @@ func trimURLPath(path string) string {
824824
return parts[0]
825825
}
826826

827+
var longRunningRequestPathMap = map[string]bool{
828+
"exec": true,
829+
"attach": true,
830+
"portforward": true,
831+
"debug": true,
832+
}
833+
827834
// isLongRunningRequest determines whether the request is long-running or not.
828835
func isLongRunningRequest(path string) bool {
829-
longRunningRequestPaths := []string{"exec", "attach", "portforward", "debug"}
830-
for _, p := range longRunningRequestPaths {
831-
if p == path {
832-
return true
833-
}
834-
}
835-
return false
836+
_, ok := longRunningRequestPathMap[path]
837+
return ok
836838
}
837839

838840
// ServeHTTP responds to HTTP requests on the Kubelet.

0 commit comments

Comments
 (0)