-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
pod_cleanup_key.go
35 lines (29 loc) · 979 Bytes
/
pod_cleanup_key.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package controller
import (
"fmt"
"strings"
)
// Should I use "clean-up" or "cleanup"?
// * cleanup is a noun - e.g "The cleanup"
// * clean-up is a verb - e.g. "I clean-up"
type (
podCleanupKey = string // describes the pod to cleanup + the cleanup action to take
podCleanupAction = string
)
const (
deletePod podCleanupAction = "deletePod"
shutdownPod podCleanupAction = "shutdownPod"
labelPodCompleted podCleanupAction = "labelPodCompleted"
terminateContainers podCleanupAction = "terminateContainers"
killContainers podCleanupAction = "killContainers"
)
func newPodCleanupKey(namespace string, podName string, action podCleanupAction) podCleanupKey {
return fmt.Sprintf("%s/%s/%v", namespace, podName, action)
}
func parsePodCleanupKey(k podCleanupKey) (namespace string, podName string, action podCleanupAction) {
parts := strings.Split(k, "/")
if len(parts) != 3 {
return "", "", ""
}
return parts[0], parts[1], parts[2]
}