Skip to content

Commit

Permalink
TEMP
Browse files Browse the repository at this point in the history
  • Loading branch information
jveski committed Nov 30, 2023
1 parent 7845afd commit 2222b09
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 53 deletions.
3 changes: 3 additions & 0 deletions internal/controllers/reconciliation/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
68 changes: 15 additions & 53 deletions internal/controllers/reconciliation/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -37,73 +37,35 @@ 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{
Name: "test-obj",
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)
},
},
}
Expand Down

0 comments on commit 2222b09

Please sign in to comment.