summaryrefslogtreecommitdiffhomepage
path: root/pkg/refs
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-08-27 03:27:43 +0000
committergVisor bot <gvisor-bot@google.com>2020-08-27 03:27:43 +0000
commitd27124946910f6025ce8f248831e8c356579a6c2 (patch)
tree6ed37bb2e84981b40708a8604e46130b8fb14040 /pkg/refs
parent6f5bd2d5be4fe63533bee65ba0fa767a08bc3c3f (diff)
parent32e7a54f7f413ba83af8217b9bc0a367e3c30f94 (diff)
Merge release-20200818.0-66-g32e7a54f7 (automated)
Diffstat (limited to 'pkg/refs')
-rw-r--r--pkg/refs/refcounter.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/pkg/refs/refcounter.go b/pkg/refs/refcounter.go
index d9d5e6bcb..57d8542b9 100644
--- a/pkg/refs/refcounter.go
+++ b/pkg/refs/refcounter.go
@@ -234,6 +234,39 @@ const (
LeaksLogTraces
)
+// Set implements flag.Value.
+func (l *LeakMode) Set(v string) error {
+ switch v {
+ case "disabled":
+ *l = NoLeakChecking
+ case "log-names":
+ *l = LeaksLogWarning
+ case "log-traces":
+ *l = LeaksLogTraces
+ default:
+ return fmt.Errorf("invalid ref leak mode %q", v)
+ }
+ return nil
+}
+
+// Get implements flag.Value.
+func (l *LeakMode) Get() interface{} {
+ return *l
+}
+
+// String implements flag.Value.
+func (l *LeakMode) String() string {
+ switch *l {
+ case NoLeakChecking:
+ return "disabled"
+ case LeaksLogWarning:
+ return "log-names"
+ case LeaksLogTraces:
+ return "log-traces"
+ }
+ panic(fmt.Sprintf("invalid ref leak mode %q", *l))
+}
+
// leakMode stores the current mode for the reference leak checker.
//
// Values must be one of the LeakMode values.