From 2222b096d5fc7fa4deaf5985c340dfb696284a96 Mon Sep 17 00:00:00 2001 From: Jordan Olshevski Date: Thu, 30 Nov 2023 12:22:16 -0600 Subject: [PATCH] TEMP --- .../controllers/reconciliation/controller.go | 3 + .../reconciliation/controller_test.go | 68 ++++--------------- 2 files changed, 18 insertions(+), 53 deletions(-) diff --git a/internal/controllers/reconciliation/controller.go b/internal/controllers/reconciliation/controller.go index efc80ec2..96e557dd 100644 --- a/internal/controllers/reconciliation/controller.go +++ b/internal/controllers/reconciliation/controller.go @@ -18,6 +18,8 @@ import ( "github.com/go-logr/logr" ) +// TODO: Minimal retries for validation error + type Controller struct { client client.Client resourceClient reconstitution.Client @@ -172,6 +174,7 @@ func (c *Controller) buildPatch(ctx context.Context, prev, resource *reconstitut return jsonmergepatch.CreateThreeWayJSONMergePatch([]byte(prevManifest), []byte(resource.Manifest), currentJS) } + println("TODO PREV", string(prevManifest)) patchmeta := strategicpatch.NewPatchMetaFromOpenAPI(model) return strategicpatch.CreateThreeWayMergePatch([]byte(prevManifest), []byte(resource.Manifest), currentJS, patchmeta, true) } diff --git a/internal/controllers/reconciliation/controller_test.go b/internal/controllers/reconciliation/controller_test.go index 20dcb2a6..364b58e3 100644 --- a/internal/controllers/reconciliation/controller_test.go +++ b/internal/controllers/reconciliation/controller_test.go @@ -20,7 +20,7 @@ import ( "github.com/Azure/eno/internal/testutil" ) -// TODO: Fix, add CR test +// TODO: Add CR test func TestControllerBasics(t *testing.T) { tests := []struct { @@ -37,36 +37,17 @@ func TestControllerBasics(t *testing.T) { Namespace: "default", }, Spec: corev1.ServiceSpec{ - Type: corev1.ServiceTypeNodePort, - Ports: []corev1.ServicePort{ - { - Name: "port-1", - Port: 1, - NodePort: 30010, - }, - { - Name: "port-2", - Port: 2, - NodePort: 30020, - }, - }, + Ports: []corev1.ServicePort{{ + Name: "test", + Port: 1234, + }}, + Selector: map[string]string{"foo": "bar"}, }, }, AssertCreated: func(t *testing.T, obj client.Object) { - expected := []corev1.ServicePort{ - { - Name: "port-1", - Port: 1, - NodePort: 30010, - }, - { - Name: "port-2", - Port: 2, - NodePort: 30020, - }, - } + // TODO svc := obj.(*corev1.Service) - assert.Equal(t, expected, svc.Spec.Ports) + assert.Equal(t, nil, svc.Spec) }, Updated: &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -74,36 +55,17 @@ func TestControllerBasics(t *testing.T) { Namespace: "default", }, Spec: corev1.ServiceSpec{ - Type: corev1.ServiceTypeNodePort, - Ports: []corev1.ServicePort{ - { - Name: "port-1", - Port: 1, - NodePort: 30010, - }, - { - Name: "port-2", - Port: 2, - NodePort: 30021, // updated - }, - }, + Ports: []corev1.ServicePort{{ + Name: "test", + Port: 1234, + }}, + Selector: map[string]string{"bar": "baz"}, }, }, AssertUpdated: func(t *testing.T, obj client.Object) { - expected := []corev1.ServicePort{ - { - Name: "port-1", - Port: 1, - NodePort: 30010, - }, - { - Name: "port-2", - Port: 2, - NodePort: 30021, - }, - } + // TODO svc := obj.(*corev1.Service) - assert.Equal(t, expected, svc.Spec.Ports) + assert.Equal(t, nil, svc.Spec) }, }, }