forked from containers/common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpod_exit_policy.go
36 lines (30 loc) · 1.11 KB
/
pod_exit_policy.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
36
package config
import "fmt"
// PodExitPolicies includes the supported pod exit policies.
var PodExitPolicies = []string{string(PodExitPolicyContinue), string(PodExitPolicyStop)}
// PodExitPolicy determines a pod's exit and stop behaviour.
type PodExitPolicy string
const (
// PodExitPolicyContinue instructs the pod to continue running when the
// last container has exited.
PodExitPolicyContinue PodExitPolicy = "continue"
// PodExitPolicyStop instructs the pod to stop when the last container
// has exited.
PodExitPolicyStop = "stop"
// PodExitPolicyUnsupported implies an internal error.
// Negative for backwards compat.
PodExitPolicyUnsupported = "invalid"
defaultPodExitPolicy = PodExitPolicyContinue
)
// ParsePodExitPolicy parses the specified policy and returns an error if it is
// invalid.
func ParsePodExitPolicy(policy string) (PodExitPolicy, error) {
switch policy {
case "", string(PodExitPolicyContinue):
return PodExitPolicyContinue, nil
case string(PodExitPolicyStop):
return PodExitPolicyStop, nil
default:
return PodExitPolicyUnsupported, fmt.Errorf("invalid pod exit policy: %q", policy)
}
}