mirror of
https://github.com/containers/podman.git
synced 2025-08-06 11:32:07 +08:00
Add support for updating restart policy
This is something Docker does, and we did not do until now. Most difficult/annoying part was the REST API, where I did not really want to modify the struct being sent, so I made the new restart policy parameters query parameters instead. Testing was also a bit annoying, because testing restart policy always is. Signed-off-by: Matt Heon <mheon@redhat.com>
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
package define
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Valid restart policy types.
|
||||
const (
|
||||
// RestartPolicyNone indicates that no restart policy has been requested
|
||||
@ -27,6 +31,16 @@ var RestartPolicyMap = map[string]string{
|
||||
RestartPolicyUnlessStopped: RestartPolicyUnlessStopped,
|
||||
}
|
||||
|
||||
// Validate that the given string is a valid restart policy.
|
||||
func ValidateRestartPolicy(policy string) error {
|
||||
switch policy {
|
||||
case RestartPolicyNone, RestartPolicyNo, RestartPolicyOnFailure, RestartPolicyAlways, RestartPolicyUnlessStopped:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("%q is not a valid restart policy: %w", policy, ErrInvalidArg)
|
||||
}
|
||||
}
|
||||
|
||||
// InitContainerTypes
|
||||
const (
|
||||
// AlwaysInitContainer is an init container that runs on each
|
||||
|
Reference in New Issue
Block a user