From bf49d552b003072c6bc64ae838a4699c1f4028bd Mon Sep 17 00:00:00 2001 From: Kiran Kamineni Date: Tue, 16 Apr 2019 18:09:13 -0700 Subject: Replace Kind with GroupVersionKind Kind is not unique to track resources in Kubernetes GroupVersionKind is unique. We are just using that to track our data. It is abstracted behind a couple of new types for templates and resources. This change makes a lot of the old kind based operations redundant and simplified. Issue-ID: MULTICLOUD-573 Change-Id: I8f4ded2ba6a0821a8fbd679dc99ce3a44d805524 Signed-off-by: Kiran Kamineni --- src/k8splugin/internal/app/client_test.go | 52 +++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 6 deletions(-) (limited to 'src/k8splugin/internal/app/client_test.go') diff --git a/src/k8splugin/internal/app/client_test.go b/src/k8splugin/internal/app/client_test.go index b3436431..d023fcff 100644 --- a/src/k8splugin/internal/app/client_test.go +++ b/src/k8splugin/internal/app/client_test.go @@ -20,8 +20,10 @@ import ( "testing" utils "k8splugin/internal" + "k8splugin/internal/helm" pkgerrors "github.com/pkg/errors" + "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" ) @@ -76,9 +78,21 @@ func TestCreateResources(t *testing.T) { } t.Run("Successfully delete resources", func(t *testing.T) { - data := map[string][]string{ - "Deployment": []string{"../../mock_files/mock_yamls/deployment.yaml"}, - "Service": []string{"../../mock_files/mock_yamls/service.yaml"}, + data := []helm.KubernetesResourceTemplate{ + { + GVK: schema.GroupVersionKind{ + Group: "apps", + Version: "v1", + Kind: "Deployment"}, + FilePath: "../../mock_files/mock_yamls/deployment.yaml", + }, + { + GVK: schema.GroupVersionKind{ + Group: "", + Version: "v1", + Kind: "Service"}, + FilePath: "../../mock_files/mock_yamls/service.yaml", + }, } _, err := k8.createResources(data, "testnamespace") @@ -105,9 +119,35 @@ func TestDeleteResources(t *testing.T) { } t.Run("Successfully delete resources", func(t *testing.T) { - data := map[string][]string{ - "Deployment": []string{"deployment-1", "deployment-2"}, - "Service": []string{"service-1", "service-2"}, + data := []helm.KubernetesResource{ + { + GVK: schema.GroupVersionKind{ + Group: "apps", + Version: "v1", + Kind: "Deployment"}, + Name: "deployment-1", + }, + { + GVK: schema.GroupVersionKind{ + Group: "apps", + Version: "v1", + Kind: "Deployment"}, + Name: "deployment-2", + }, + { + GVK: schema.GroupVersionKind{ + Group: "", + Version: "v1", + Kind: "Service"}, + Name: "service-1", + }, + { + GVK: schema.GroupVersionKind{ + Group: "", + Version: "v1", + Kind: "Service"}, + Name: "service-2", + }, } err := k8.deleteResources(data, "test") -- cgit 1.2.3-korg