From 1eed5a13adbcafc50b41291fda63ae7395b8a7b1 Mon Sep 17 00:00:00 2001 From: Pooneh Mortazavi Date: Thu, 29 Oct 2020 12:29:00 -0700 Subject: [PATCH] Fix kind on GameServerAllocation converter --- pkg/allocation/converters/converter.go | 5 +---- pkg/allocation/converters/converter_test.go | 24 ++++++++++----------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/pkg/allocation/converters/converter.go b/pkg/allocation/converters/converter.go index 26cc576538..1e78a2f41a 100644 --- a/pkg/allocation/converters/converter.go +++ b/pkg/allocation/converters/converter.go @@ -171,10 +171,6 @@ func ConvertAllocationResponseToGSA(in *pb.AllocationResponse) *allocationv1.Gam } out := &allocationv1.GameServerAllocation{ - TypeMeta: metav1.TypeMeta{ - Kind: allocationv1.SchemeGroupVersion.Group, - APIVersion: allocationv1.SchemeGroupVersion.Version, - }, Status: allocationv1.GameServerAllocationStatus{ State: allocationv1.GameServerAllocationAllocated, GameServerName: in.GameServerName, @@ -183,6 +179,7 @@ func ConvertAllocationResponseToGSA(in *pb.AllocationResponse) *allocationv1.Gam Ports: convertAllocationPortsToGSAAgonesPorts(in.Ports), }, } + out.SetGroupVersionKind(allocationv1.SchemeGroupVersion.WithKind("GameServerAllocation")) return out } diff --git a/pkg/allocation/converters/converter_test.go b/pkg/allocation/converters/converter_test.go index 7d06c21363..a6cb4d9811 100644 --- a/pkg/allocation/converters/converter_test.go +++ b/pkg/allocation/converters/converter_test.go @@ -232,8 +232,8 @@ func TestConvertGSAToAllocationResponse(t *testing.T) { name: "status state is set to allocated", in: &allocationv1.GameServerAllocation{ TypeMeta: metav1.TypeMeta{ - Kind: "allocation.agones.dev", - APIVersion: "v1", + Kind: "GameServerAllocation", + APIVersion: "allocation.agones.dev/v1", }, Status: allocationv1.GameServerAllocationStatus{ State: allocationv1.GameServerAllocationAllocated, @@ -268,8 +268,8 @@ func TestConvertGSAToAllocationResponse(t *testing.T) { name: "status field is set to unallocated", in: &allocationv1.GameServerAllocation{ TypeMeta: metav1.TypeMeta{ - Kind: "allocation.agones.dev", - APIVersion: "v1", + Kind: "GameServerAllocation", + APIVersion: "allocation.agones.dev/v1", }, Status: allocationv1.GameServerAllocationStatus{ State: allocationv1.GameServerAllocationUnAllocated, @@ -293,8 +293,8 @@ func TestConvertGSAToAllocationResponse(t *testing.T) { name: "status state is set to contention", in: &allocationv1.GameServerAllocation{ TypeMeta: metav1.TypeMeta{ - Kind: "allocation.agones.dev", - APIVersion: "v1", + Kind: "GameServerAllocation", + APIVersion: "allocation.agones.dev/v1", }, Status: allocationv1.GameServerAllocationStatus{ State: allocationv1.GameServerAllocationContention, @@ -307,8 +307,8 @@ func TestConvertGSAToAllocationResponse(t *testing.T) { name: "Empty fields", in: &allocationv1.GameServerAllocation{ TypeMeta: metav1.TypeMeta{ - Kind: "allocation.agones.dev", - APIVersion: "v1", + Kind: "GameServerAllocation", + APIVersion: "allocation.agones.dev/v1", }, Status: allocationv1.GameServerAllocationStatus{ Ports: []agonesv1.GameServerStatusPort{}, @@ -321,8 +321,8 @@ func TestConvertGSAToAllocationResponse(t *testing.T) { name: "Empty objects", in: &allocationv1.GameServerAllocation{ TypeMeta: metav1.TypeMeta{ - Kind: "allocation.agones.dev", - APIVersion: "v1", + Kind: "GameServerAllocation", + APIVersion: "allocation.agones.dev/v1", }, Status: allocationv1.GameServerAllocationStatus{ State: allocationv1.GameServerAllocationAllocated, @@ -376,8 +376,8 @@ func TestConvertAllocationResponseToGSA(t *testing.T) { }, want: &allocationv1.GameServerAllocation{ TypeMeta: metav1.TypeMeta{ - Kind: "allocation.agones.dev", - APIVersion: "v1", + Kind: "GameServerAllocation", + APIVersion: "allocation.agones.dev/v1", }, Status: allocationv1.GameServerAllocationStatus{ State: allocationv1.GameServerAllocationAllocated,