Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to reconciler.io/dies #501

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ While `controller-runtime` focuses its testing efforts on integration testing by

The table test pattern is used to declare each test case in a test suite with the resource being reconciled, other given resources in the cluster, and all expected resource mutations (create, update, delete).

The tests make extensive use of given and mutated resources. It is recommended to use a library like [dies](https://dies.dev) to reduce boilerplate code and to highlight the delta unique to each test.
The tests make extensive use of given and mutated resources. It is recommended to use a library like [dies](https://reconciler.io/dies) to reduce boilerplate code and to highlight the delta unique to each test.

There are three test suites: for [testing reconcilers](#reconcilertests), an optimized harness for [testing sub reconcilers](#subreconcilertests), and for [testing admission webhooks](#admissionwebhooktests).

Expand Down Expand Up @@ -721,7 +721,7 @@ rts := rtesting.ReconcilerTests{
gatewayCreate,
},
ExpectStatusUpdates: []client.Object{
// example using an https://dies.dev style die to mutate the resource
// example using an https://reconciler.io/dies style die to mutate the resource
inMemoryGateway.
StatusDie(func(d *diestreamingv1alpha1.InMemoryGatewayStatusDie) {
d.ObservedGeneration(1)
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ module reconciler.io/runtime

go 1.21

toolchain go1.21.6

require (
dies.dev v0.10.1
github.com/evanphx/json-patch/v5 v5.9.0
github.com/fatih/color v1.16.0
github.com/go-logr/logr v1.4.1
Expand All @@ -17,6 +14,7 @@ require (
k8s.io/apimachinery v0.29.3
k8s.io/client-go v0.29.3
k8s.io/utils v0.0.0-20240102154912-e7106e64919e
reconciler.io/dies v0.11.0
sigs.k8s.io/controller-runtime v0.17.2
sigs.k8s.io/yaml v1.4.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dies.dev v0.10.1 h1:UKgYIrPRKPlvCA0PTBNjvQv1UxHwgzD22QKC5ByoBds=
dies.dev v0.10.1/go.mod h1:7gwWOuo9E63wlQ8xso6uLX0jcqgQQVp6X0AYe+UhAl8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
Expand Down Expand Up @@ -207,6 +205,8 @@ k8s.io/kube-openapi v0.0.0-20240126223410-2919ad4fcfec h1:iGTel2aR8vCZdxJDgmbeY0
k8s.io/kube-openapi v0.0.0-20240126223410-2919ad4fcfec/go.mod h1:Pa1PvrP7ACSkuX6I7KYomY6cmMA0Tx86waBhDUgoKPw=
k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ=
k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
reconciler.io/dies v0.11.0 h1:gfhOPxB/+V1Pqwr94krtAcQTksnYl8G4YAwDtElSzz4=
reconciler.io/dies v0.11.0/go.mod h1:jL6xrLwWP/BZm17LIH5WPnYq+//ZD/7srVBnPVHqM4Q=
sigs.k8s.io/controller-runtime v0.17.2 h1:FwHwD1CTUemg0pW2otk7/U5/i5m2ymzvOXdbeGOUvw0=
sigs.k8s.io/controller-runtime v0.17.2/go.mod h1:+MngTvIQQQhfXtwfdGw/UOQ/aIaqsYywfCINOtwMO/s=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
Expand Down
4 changes: 1 addition & 3 deletions hack/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ module reconciler.io/runtime/hack

go 1.21

toolchain go1.21.6

require (
dies.dev/diegen v0.10.1
reconciler.io/dies/diegen v0.11.0
sigs.k8s.io/controller-tools v0.14.0
)

Expand Down
4 changes: 2 additions & 2 deletions hack/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dies.dev/diegen v0.10.1 h1:bUjO7L3ALdyT6nRuntcCAfy4Vx4ny4cC8kemT/GY240=
dies.dev/diegen v0.10.1/go.mod h1:08auIh8JtE32P7wVv7IC1EmAxSRoziWLwbOiMfk8cNI=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down Expand Up @@ -128,6 +126,8 @@ k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw=
k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ=
k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
reconciler.io/dies/diegen v0.11.0 h1:mB9Z7lVqrG5Ld+9sqgpRtGEnvL86BLWxfdvcioDAFWQ=
reconciler.io/dies/diegen v0.11.0/go.mod h1:K2Y514FWyBp3R7VQk7zq8zFA6fGK2QsOBRnaShMAj4Q=
sigs.k8s.io/controller-tools v0.14.0 h1:rnNoCC5wSXlrNoBKKzL70LNJKIQKEzT6lloG6/LF73A=
sigs.k8s.io/controller-tools v0.14.0/go.mod h1:TV7uOtNNnnR72SpzhStvPkoS/U5ir0nMudrkrC4M9Sc=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
Expand Down
2 changes: 1 addition & 1 deletion hack/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
package tools

import (
_ "dies.dev/diegen"
_ "reconciler.io/dies/diegen"
_ "sigs.k8s.io/controller-tools/cmd/controller-gen"
)
2 changes: 1 addition & 1 deletion hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -o pipefail

SCRIPT_ROOT=$(cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd)
CONTROLLER_GEN="go run -modfile=${SCRIPT_ROOT}/hack/go.mod sigs.k8s.io/controller-tools/cmd/controller-gen"
DIEGEN="go run -modfile=${SCRIPT_ROOT}/hack/go.mod dies.dev/diegen"
DIEGEN="go run -modfile=${SCRIPT_ROOT}/hack/go.mod reconciler.io/dies/diegen"

( cd $SCRIPT_ROOT ; $CONTROLLER_GEN object:headerFile="./hack/boilerplate.go.txt" paths="./..." )
( cd $SCRIPT_ROOT ; $DIEGEN die:headerFile="./hack/boilerplate.go.txt" paths="./..." )
Expand Down
4 changes: 2 additions & 2 deletions internal/resources/dies/dies.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ limitations under the License.
package dies

import (
diecorev1 "dies.dev/apis/core/v1"
diemetav1 "dies.dev/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
diecorev1 "reconciler.io/dies/apis/core/v1"
diemetav1 "reconciler.io/dies/apis/meta/v1"
"reconciler.io/runtime/internal/resources"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/resources/dies/zz_generated.die.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/resources/dies/zz_generated.die_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions reconcilers/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import (
"testing"
"time"

diecorev1 "dies.dev/apis/core/v1"
diemetav1 "dies.dev/apis/meta/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
diecorev1 "reconciler.io/dies/apis/core/v1"
diemetav1 "reconciler.io/dies/apis/meta/v1"
"reconciler.io/runtime/internal/resources"
"reconciler.io/runtime/reconcilers"
rtesting "reconciler.io/runtime/testing"
Expand Down
4 changes: 2 additions & 2 deletions reconcilers/cast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import (
"fmt"
"testing"

diecorev1 "dies.dev/apis/core/v1"
diemetav1 "dies.dev/apis/meta/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
diecorev1 "reconciler.io/dies/apis/core/v1"
diemetav1 "reconciler.io/dies/apis/meta/v1"
"reconciler.io/runtime/apis"
"reconciler.io/runtime/internal/resources"
"reconciler.io/runtime/internal/resources/dies"
Expand Down
4 changes: 2 additions & 2 deletions reconcilers/child_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"testing"
"time"

diecorev1 "dies.dev/apis/core/v1"
diemetav1 "dies.dev/apis/meta/v1"
corev1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -34,6 +32,8 @@ import (
"k8s.io/apimachinery/pkg/util/validation/field"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/utils/pointer"
diecorev1 "reconciler.io/dies/apis/core/v1"
diemetav1 "reconciler.io/dies/apis/meta/v1"
"reconciler.io/runtime/apis"
"reconciler.io/runtime/internal/resources"
"reconciler.io/runtime/internal/resources/dies"
Expand Down
4 changes: 2 additions & 2 deletions reconcilers/childset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import (
"testing"
"time"

diecorev1 "dies.dev/apis/core/v1"
diemetav1 "dies.dev/apis/meta/v1"
corev1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
diecorev1 "reconciler.io/dies/apis/core/v1"
diemetav1 "reconciler.io/dies/apis/meta/v1"
"reconciler.io/runtime/apis"
"reconciler.io/runtime/internal/resources"
"reconciler.io/runtime/internal/resources/dies"
Expand Down
4 changes: 2 additions & 2 deletions reconcilers/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import (
"fmt"
"testing"

diecorev1 "dies.dev/apis/core/v1"
diemetav1 "dies.dev/apis/meta/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
diecorev1 "reconciler.io/dies/apis/core/v1"
diemetav1 "reconciler.io/dies/apis/meta/v1"
"reconciler.io/runtime/internal/resources"
"reconciler.io/runtime/internal/resources/dies"
"reconciler.io/runtime/reconcilers"
Expand Down
2 changes: 1 addition & 1 deletion reconcilers/finalizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
"testing"
"time"

diemetav1 "dies.dev/apis/meta/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
diemetav1 "reconciler.io/dies/apis/meta/v1"
"reconciler.io/runtime/internal/resources"
"reconciler.io/runtime/internal/resources/dies"
"reconciler.io/runtime/reconcilers"
Expand Down
2 changes: 1 addition & 1 deletion reconcilers/flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"testing"
"time"

diemetav1 "dies.dev/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
diemetav1 "reconciler.io/dies/apis/meta/v1"
"reconciler.io/runtime/internal/resources"
"reconciler.io/runtime/internal/resources/dies"
"reconciler.io/runtime/reconcilers"
Expand Down
2 changes: 1 addition & 1 deletion reconcilers/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import (
"testing"
"time"

diemetav1 "dies.dev/apis/meta/v1"
"github.com/google/go-cmp/cmp"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
diemetav1 "reconciler.io/dies/apis/meta/v1"
"reconciler.io/runtime/apis"
"reconciler.io/runtime/internal/resources"
"reconciler.io/runtime/internal/resources/dies"
Expand Down
2 changes: 1 addition & 1 deletion reconcilers/sequence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"testing"
"time"

diemetav1 "dies.dev/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
diemetav1 "reconciler.io/dies/apis/meta/v1"
"reconciler.io/runtime/apis"
"reconciler.io/runtime/internal/resources"
"reconciler.io/runtime/internal/resources/dies"
Expand Down
2 changes: 1 addition & 1 deletion reconcilers/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"testing"
"time"

diemetav1 "dies.dev/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
diemetav1 "reconciler.io/dies/apis/meta/v1"
"reconciler.io/runtime/apis"
"reconciler.io/runtime/internal/resources"
"reconciler.io/runtime/internal/resources/dies"
Expand Down
4 changes: 2 additions & 2 deletions reconcilers/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"net/url"
"testing"

dieadmissionv1 "dies.dev/apis/admission/v1"
diemetav1 "dies.dev/apis/meta/v1"
"github.com/google/go-cmp/cmp"
jsonpatch "gomodules.xyz/jsonpatch/v2"
admissionv1 "k8s.io/api/admission/v1"
Expand All @@ -34,6 +32,8 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
dieadmissionv1 "reconciler.io/dies/apis/admission/v1"
diemetav1 "reconciler.io/dies/apis/meta/v1"
"reconciler.io/runtime/apis"
"reconciler.io/runtime/internal/resources"
"reconciler.io/runtime/internal/resources/dies"
Expand Down
2 changes: 1 addition & 1 deletion testing/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"testing"
"time"

diemetav1 "dies.dev/apis/meta/v1"
"github.com/google/go-cmp/cmp"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -32,6 +31,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
diemetav1 "reconciler.io/dies/apis/meta/v1"
"reconciler.io/runtime/internal/resources"
"reconciler.io/runtime/internal/resources/dies"
"reconciler.io/runtime/reconcilers"
Expand Down
Loading