From 00f5d1a38bcb37b8f28159b26aad6ed981ed7c76 Mon Sep 17 00:00:00 2001
From: Anand Swaminathan <aswaminathan@lyft.com>
Date: Tue, 2 Jul 2019 16:55:52 -0700
Subject: [PATCH] Set provider only if all methods are implemented (#26)

* Set provider only if all methods of interface are implemented
---
 flytestdlib/promutils/workqueue.go | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/flytestdlib/promutils/workqueue.go b/flytestdlib/promutils/workqueue.go
index 1911c0894c..f7bdd055f0 100644
--- a/flytestdlib/promutils/workqueue.go
+++ b/flytestdlib/promutils/workqueue.go
@@ -17,6 +17,8 @@ limitations under the License.
 package promutils
 
 import (
+	"fmt"
+
 	"k8s.io/client-go/util/workqueue"
 
 	"github.com/prometheus/client_golang/prometheus"
@@ -26,7 +28,14 @@ import (
 // prometheus metrics. To use this package, you just have to import it.
 
 func init() {
-	workqueue.SetProvider(prometheusMetricsProvider{})
+	var provider interface{} //nolint
+	provider = prometheusMetricsProvider{}
+	if p, casted := provider.(workqueue.MetricsProvider); casted {
+		workqueue.SetProvider(p)
+	} else {
+		// This case happens in future versions of client-go where the interface has added methods
+		fmt.Println("Warn: No metricsProvider set for the workqueue")
+	}
 }
 
 type prometheusMetricsProvider struct{}