Repository: Azure/ARO-RP
Pull request #1538 (2021-06-09 14:19:07)

Consolidates two go-cmp wrappers into one
### What this PR does / why we need it:

Just a clean up

### Test plan for issue:

CI will run unit tests

### Is there any documentation that needs to be updated for this PR?

No, it is refactoring/clean up.



Patch:
diff --git a/pkg/util/cmp/cmp.go b/pkg/util/cmp/cmp.go
index 20ca90668..8465a27da 100644
--- a/pkg/util/cmp/cmp.go
+++ b/pkg/util/cmp/cmp.go
@@ -8,6 +8,8 @@ import (
 	"math/big"
 
 	"github.com/google/go-cmp/cmp"
+
+	"github.com/Azure/ARO-RP/pkg/api"
 )
 
 // Diff is a wrapper for github.com/google/go-cmp/cmp.Diff with extra options
@@ -17,6 +19,7 @@ func Diff(x, y interface{}, opts ...cmp.Option) string {
 		// FIXME: Remove x509CertComparer after upgrading to a Go version that includes https://github.com/golang/go/issues/28743
 		cmp.Comparer(x509CertComparer),
 		cmp.Comparer(bigIntComparer),
+		cmp.AllowUnexported(api.MissingFields{}),
 	)
 
 	return cmp.Diff(x, y, newOpts...)


Test patch:
diff --git a/pkg/util/clusterdata/cluster_service_principal_task_test.go b/pkg/util/clusterdata/cluster_service_principal_task_test.go
index 308bcfbe2..2097d9ff5 100644
--- a/pkg/util/clusterdata/cluster_service_principal_task_test.go
+++ b/pkg/util/clusterdata/cluster_service_principal_task_test.go
@@ -15,7 +15,7 @@ import (
 	"k8s.io/client-go/kubernetes/fake"
 
 	"github.com/Azure/ARO-RP/pkg/api"
-	"github.com/Azure/ARO-RP/test/util/cmp"
+	"github.com/Azure/ARO-RP/pkg/util/cmp"
 )
 
 func TestClusterServidePrincipalEnricherTask(t *testing.T) {
diff --git a/pkg/util/clusterdata/cluster_version_task_test.go b/pkg/util/clusterdata/cluster_version_task_test.go
index 9e1faaa43..6777083ed 100644
--- a/pkg/util/clusterdata/cluster_version_task_test.go
+++ b/pkg/util/clusterdata/cluster_version_task_test.go
@@ -15,7 +15,7 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
 	"github.com/Azure/ARO-RP/pkg/api"
-	"github.com/Azure/ARO-RP/test/util/cmp"
+	"github.com/Azure/ARO-RP/pkg/util/cmp"
 )
 
 func TestClusterVersionEnricherTask(t *testing.T) {
diff --git a/pkg/util/clusterdata/clusterdata_test.go b/pkg/util/clusterdata/clusterdata_test.go
index f935271fa..83e668520 100644
--- a/pkg/util/clusterdata/clusterdata_test.go
+++ b/pkg/util/clusterdata/clusterdata_test.go
@@ -17,7 +17,7 @@ import (
 	"github.com/Azure/ARO-RP/pkg/api"
 	"github.com/Azure/ARO-RP/pkg/metrics/noop"
 	"github.com/Azure/ARO-RP/pkg/proxy"
-	"github.com/Azure/ARO-RP/test/util/cmp"
+	"github.com/Azure/ARO-RP/pkg/util/cmp"
 )
 
 func TestBestEffortEnricher(t *testing.T) {
diff --git a/pkg/util/clusterdata/ingress_profiles_task_test.go b/pkg/util/clusterdata/ingress_profiles_task_test.go
index 70ef49652..7e86e848b 100644
--- a/pkg/util/clusterdata/ingress_profiles_task_test.go
+++ b/pkg/util/clusterdata/ingress_profiles_task_test.go
@@ -18,7 +18,7 @@ import (
 	"k8s.io/client-go/kubernetes/fake"
 
 	"github.com/Azure/ARO-RP/pkg/api"
-	"github.com/Azure/ARO-RP/test/util/cmp"
+	"github.com/Azure/ARO-RP/pkg/util/cmp"
 )
 
 func TestIngressProfilesEnricherTask(t *testing.T) {
diff --git a/pkg/util/clusterdata/worker_profiles_task_test.go b/pkg/util/clusterdata/worker_profiles_task_test.go
index 316ea59f8..e97a3e105 100644
--- a/pkg/util/clusterdata/worker_profiles_task_test.go
+++ b/pkg/util/clusterdata/worker_profiles_task_test.go
@@ -20,7 +20,7 @@ import (
 	ktesting "k8s.io/client-go/testing"
 
 	"github.com/Azure/ARO-RP/pkg/api"
-	"github.com/Azure/ARO-RP/test/util/cmp"
+	"github.com/Azure/ARO-RP/pkg/util/cmp"
 )
 
 func TestWorkerProfilesEnricherTask(t *testing.T) {
diff --git a/pkg/util/dynamichelper/discovery/cache_fallback_discovery_client_test.go b/pkg/util/dynamichelper/discovery/cache_fallback_discovery_client_test.go
index 115c475b8..347a06ffe 100644
--- a/pkg/util/dynamichelper/discovery/cache_fallback_discovery_client_test.go
+++ b/pkg/util/dynamichelper/discovery/cache_fallback_discovery_client_test.go
@@ -16,9 +16,9 @@ import (
 	"k8s.io/client-go/discovery"
 	"k8s.io/client-go/rest"
 
+	"github.com/Azure/ARO-RP/pkg/util/cmp"
 	utillog "github.com/Azure/ARO-RP/pkg/util/log"
 	"github.com/Azure/ARO-RP/pkg/util/version"
-	"github.com/Azure/ARO-RP/test/util/cmp"
 )
 
 // TestVersion makes sure that bindata contains cache generated with the
diff --git a/pkg/util/version/stream_test.go b/pkg/util/version/stream_test.go
index 3e8cb4153..5f2def1f3 100644
--- a/pkg/util/version/stream_test.go
+++ b/pkg/util/version/stream_test.go
@@ -8,7 +8,7 @@ import (
 	"reflect"
 	"testing"
 
-	"github.com/Azure/ARO-RP/test/util/cmp"
+	"github.com/Azure/ARO-RP/pkg/util/cmp"
 )
 
 func TestOpenShiftVersions(t *testing.T) {
diff --git a/test/util/cmp/cmp.go b/test/util/cmp/cmp.go
deleted file mode 100644
index 1d22211d0..000000000
--- a/test/util/cmp/cmp.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package cmp
-
-// Copyright (c) Microsoft Corporation.
-// Licensed under the Apache License 2.0.
-
-import (
-	"github.com/google/go-cmp/cmp"
-
-	"github.com/Azure/ARO-RP/pkg/api"
-)
-
-// Diff is a wrapper for github.com/google/go-cmp/cmp.Diff with extra options
-func Diff(x, y interface{}, opts ...cmp.Option) string {
-	newOpts := append(
-		opts,
-		cmp.AllowUnexported(api.MissingFields{}),
-	)
-
-	return cmp.Diff(x, y, newOpts...)
-}