Skip to content

Commit 384939f

Browse files
committed
WIP: drop routeclient from reconciler
Change the code to use the runtime client so we can drop some vendor dependencies.
1 parent d488f1b commit 384939f

File tree

306 files changed

+35
-19390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

306 files changed

+35
-19390
lines changed

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ require (
1313
github.com/onsi/ginkgo/v2 v2.25.2
1414
github.com/onsi/gomega v1.38.2
1515
github.com/openshift/api v3.9.1-0.20190916204813-cdbe64fb0c91+incompatible
16-
github.com/openshift/client-go v0.0.0-20240115204758-e6bf7d631d5e // release-4.16
1716
github.com/operator-framework/api v0.33.0
1817
github.com/segmentio/analytics-go/v3 v3.3.0
1918
go.uber.org/mock v0.6.0
@@ -194,7 +193,6 @@ replace (
194193
// Usually not needed unless we have newer k8s.io deps and argocd still uses an old gitops-engine
195194
// github.com/argoproj/gitops-engine => github.com/argoproj/gitops-engine v0.0.0-20240905010810-bd7681ae3f8b
196195
github.com/openshift/api => github.com/openshift/api v0.0.0-20240124164020-e2ce40831f2e
197-
github.com/openshift/client-go => github.com/openshift/client-go v0.0.0-20240115204758-e6bf7d631d5e
198196
// Caused by Argo importing 'k8s.io/api'
199197
// Override all the v0.0.0 entries
200198
k8s.io/api => k8s.io/api v0.33.4

go.sum

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8=
66
dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA=
77
github.com/42wim/httpsig v1.2.3 h1:xb0YyWhkYj57SPtfSttIobJUPJZB9as1nsfo7KWVcEs=
88
github.com/42wim/httpsig v1.2.3/go.mod h1:nZq9OlYKDrUBhptd77IHx4/sZZD+IxTBADvAPI9G/EM=
9-
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 h1:He8afgbRMd7mFxO99hRNu+6tazq8nFF9lIwo9JFroBk=
10-
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
9+
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU=
10+
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
1111
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 h1:Gt0j3wceWMwPmiazCa8MzMA0MfhmPIz0Qp0FJ6qcM0U=
1212
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0/go.mod h1:Ot/6aikWnKWi4l9QB7qVSwa8iMphQNqkWALMoNT3rzM=
1313
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.0 h1:j8BorDEigD8UFOSZQiSqAMOOleyQOOQPnUAwV+Ls1gA=
@@ -325,12 +325,8 @@ github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJw
325325
github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M=
326326
github.com/openshift/api v0.0.0-20240124164020-e2ce40831f2e h1:cxgCNo/R769CO23AK5TCh45H9SMUGZ8RukiF2/Qif3o=
327327
github.com/openshift/api v0.0.0-20240124164020-e2ce40831f2e/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
328-
github.com/openshift/client-go v0.0.0-20240115204758-e6bf7d631d5e h1:qGjfKX8i0h4efMNEnhgTdxcdx6gwwOwhTfBJ20WFqA8=
329-
github.com/openshift/client-go v0.0.0-20240115204758-e6bf7d631d5e/go.mod h1:2am3qrggh9LlDCf/MDGzcFWMhdaushxFQi0+ZZDhdVk=
330328
github.com/operator-framework/api v0.33.0 h1:Tdu9doXz6Key2riIiP3/JPahHEgFBXAqyWQN4kOITS8=
331329
github.com/operator-framework/api v0.33.0/go.mod h1:sEh1VqwQCJUj+l/rKNWPDEJdFNAbdTu8QcM+x+wdYYo=
332-
github.com/operator-framework/operator-lifecycle-manager v0.33.0 h1:KFBrln/E0itngxLNgP5CGQQoTf9whtudrLnZsxS2Ey4=
333-
github.com/operator-framework/operator-lifecycle-manager v0.33.0/go.mod h1:FsL9ACmFMFfDIA/Y20ECuiT49d6gVFfcdebReqtIWyM=
334330
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
335331
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
336332
github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI=
@@ -559,8 +555,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
559555
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
560556
gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw=
561557
gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
562-
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 h1:rHWScKit0gvAPuOnu87KpaYtjK5zBMLcULh7gxkCXu4=
563-
google.golang.org/genproto v0.0.0-20250603155806-513f23925822/go.mod h1:HubltRL7rMh0LfnQPkMH4NPDFEWp0jw3vixw7jEM53s=
558+
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 h1:9+tzLLstTlPTRyJTh+ah5wIMsBW5c4tQwGTN3thOW9Y=
559+
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:mqHbVIp48Muh7Ywss/AD6I5kNVKZMmAa/QEW58Gxp2s=
564560
google.golang.org/genproto/googleapis/api v0.0.0-20250707201910-8d1bb00bc6a7 h1:FiusG7LWj+4byqhbvmB+Q93B/mOxJLN2DTozDuZm4EU=
565561
google.golang.org/genproto/googleapis/api v0.0.0-20250707201910-8d1bb00bc6a7/go.mod h1:kXqgZtrWaf6qS3jZOCnCH7WYfrvFjkC51bM8fz3RsCA=
566562
google.golang.org/genproto/googleapis/rpc v0.0.0-20250826171959-ef028d996bc1 h1:pmJpJEvT846VzausCQ5d7KreSROcDqmO388w5YbnltA=

internal/controller/kube.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import (
2020
"context"
2121
"fmt"
2222

23-
routeclient "github.com/openshift/client-go/route/clientset/versioned"
2423
v1 "k8s.io/api/core/v1"
2524
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2625

26+
routev1 "github.com/openshift/api/route/v1"
2727
"k8s.io/apimachinery/pkg/runtime/schema"
2828
"k8s.io/apimachinery/pkg/types"
2929
kubeclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -84,8 +84,10 @@ func referSameObject(a, b *metav1.OwnerReference) bool {
8484
return aGV.Version == bGV.Version && aGV.Group == bGV.Group && a.Kind == b.Kind && a.Name == b.Name && a.UID == b.UID
8585
}
8686

87-
func getRoute(routeClient routeclient.Interface, routeName, namespace string) (string, error) {
88-
route, err := routeClient.RouteV1().Routes(namespace).Get(context.Background(), routeName, metav1.GetOptions{})
87+
func getRoute(cl kubeclient.Client, routeName, namespace string) (string, error) {
88+
route := routev1.Route{}
89+
90+
err := cl.Get(context.Background(), types.NamespacedName{Name: routeName, Namespace: namespace}, &route)
8991
if err != nil {
9092
return "", err
9193
}

internal/controller/kube_test.go

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66

77
routev1 "github.com/openshift/api/route/v1"
8-
routefake "github.com/openshift/client-go/route/clientset/versioned/fake"
98
v1 "k8s.io/api/core/v1"
109
"k8s.io/apimachinery/pkg/api/errors"
1110
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -498,20 +497,19 @@ var _ = Describe("ObjectYaml", func() {
498497

499498
var _ = Describe("GetRoute", func() {
500499
var (
501-
routeClient *routefake.Clientset
502-
namespace string
503-
routeName string
500+
fakeClient client.Client
501+
namespace string
502+
routeName string
504503
)
505504

506505
BeforeEach(func() {
507-
routeClient = routefake.NewSimpleClientset()
508506
namespace = "default"
509507
routeName = "test-route"
510508
})
511509

512510
Context("when the route exists", func() {
513-
BeforeEach(func() {
514-
route := &routev1.Route{
511+
It("should return the URL of the route", func() {
512+
route := routev1.Route{
515513
ObjectMeta: metav1.ObjectMeta{
516514
Name: routeName,
517515
Namespace: namespace,
@@ -524,40 +522,41 @@ var _ = Describe("GetRoute", func() {
524522
},
525523
},
526524
}
527-
_, err := routeClient.RouteV1().Routes(namespace).Create(context.Background(), route, metav1.CreateOptions{})
528-
Expect(err).ToNot(HaveOccurred())
529-
})
530525

531-
It("should return the URL of the route", func() {
532-
url, err := getRoute(routeClient, routeName, namespace)
526+
fakeClient = fake.NewClientBuilder().WithScheme(testEnv.Scheme).
527+
WithRuntimeObjects(&route).Build()
528+
529+
url, err := getRoute(fakeClient, routeName, namespace)
533530
Expect(err).ToNot(HaveOccurred())
534531
Expect(url).To(Equal("https://example.com"))
535532
})
536533
})
537534

538535
Context("when the route does not exist", func() {
539536
It("should return an error", func() {
540-
url, err := getRoute(routeClient, routeName, namespace)
537+
fakeClient = fake.NewClientBuilder().WithScheme(testEnv.Scheme).
538+
WithRuntimeObjects().Build()
539+
540+
url, err := getRoute(fakeClient, routeName, namespace)
541541
Expect(err).To(HaveOccurred())
542542
Expect(url).To(BeEmpty())
543543
})
544544
})
545545

546546
Context("when the route has no ingress", func() {
547-
BeforeEach(func() {
548-
route := &routev1.Route{
547+
It("should return an error", func() {
548+
route := routev1.Route{
549549
ObjectMeta: metav1.ObjectMeta{
550550
Name: routeName,
551551
Namespace: namespace,
552552
},
553553
Status: routev1.RouteStatus{},
554554
}
555-
_, err := routeClient.RouteV1().Routes(namespace).Create(context.Background(), route, metav1.CreateOptions{})
556-
Expect(err).ToNot(HaveOccurred())
557-
})
558555

559-
It("should return an error", func() {
560-
url, err := getRoute(routeClient, routeName, namespace)
556+
fakeClient = fake.NewClientBuilder().WithScheme(testEnv.Scheme).
557+
WithRuntimeObjects(&route).Build()
558+
559+
url, err := getRoute(fakeClient, routeName, namespace)
561560
Expect(err).To(HaveOccurred())
562561
Expect(url).To(BeEmpty())
563562
})

internal/controller/pattern_controller.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import (
4141

4242
argoapi "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
4343
v1 "github.com/openshift/api/config/v1"
44-
routeclient "github.com/openshift/client-go/route/clientset/versioned"
4544
corev1 "k8s.io/api/core/v1"
4645

4746
api "github.com/hybrid-cloud-patterns/patterns-operator/api/v1alpha1"
@@ -58,7 +57,6 @@ type PatternReconciler struct {
5857
logger logr.Logger
5958

6059
config *rest.Config
61-
routeClient routeclient.Interface
6260
driftWatcher driftWatcher
6361
gitOperations GitOperations
6462
giteaOperations GiteaOperations
@@ -356,7 +354,7 @@ func (r *PatternReconciler) createGiteaInstance(input *api.Pattern) error {
356354

357355
// Here we need to call the gitea migration bits
358356
// Let's get the GiteaServer route
359-
giteaRouteURL, routeErr := getRoute(r.routeClient, GiteaRouteName, GiteaNamespace)
357+
giteaRouteURL, routeErr := getRoute(r.Client, GiteaRouteName, GiteaNamespace)
360358
if routeErr != nil {
361359
return fmt.Errorf("GiteaServer route not ready: %v", routeErr)
362360
}
@@ -589,12 +587,8 @@ func (r *PatternReconciler) finalizeObject(instance *api.Pattern) error {
589587

590588
// SetupWithManager sets up the controller with the Manager.
591589
func (r *PatternReconciler) SetupWithManager(mgr ctrl.Manager) error {
592-
var err error
593590
r.config = mgr.GetConfig()
594591

595-
if r.routeClient, err = routeclient.NewForConfig(r.config); err != nil {
596-
return err
597-
}
598592
r.driftWatcher, _ = newDriftWatcher(r.Client, mgr.GetLogger(), newGitClient())
599593
r.gitOperations = &GitOperationsImpl{}
600594
r.giteaOperations = &GiteaOperationsImpl{}

internal/controller/suite_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
. "github.com/onsi/gomega"
2929
apiv1 "github.com/openshift/api/config/v1"
3030
operatorv1 "github.com/openshift/api/operator/v1"
31+
routev1 "github.com/openshift/api/route/v1"
3132
operatorv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
3233

3334
"k8s.io/client-go/kubernetes/scheme"
@@ -85,6 +86,8 @@ var _ = BeforeSuite(func() {
8586
Expect(err).NotTo(HaveOccurred())
8687
err = operatorv1alpha1.AddToScheme(scheme.Scheme)
8788
Expect(err).NotTo(HaveOccurred())
89+
err = routev1.AddToScheme(scheme.Scheme)
90+
Expect(err).NotTo(HaveOccurred())
8891
//+kubebuilder:scaffold:scheme
8992

9093
k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})

vendor/github.com/argoproj/argo-cd/v3/pkg/client/clientset/versioned/clientset.go

Lines changed: 0 additions & 104 deletions
This file was deleted.

vendor/github.com/argoproj/argo-cd/v3/pkg/client/clientset/versioned/fake/clientset_generated.go

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)