diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-08-27 03:27:43 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-08-27 03:27:43 +0000 |
commit | d27124946910f6025ce8f248831e8c356579a6c2 (patch) | |
tree | 6ed37bb2e84981b40708a8604e46130b8fb14040 /pkg/sentry/watchdog | |
parent | 6f5bd2d5be4fe63533bee65ba0fa767a08bc3c3f (diff) | |
parent | 32e7a54f7f413ba83af8217b9bc0a367e3c30f94 (diff) |
Merge release-20200818.0-66-g32e7a54f7 (automated)
Diffstat (limited to 'pkg/sentry/watchdog')
-rw-r--r-- | pkg/sentry/watchdog/watchdog.go | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/pkg/sentry/watchdog/watchdog.go b/pkg/sentry/watchdog/watchdog.go index 748273366..bbafb8b7f 100644 --- a/pkg/sentry/watchdog/watchdog.go +++ b/pkg/sentry/watchdog/watchdog.go @@ -96,15 +96,33 @@ const ( Panic ) +// Set implements flag.Value. +func (a *Action) Set(v string) error { + switch v { + case "log", "logwarning": + *a = LogWarning + case "panic": + *a = Panic + default: + return fmt.Errorf("invalid watchdog action %q", v) + } + return nil +} + +// Get implements flag.Value. +func (a *Action) Get() interface{} { + return *a +} + // String returns Action's string representation. -func (a Action) String() string { - switch a { +func (a *Action) String() string { + switch *a { case LogWarning: - return "LogWarning" + return "logWarning" case Panic: - return "Panic" + return "panic" default: - panic(fmt.Sprintf("Invalid action: %d", a)) + panic(fmt.Sprintf("Invalid watchdog action: %d", *a)) } } |