You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2026/10/08 14:56:39 UTC
(camel-k) 05/19: Fix #5935: Use context client instead of internal clientset in ArkMQ binding
This is an automated email from the ASF dual-hosted git repository.
squakez pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit d7cf8f2f04d2d35a9ba166eeeeafa5231d019a88
Author: Keerthan <po...@gmail.com>
AuthorDate: Wed Sep 23 21:46:05 2026 +0530
Fix #5935: Use context client instead of internal clientset in ArkMQ binding
---
.../arkmq/clientset/internalclientset/clientset.go | 121 ---------------------
.../internalclientset/fake/clientset_generated.go | 102 -----------------
.../arkmq/clientset/internalclientset/fake/doc.go | 21 ----
.../clientset/internalclientset/fake/register.go | 57 ----------
.../clientset/internalclientset/scheme/doc.go | 21 ----
.../clientset/internalclientset/scheme/register.go | 57 ----------
.../typed/arkmq/v1beta1/activemqartemis.go | 63 -----------
.../typed/arkmq/v1beta1/activemqartemisaddress.go | 63 -----------
.../typed/arkmq/v1beta1/arkmq_client.go | 107 ------------------
.../internalclientset/typed/arkmq/v1beta1/doc.go | 21 ----
.../typed/arkmq/v1beta1/fake/doc.go | 21 ----
.../arkmq/v1beta1/fake/fake_activemqartemis.go | 53 ---------
.../v1beta1/fake/fake_activemqartemisaddress.go | 53 ---------
.../typed/arkmq/v1beta1/fake/fake_arkmq_client.go | 45 --------
.../typed/arkmq/v1beta1/generated_expansion.go | 24 ----
pkg/internal/client.go | 3 +-
pkg/util/bindings/arkmq.go | 98 ++++++-----------
pkg/util/bindings/arkmq_test.go | 49 +++------
script/gen_client.sh | 6 -
19 files changed, 53 insertions(+), 932 deletions(-)
diff --git a/pkg/client/arkmq/clientset/internalclientset/clientset.go b/pkg/client/arkmq/clientset/internalclientset/clientset.go
deleted file mode 100644
index 6bfbf6fed..000000000
--- a/pkg/client/arkmq/clientset/internalclientset/clientset.go
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by client-gen. DO NOT EDIT.
-
-package internalclientset
-
-import (
- fmt "fmt"
- http "net/http"
-
- brokerv1beta1 "github.com/apache/camel-k/v2/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1"
- discovery "k8s.io/client-go/discovery"
- rest "k8s.io/client-go/rest"
- flowcontrol "k8s.io/client-go/util/flowcontrol"
-)
-
-type Interface interface {
- Discovery() discovery.DiscoveryInterfaces
- BrokerV1beta1() brokerv1beta1.BrokerV1beta1Interface
-}
-
-// Clientset contains the clients for groups.
-type Clientset struct {
- *discovery.DiscoveryClient
- brokerV1beta1 *brokerv1beta1.BrokerV1beta1Client
-}
-
-// BrokerV1beta1 retrieves the BrokerV1beta1Client
-func (c *Clientset) BrokerV1beta1() brokerv1beta1.BrokerV1beta1Interface {
- return c.brokerV1beta1
-}
-
-// Discovery retrieves the DiscoveryClient
-func (c *Clientset) Discovery() discovery.DiscoveryInterfaces {
- if c == nil {
- return nil
- }
- return c.DiscoveryClient
-}
-
-// NewForConfig creates a new Clientset for the given config.
-// If config's RateLimiter is not set and QPS and Burst are acceptable,
-// NewForConfig will generate a rate-limiter in configShallowCopy.
-// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
-// where httpClient was generated with rest.HTTPClientFor(c).
-func NewForConfig(c *rest.Config) (*Clientset, error) {
- configShallowCopy := *c
-
- if configShallowCopy.UserAgent == "" {
- configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent()
- }
-
- // share the transport between all clients
- httpClient, err := rest.HTTPClientFor(&configShallowCopy)
- if err != nil {
- return nil, err
- }
-
- return NewForConfigAndClient(&configShallowCopy, httpClient)
-}
-
-// NewForConfigAndClient creates a new Clientset for the given config and http client.
-// Note the http client provided takes precedence over the configured transport values.
-// If config's RateLimiter is not set and QPS and Burst are acceptable,
-// NewForConfigAndClient will generate a rate-limiter in configShallowCopy.
-func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) {
- configShallowCopy := *c
- if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
- if configShallowCopy.Burst <= 0 {
- return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0")
- }
- configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
- }
-
- var cs Clientset
- var err error
- cs.brokerV1beta1, err = brokerv1beta1.NewForConfigAndClient(&configShallowCopy, httpClient)
- if err != nil {
- return nil, err
- }
-
- cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient)
- if err != nil {
- return nil, err
- }
- return &cs, nil
-}
-
-// NewForConfigOrDie creates a new Clientset for the given config and
-// panics if there is an error in the config.
-func NewForConfigOrDie(c *rest.Config) *Clientset {
- cs, err := NewForConfig(c)
- if err != nil {
- panic(err)
- }
- return cs
-}
-
-// New creates a new Clientset for the given RESTClient.
-func New(c rest.Interface) *Clientset {
- var cs Clientset
- cs.brokerV1beta1 = brokerv1beta1.New(c)
-
- cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
- return &cs
-}
diff --git a/pkg/client/arkmq/clientset/internalclientset/fake/clientset_generated.go b/pkg/client/arkmq/clientset/internalclientset/fake/clientset_generated.go
deleted file mode 100644
index 2406b49b0..000000000
--- a/pkg/client/arkmq/clientset/internalclientset/fake/clientset_generated.go
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by client-gen. DO NOT EDIT.
-
-package fake
-
-import (
- clientset "github.com/apache/camel-k/v2/pkg/client/arkmq/clientset/internalclientset"
- brokerv1beta1 "github.com/apache/camel-k/v2/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1"
- fakebrokerv1beta1 "github.com/apache/camel-k/v2/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/fake"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/apimachinery/pkg/runtime"
- "k8s.io/apimachinery/pkg/watch"
- "k8s.io/client-go/discovery"
- fakediscovery "k8s.io/client-go/discovery/fake"
- "k8s.io/client-go/testing"
-)
-
-// NewSimpleClientset returns a clientset that will respond with the provided objects.
-// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
-// without applying any field management, validations and/or defaults. It shouldn't be considered a replacement
-// for a real clientset and is mostly useful in simple unit tests.
-func NewSimpleClientset(objects ...runtime.Object) *Clientset {
- o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
- for _, obj := range objects {
- if err := o.Add(obj); err != nil {
- panic(err)
- }
- }
-
- cs := &Clientset{tracker: o}
- cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
- cs.AddReactor("*", "*", testing.ObjectReaction(o))
- cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
- var opts metav1.ListOptions
- if watchAction, ok := action.(testing.WatchActionImpl); ok {
- opts = watchAction.ListOptions
- }
- gvr := action.GetResource()
- ns := action.GetNamespace()
- watch, err := o.Watch(gvr, ns, opts)
- if err != nil {
- return false, nil, err
- }
- return true, watch, nil
- })
-
- return cs
-}
-
-// Clientset implements clientset.Interface. Meant to be embedded into a
-// struct to get a default implementation. This makes faking out just the method
-// you want to test easier.
-type Clientset struct {
- testing.Fake
- discovery *fakediscovery.FakeDiscovery
- tracker testing.ObjectTracker
-}
-
-func (c *Clientset) Discovery() discovery.DiscoveryInterfaces {
- return c.discovery
-}
-
-func (c *Clientset) Tracker() testing.ObjectTracker {
- return c.tracker
-}
-
-// IsWatchListSemanticsUnSupported informs the reflector that this client
-// doesn't support WatchList semantics.
-//
-// This is a synthetic method whose sole purpose is to satisfy the optional
-// interface check performed by the reflector.
-// Returning true signals that WatchList can NOT be used.
-// No additional logic is implemented here.
-func (c *Clientset) IsWatchListSemanticsUnSupported() bool {
- return true
-}
-
-var (
- _ clientset.Interface = &Clientset{}
- _ testing.FakeClient = &Clientset{}
-)
-
-// BrokerV1beta1 retrieves the BrokerV1beta1Client
-func (c *Clientset) BrokerV1beta1() brokerv1beta1.BrokerV1beta1Interface {
- return &fakebrokerv1beta1.FakeBrokerV1beta1{Fake: &c.Fake}
-}
diff --git a/pkg/client/arkmq/clientset/internalclientset/fake/doc.go b/pkg/client/arkmq/clientset/internalclientset/fake/doc.go
deleted file mode 100644
index 9c6a5fa07..000000000
--- a/pkg/client/arkmq/clientset/internalclientset/fake/doc.go
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by client-gen. DO NOT EDIT.
-
-// This package has the automatically generated fake clientset.
-package fake
diff --git a/pkg/client/arkmq/clientset/internalclientset/fake/register.go b/pkg/client/arkmq/clientset/internalclientset/fake/register.go
deleted file mode 100644
index 6626d0c24..000000000
--- a/pkg/client/arkmq/clientset/internalclientset/fake/register.go
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by client-gen. DO NOT EDIT.
-
-package fake
-
-import (
- brokerv1beta1 "github.com/apache/camel-k/v2/pkg/apis/duck/arkmq/v1beta1"
- v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- runtime "k8s.io/apimachinery/pkg/runtime"
- schema "k8s.io/apimachinery/pkg/runtime/schema"
- serializer "k8s.io/apimachinery/pkg/runtime/serializer"
- utilruntime "k8s.io/apimachinery/pkg/util/runtime"
-)
-
-var scheme = runtime.NewScheme()
-var codecs = serializer.NewCodecFactory(scheme)
-
-var localSchemeBuilder = runtime.SchemeBuilder{
- brokerv1beta1.AddToScheme,
-}
-
-// AddToScheme adds all types of this clientset into the given scheme. This allows composition
-// of clientsets, like in:
-//
-// import (
-// "k8s.io/client-go/kubernetes"
-// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
-// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
-// )
-//
-// kclientset, _ := kubernetes.NewForConfig(c)
-// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
-//
-// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
-// correctly.
-var AddToScheme = localSchemeBuilder.AddToScheme
-
-func init() {
- v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
- utilruntime.Must(AddToScheme(scheme))
-}
diff --git a/pkg/client/arkmq/clientset/internalclientset/scheme/doc.go b/pkg/client/arkmq/clientset/internalclientset/scheme/doc.go
deleted file mode 100644
index dd7d3b588..000000000
--- a/pkg/client/arkmq/clientset/internalclientset/scheme/doc.go
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by client-gen. DO NOT EDIT.
-
-// This package contains the scheme of the automatically generated clientset.
-package scheme
diff --git a/pkg/client/arkmq/clientset/internalclientset/scheme/register.go b/pkg/client/arkmq/clientset/internalclientset/scheme/register.go
deleted file mode 100644
index 4d0cfde87..000000000
--- a/pkg/client/arkmq/clientset/internalclientset/scheme/register.go
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by client-gen. DO NOT EDIT.
-
-package scheme
-
-import (
- brokerv1beta1 "github.com/apache/camel-k/v2/pkg/apis/duck/arkmq/v1beta1"
- v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- runtime "k8s.io/apimachinery/pkg/runtime"
- schema "k8s.io/apimachinery/pkg/runtime/schema"
- serializer "k8s.io/apimachinery/pkg/runtime/serializer"
- utilruntime "k8s.io/apimachinery/pkg/util/runtime"
-)
-
-var Scheme = runtime.NewScheme()
-var Codecs = serializer.NewCodecFactory(Scheme)
-var ParameterCodec = runtime.NewParameterCodec(Scheme)
-var localSchemeBuilder = runtime.SchemeBuilder{
- brokerv1beta1.AddToScheme,
-}
-
-// AddToScheme adds all types of this clientset into the given scheme. This allows composition
-// of clientsets, like in:
-//
-// import (
-// "k8s.io/client-go/kubernetes"
-// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
-// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
-// )
-//
-// kclientset, _ := kubernetes.NewForConfig(c)
-// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
-//
-// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
-// correctly.
-var AddToScheme = localSchemeBuilder.AddToScheme
-
-func init() {
- v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
- utilruntime.Must(AddToScheme(Scheme))
-}
diff --git a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/activemqartemis.go b/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/activemqartemis.go
deleted file mode 100644
index b4c09a538..000000000
--- a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/activemqartemis.go
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by client-gen. DO NOT EDIT.
-
-package v1beta1
-
-import (
- context "context"
-
- arkmqv1beta1 "github.com/apache/camel-k/v2/pkg/apis/duck/arkmq/v1beta1"
- scheme "github.com/apache/camel-k/v2/pkg/client/arkmq/clientset/internalclientset/scheme"
- v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- watch "k8s.io/apimachinery/pkg/watch"
- gentype "k8s.io/client-go/gentype"
-)
-
-// ActiveMQArtemisesGetter has a method to return a ActiveMQArtemisInterface.
-// A group's client should implement this interface.
-type ActiveMQArtemisesGetter interface {
- ActiveMQArtemises(namespace string) ActiveMQArtemisInterface
-}
-
-// ActiveMQArtemisInterface has methods to work with ActiveMQArtemis resources.
-type ActiveMQArtemisInterface interface {
- Get(ctx context.Context, name string, opts v1.GetOptions) (*arkmqv1beta1.ActiveMQArtemis, error)
- List(ctx context.Context, opts v1.ListOptions) (*arkmqv1beta1.ActiveMQArtemisList, error)
- Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
- ActiveMQArtemisExpansion
-}
-
-// activeMQArtemises implements ActiveMQArtemisInterface
-type activeMQArtemises struct {
- *gentype.ClientWithList[*arkmqv1beta1.ActiveMQArtemis, *arkmqv1beta1.ActiveMQArtemisList]
-}
-
-// newActiveMQArtemises returns a ActiveMQArtemises
-func newActiveMQArtemises(c *BrokerV1beta1Client, namespace string) *activeMQArtemises {
- return &activeMQArtemises{
- gentype.NewClientWithList[*arkmqv1beta1.ActiveMQArtemis, *arkmqv1beta1.ActiveMQArtemisList](
- "activemqartemises",
- c.RESTClient(),
- scheme.ParameterCodec,
- namespace,
- func() *arkmqv1beta1.ActiveMQArtemis { return &arkmqv1beta1.ActiveMQArtemis{} },
- func() *arkmqv1beta1.ActiveMQArtemisList { return &arkmqv1beta1.ActiveMQArtemisList{} },
- ),
- }
-}
diff --git a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/activemqartemisaddress.go b/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/activemqartemisaddress.go
deleted file mode 100644
index f8d753cac..000000000
--- a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/activemqartemisaddress.go
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by client-gen. DO NOT EDIT.
-
-package v1beta1
-
-import (
- context "context"
-
- arkmqv1beta1 "github.com/apache/camel-k/v2/pkg/apis/duck/arkmq/v1beta1"
- scheme "github.com/apache/camel-k/v2/pkg/client/arkmq/clientset/internalclientset/scheme"
- v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- watch "k8s.io/apimachinery/pkg/watch"
- gentype "k8s.io/client-go/gentype"
-)
-
-// ActiveMQArtemisAddressesGetter has a method to return a ActiveMQArtemisAddressInterface.
-// A group's client should implement this interface.
-type ActiveMQArtemisAddressesGetter interface {
- ActiveMQArtemisAddresses(namespace string) ActiveMQArtemisAddressInterface
-}
-
-// ActiveMQArtemisAddressInterface has methods to work with ActiveMQArtemisAddress resources.
-type ActiveMQArtemisAddressInterface interface {
- Get(ctx context.Context, name string, opts v1.GetOptions) (*arkmqv1beta1.ActiveMQArtemisAddress, error)
- List(ctx context.Context, opts v1.ListOptions) (*arkmqv1beta1.ActiveMQArtemisAddressList, error)
- Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
- ActiveMQArtemisAddressExpansion
-}
-
-// activeMQArtemisAddresses implements ActiveMQArtemisAddressInterface
-type activeMQArtemisAddresses struct {
- *gentype.ClientWithList[*arkmqv1beta1.ActiveMQArtemisAddress, *arkmqv1beta1.ActiveMQArtemisAddressList]
-}
-
-// newActiveMQArtemisAddresses returns a ActiveMQArtemisAddresses
-func newActiveMQArtemisAddresses(c *BrokerV1beta1Client, namespace string) *activeMQArtemisAddresses {
- return &activeMQArtemisAddresses{
- gentype.NewClientWithList[*arkmqv1beta1.ActiveMQArtemisAddress, *arkmqv1beta1.ActiveMQArtemisAddressList](
- "activemqartemisaddresses",
- c.RESTClient(),
- scheme.ParameterCodec,
- namespace,
- func() *arkmqv1beta1.ActiveMQArtemisAddress { return &arkmqv1beta1.ActiveMQArtemisAddress{} },
- func() *arkmqv1beta1.ActiveMQArtemisAddressList { return &arkmqv1beta1.ActiveMQArtemisAddressList{} },
- ),
- }
-}
diff --git a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/arkmq_client.go b/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/arkmq_client.go
deleted file mode 100644
index 881d6e2cf..000000000
--- a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/arkmq_client.go
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by client-gen. DO NOT EDIT.
-
-package v1beta1
-
-import (
- http "net/http"
-
- arkmqv1beta1 "github.com/apache/camel-k/v2/pkg/apis/duck/arkmq/v1beta1"
- scheme "github.com/apache/camel-k/v2/pkg/client/arkmq/clientset/internalclientset/scheme"
- rest "k8s.io/client-go/rest"
-)
-
-type BrokerV1beta1Interface interface {
- RESTClient() rest.Interface
- ActiveMQArtemisesGetter
- ActiveMQArtemisAddressesGetter
-}
-
-// BrokerV1beta1Client is used to interact with features provided by the broker.amq.io group.
-type BrokerV1beta1Client struct {
- restClient rest.Interface
-}
-
-func (c *BrokerV1beta1Client) ActiveMQArtemises(namespace string) ActiveMQArtemisInterface {
- return newActiveMQArtemises(c, namespace)
-}
-
-func (c *BrokerV1beta1Client) ActiveMQArtemisAddresses(namespace string) ActiveMQArtemisAddressInterface {
- return newActiveMQArtemisAddresses(c, namespace)
-}
-
-// NewForConfig creates a new BrokerV1beta1Client for the given config.
-// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
-// where httpClient was generated with rest.HTTPClientFor(c).
-func NewForConfig(c *rest.Config) (*BrokerV1beta1Client, error) {
- config := *c
- setConfigDefaults(&config)
- httpClient, err := rest.HTTPClientFor(&config)
- if err != nil {
- return nil, err
- }
- return NewForConfigAndClient(&config, httpClient)
-}
-
-// NewForConfigAndClient creates a new BrokerV1beta1Client for the given config and http client.
-// Note the http client provided takes precedence over the configured transport values.
-func NewForConfigAndClient(c *rest.Config, h *http.Client) (*BrokerV1beta1Client, error) {
- config := *c
- setConfigDefaults(&config)
- client, err := rest.RESTClientForConfigAndClient(&config, h)
- if err != nil {
- return nil, err
- }
- return &BrokerV1beta1Client{client}, nil
-}
-
-// NewForConfigOrDie creates a new BrokerV1beta1Client for the given config and
-// panics if there is an error in the config.
-func NewForConfigOrDie(c *rest.Config) *BrokerV1beta1Client {
- client, err := NewForConfig(c)
- if err != nil {
- panic(err)
- }
- return client
-}
-
-// New creates a new BrokerV1beta1Client for the given RESTClient.
-func New(c rest.Interface) *BrokerV1beta1Client {
- return &BrokerV1beta1Client{c}
-}
-
-func setConfigDefaults(config *rest.Config) {
- gv := arkmqv1beta1.SchemeGroupVersion
- config.GroupVersion = &gv
- config.APIPath = "/apis"
- config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(scheme.Scheme, scheme.Codecs).WithoutConversion()
-
- if config.UserAgent == "" {
- config.UserAgent = rest.DefaultKubernetesUserAgent()
- }
-}
-
-// RESTClient returns a RESTClient that is used to communicate
-// with API server by this client implementation.
-func (c *BrokerV1beta1Client) RESTClient() rest.Interface {
- if c == nil {
- return nil
- }
- return c.restClient
-}
diff --git a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/doc.go b/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/doc.go
deleted file mode 100644
index 69b5e249c..000000000
--- a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/doc.go
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by client-gen. DO NOT EDIT.
-
-// This package has the automatically generated typed clients.
-package v1beta1
diff --git a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/fake/doc.go b/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/fake/doc.go
deleted file mode 100644
index 5d1c76cc9..000000000
--- a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/fake/doc.go
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by client-gen. DO NOT EDIT.
-
-// Package fake has the automatically generated clients.
-package fake
diff --git a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/fake/fake_activemqartemis.go b/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/fake/fake_activemqartemis.go
deleted file mode 100644
index 5c4620f05..000000000
--- a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/fake/fake_activemqartemis.go
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by client-gen. DO NOT EDIT.
-
-package fake
-
-import (
- v1beta1 "github.com/apache/camel-k/v2/pkg/apis/duck/arkmq/v1beta1"
- arkmqv1beta1 "github.com/apache/camel-k/v2/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1"
- gentype "k8s.io/client-go/gentype"
-)
-
-// fakeActiveMQArtemises implements ActiveMQArtemisInterface
-type fakeActiveMQArtemises struct {
- *gentype.FakeClientWithList[*v1beta1.ActiveMQArtemis, *v1beta1.ActiveMQArtemisList]
- Fake *FakeBrokerV1beta1
-}
-
-func newFakeActiveMQArtemises(fake *FakeBrokerV1beta1, namespace string) arkmqv1beta1.ActiveMQArtemisInterface {
- return &fakeActiveMQArtemises{
- gentype.NewFakeClientWithList[*v1beta1.ActiveMQArtemis, *v1beta1.ActiveMQArtemisList](
- fake.Fake,
- namespace,
- v1beta1.SchemeGroupVersion.WithResource("activemqartemises"),
- v1beta1.SchemeGroupVersion.WithKind("ActiveMQArtemis"),
- func() *v1beta1.ActiveMQArtemis { return &v1beta1.ActiveMQArtemis{} },
- func() *v1beta1.ActiveMQArtemisList { return &v1beta1.ActiveMQArtemisList{} },
- func(dst, src *v1beta1.ActiveMQArtemisList) { dst.ListMeta = src.ListMeta },
- func(list *v1beta1.ActiveMQArtemisList) []*v1beta1.ActiveMQArtemis {
- return gentype.ToPointerSlice(list.Items)
- },
- func(list *v1beta1.ActiveMQArtemisList, items []*v1beta1.ActiveMQArtemis) {
- list.Items = gentype.FromPointerSlice(items)
- },
- ),
- fake,
- }
-}
diff --git a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/fake/fake_activemqartemisaddress.go b/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/fake/fake_activemqartemisaddress.go
deleted file mode 100644
index 2f6681b77..000000000
--- a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/fake/fake_activemqartemisaddress.go
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by client-gen. DO NOT EDIT.
-
-package fake
-
-import (
- v1beta1 "github.com/apache/camel-k/v2/pkg/apis/duck/arkmq/v1beta1"
- arkmqv1beta1 "github.com/apache/camel-k/v2/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1"
- gentype "k8s.io/client-go/gentype"
-)
-
-// fakeActiveMQArtemisAddresses implements ActiveMQArtemisAddressInterface
-type fakeActiveMQArtemisAddresses struct {
- *gentype.FakeClientWithList[*v1beta1.ActiveMQArtemisAddress, *v1beta1.ActiveMQArtemisAddressList]
- Fake *FakeBrokerV1beta1
-}
-
-func newFakeActiveMQArtemisAddresses(fake *FakeBrokerV1beta1, namespace string) arkmqv1beta1.ActiveMQArtemisAddressInterface {
- return &fakeActiveMQArtemisAddresses{
- gentype.NewFakeClientWithList[*v1beta1.ActiveMQArtemisAddress, *v1beta1.ActiveMQArtemisAddressList](
- fake.Fake,
- namespace,
- v1beta1.SchemeGroupVersion.WithResource("activemqartemisaddresses"),
- v1beta1.SchemeGroupVersion.WithKind("ActiveMQArtemisAddress"),
- func() *v1beta1.ActiveMQArtemisAddress { return &v1beta1.ActiveMQArtemisAddress{} },
- func() *v1beta1.ActiveMQArtemisAddressList { return &v1beta1.ActiveMQArtemisAddressList{} },
- func(dst, src *v1beta1.ActiveMQArtemisAddressList) { dst.ListMeta = src.ListMeta },
- func(list *v1beta1.ActiveMQArtemisAddressList) []*v1beta1.ActiveMQArtemisAddress {
- return gentype.ToPointerSlice(list.Items)
- },
- func(list *v1beta1.ActiveMQArtemisAddressList, items []*v1beta1.ActiveMQArtemisAddress) {
- list.Items = gentype.FromPointerSlice(items)
- },
- ),
- fake,
- }
-}
diff --git a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/fake/fake_arkmq_client.go b/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/fake/fake_arkmq_client.go
deleted file mode 100644
index be83e82fc..000000000
--- a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/fake/fake_arkmq_client.go
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by client-gen. DO NOT EDIT.
-
-package fake
-
-import (
- v1beta1 "github.com/apache/camel-k/v2/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1"
- rest "k8s.io/client-go/rest"
- testing "k8s.io/client-go/testing"
-)
-
-type FakeBrokerV1beta1 struct {
- *testing.Fake
-}
-
-func (c *FakeBrokerV1beta1) ActiveMQArtemises(namespace string) v1beta1.ActiveMQArtemisInterface {
- return newFakeActiveMQArtemises(c, namespace)
-}
-
-func (c *FakeBrokerV1beta1) ActiveMQArtemisAddresses(namespace string) v1beta1.ActiveMQArtemisAddressInterface {
- return newFakeActiveMQArtemisAddresses(c, namespace)
-}
-
-// RESTClient returns a RESTClient that is used to communicate
-// with API server by this client implementation.
-func (c *FakeBrokerV1beta1) RESTClient() rest.Interface {
- var ret *rest.RESTClient
- return ret
-}
diff --git a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/generated_expansion.go b/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/generated_expansion.go
deleted file mode 100644
index 50d18cb0c..000000000
--- a/pkg/client/arkmq/clientset/internalclientset/typed/arkmq/v1beta1/generated_expansion.go
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by client-gen. DO NOT EDIT.
-
-package v1beta1
-
-type ActiveMQArtemisExpansion interface{}
-
-type ActiveMQArtemisAddressExpansion interface{}
diff --git a/pkg/internal/client.go b/pkg/internal/client.go
index 3de56810c..748f2e567 100644
--- a/pkg/internal/client.go
+++ b/pkg/internal/client.go
@@ -80,7 +80,8 @@ func NewFakeClient(initObjs ...runtime.Object) (client.Client, error) {
})...)
clientset := fakeclientset.NewSimpleClientset(filterObjects(scheme, initObjs, func(gvk schema.GroupVersionKind) bool {
return !strings.Contains(gvk.Group, "camel") && !strings.Contains(gvk.Group, "knative") &&
- !strings.Contains(gvk.Group, "cert-manager")
+ !strings.Contains(gvk.Group, "cert-manager") && !strings.Contains(gvk.Group, "amq.io") &&
+ !strings.Contains(gvk.Group, "strimzi")
})...)
replicasCount := make(map[string]int32)
fakescaleclient := fakescale.FakeScaleClient{}
diff --git a/pkg/util/bindings/arkmq.go b/pkg/util/bindings/arkmq.go
index 21599d138..804bd7e67 100644
--- a/pkg/util/bindings/arkmq.go
+++ b/pkg/util/bindings/arkmq.go
@@ -22,12 +22,11 @@ import (
camelv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
arkmqv1beta1 "github.com/apache/camel-k/v2/pkg/apis/duck/arkmq/v1beta1"
- "github.com/apache/camel-k/v2/pkg/client/arkmq/clientset/internalclientset"
"github.com/apache/camel-k/v2/pkg/util/kubernetes"
"github.com/apache/camel-k/v2/pkg/util/uri"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
- v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
+ ctrl "sigs.k8s.io/controller-runtime/pkg/client"
)
func init() {
@@ -41,9 +40,7 @@ type camelArkMQ struct {
}
// ArkMQBindingProvider allows connecting to an ArkMQ queue via Binding.
-type ArkMQBindingProvider struct {
- Client internalclientset.Interface
-}
+type ArkMQBindingProvider struct{}
func (a ArkMQBindingProvider) ID() string {
return "arkmq"
@@ -195,17 +192,8 @@ func (a ArkMQBindingProvider) lookupBrokerURL(ctx BindingContext, address *arkmq
}
func (a ArkMQBindingProvider) fallbackBrokerName(ctx BindingContext, namespace, addressName string) (string, error) {
- client := a.Client
- if client == nil {
- arkmqClient, err := internalclientset.NewForConfig(ctx.Client.GetConfig())
- if err != nil {
- return "", err
- }
- client = arkmqClient
- }
-
- brokers, err := client.BrokerV1beta1().ActiveMQArtemises(namespace).List(ctx.Ctx, v1.ListOptions{})
- if err != nil {
+ var brokers arkmqv1beta1.ActiveMQArtemisList
+ if err := ctx.Client.List(ctx.Ctx, &brokers, ctrl.InNamespace(namespace)); err != nil {
return "", err
}
if len(brokers.Items) == 0 {
@@ -220,17 +208,12 @@ func (a ArkMQBindingProvider) fallbackBrokerName(ctx BindingContext, namespace,
}
func (a ArkMQBindingProvider) getBrokerURL(ctx BindingContext, clusterName, namespace string) (string, error) {
- client := a.Client
- if client == nil {
- arkmqClient, err := internalclientset.NewForConfig(ctx.Client.GetConfig())
- if err != nil {
- return "", err
- }
- client = arkmqClient
+ var broker arkmqv1beta1.ActiveMQArtemis
+ key := ctrl.ObjectKey{
+ Namespace: namespace,
+ Name: clusterName,
}
-
- broker, err := client.BrokerV1beta1().ActiveMQArtemises(namespace).Get(ctx.Ctx, clusterName, v1.GetOptions{})
- if err != nil {
+ if err := ctx.Client.Get(ctx.Ctx, key, &broker); err != nil {
return "", err
}
@@ -245,67 +228,56 @@ func (a ArkMQBindingProvider) getBrokerURL(ctx BindingContext, clusterName, name
}
svcName := fmt.Sprintf("%s-hdls-svc", clusterName)
- if ctx.Client != nil {
- svc, err := kubernetes.LookupService(ctx.Ctx, ctx.Client, namespace, svcName)
+ svc, err := kubernetes.LookupService(ctx.Ctx, ctx.Client, namespace, svcName)
+ if err != nil {
+ return "", err
+ }
+ if svc == nil {
+ svc, err = kubernetes.LookupService(ctx.Ctx, ctx.Client, namespace, clusterName)
if err != nil {
return "", err
}
- if svc == nil {
- svc, err = kubernetes.LookupService(ctx.Ctx, ctx.Client, namespace, clusterName)
- if err != nil {
- return "", err
- }
- }
- if svc == nil {
- return "", fmt.Errorf("could not find service %s in namespace %s for ArkMQ broker %s", svcName, namespace, clusterName)
- }
-
- for _, p := range svc.Spec.Ports {
- if p.Name == "core" || p.Name == "all" || p.Name == "openwire" || p.Port == 61616 {
- port = p.Port
- break
- }
- }
+ }
+ if svc == nil {
+ return "", fmt.Errorf("could not find service %s in namespace %s for ArkMQ broker %s", svcName, namespace, clusterName)
+ }
- if svc.Namespace != "" {
- return fmt.Sprintf("tcp://%s.%s.svc:%d", svc.Name, svc.Namespace, port), nil
+ for _, p := range svc.Spec.Ports {
+ if p.Name == "core" || p.Name == "all" || p.Name == "openwire" || p.Port == 61616 {
+ port = p.Port
+ break
}
- return fmt.Sprintf("tcp://%s:%d", svc.Name, port), nil
}
- if namespace != "" {
- return fmt.Sprintf("tcp://%s.%s.svc:%d", svcName, namespace, port), nil
+ if svc.Namespace != "" {
+ return fmt.Sprintf("tcp://%s.%s.svc:%d", svc.Name, svc.Namespace, port), nil
}
- return fmt.Sprintf("tcp://%s:%d", svcName, port), nil
+ return fmt.Sprintf("tcp://%s:%d", svc.Name, port), nil
}
func (a ArkMQBindingProvider) lookupAddress(ctx BindingContext, endpoint camelv1.Endpoint) (*arkmqv1beta1.ActiveMQArtemisAddress, error) {
- client := a.Client
- if client == nil {
- arkmqClient, err := internalclientset.NewForConfig(ctx.Client.GetConfig())
- if err != nil {
- return nil, err
- }
- client = arkmqClient
- }
-
namespace := endpoint.Ref.Namespace
if namespace == "" {
namespace = ctx.Namespace
}
+ var address arkmqv1beta1.ActiveMQArtemisAddress
+ key := ctrl.ObjectKey{
+ Namespace: namespace,
+ Name: endpoint.Ref.Name,
+ }
// first check by ActiveMQArtemisAddress name
- address, err := client.BrokerV1beta1().ActiveMQArtemisAddresses(namespace).Get(ctx.Ctx, endpoint.Ref.Name, v1.GetOptions{})
+ err := ctx.Client.Get(ctx.Ctx, key, &address)
if err != nil && !k8serrors.IsNotFound(err) {
return nil, err
}
if err == nil {
- return address, nil
+ return &address, nil
}
// if not found, then look at spec.queueName or spec.addressName
- addresses, err := client.BrokerV1beta1().ActiveMQArtemisAddresses(namespace).List(ctx.Ctx, v1.ListOptions{})
- if err != nil {
+ var addresses arkmqv1beta1.ActiveMQArtemisAddressList
+ if err := ctx.Client.List(ctx.Ctx, &addresses, ctrl.InNamespace(namespace)); err != nil {
return nil, fmt.Errorf("couldn't find any ActiveMQArtemisAddress with either name, queueName or addressName %s; error %w", endpoint.Ref.Name, err)
}
for i := range addresses.Items {
diff --git a/pkg/util/bindings/arkmq_test.go b/pkg/util/bindings/arkmq_test.go
index 3a3be32e8..6cb610db3 100644
--- a/pkg/util/bindings/arkmq_test.go
+++ b/pkg/util/bindings/arkmq_test.go
@@ -23,7 +23,6 @@ import (
camelv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
arkmqv1beta1 "github.com/apache/camel-k/v2/pkg/apis/duck/arkmq/v1beta1"
- "github.com/apache/camel-k/v2/pkg/client/arkmq/clientset/internalclientset/fake"
"github.com/apache/camel-k/v2/pkg/internal"
"github.com/stretchr/testify/assert"
@@ -110,7 +109,7 @@ func TestArkMQLookupAddress(t *testing.T) {
},
}
- client, err := internal.NewFakeClient(svc)
+ client, err := internal.NewFakeClient(broker, address, svc)
require.NoError(t, err)
bindingContext := BindingContext{
@@ -128,9 +127,7 @@ func TestArkMQLookupAddress(t *testing.T) {
},
}
- provider := ArkMQBindingProvider{
- Client: fake.NewSimpleClientset(broker, address),
- }
+ provider := ArkMQBindingProvider{}
binding, err := provider.Translate(bindingContext, EndpointContext{
Type: camelv1.EndpointTypeSink,
@@ -155,7 +152,7 @@ func TestArkMQMulticastUnsupported(t *testing.T) {
},
}
- client, err := internal.NewFakeClient()
+ client, err := internal.NewFakeClient(address)
require.NoError(t, err)
bindingContext := BindingContext{
@@ -173,9 +170,7 @@ func TestArkMQMulticastUnsupported(t *testing.T) {
},
}
- provider := ArkMQBindingProvider{
- Client: fake.NewSimpleClientset(address),
- }
+ provider := ArkMQBindingProvider{}
_, err = provider.Translate(bindingContext, EndpointContext{
Type: camelv1.EndpointTypeSink,
@@ -223,7 +218,7 @@ func TestArkMQLookupAddressByName(t *testing.T) {
},
}
- client, err := internal.NewFakeClient(svc)
+ client, err := internal.NewFakeClient(broker, address, svc)
require.NoError(t, err)
bindingContext := BindingContext{
@@ -241,9 +236,7 @@ func TestArkMQLookupAddressByName(t *testing.T) {
},
}
- provider := ArkMQBindingProvider{
- Client: fake.NewSimpleClientset(broker, address),
- }
+ provider := ArkMQBindingProvider{}
binding, err := provider.Translate(bindingContext, EndpointContext{
Type: camelv1.EndpointTypeSink,
@@ -287,7 +280,7 @@ func TestArkMQBrokerDirect(t *testing.T) {
},
}
- client, err := internal.NewFakeClient(svc)
+ client, err := internal.NewFakeClient(broker, svc)
require.NoError(t, err)
bindingContext := BindingContext{
@@ -309,9 +302,7 @@ func TestArkMQBrokerDirect(t *testing.T) {
}),
}
- provider := ArkMQBindingProvider{
- Client: fake.NewSimpleClientset(broker),
- }
+ provider := ArkMQBindingProvider{}
binding, err := provider.Translate(bindingContext, EndpointContext{
Type: camelv1.EndpointTypeSink,
@@ -364,7 +355,7 @@ func TestArkMQMissingService(t *testing.T) {
},
}
- client, err := internal.NewFakeClient() // no service in client!
+ client, err := internal.NewFakeClient(broker) // no service in client!
require.NoError(t, err)
bindingContext := BindingContext{
@@ -385,9 +376,7 @@ func TestArkMQMissingService(t *testing.T) {
}),
}
- provider := ArkMQBindingProvider{
- Client: fake.NewSimpleClientset(broker),
- }
+ provider := ArkMQBindingProvider{}
_, err = provider.Translate(bindingContext, EndpointContext{
Type: camelv1.EndpointTypeSink,
@@ -438,7 +427,7 @@ func TestArkMQMissingBrokerLabel(t *testing.T) {
},
}
- client, err := internal.NewFakeClient()
+ client, err := internal.NewFakeClient(address)
require.NoError(t, err)
bindingContext := BindingContext{
@@ -456,9 +445,7 @@ func TestArkMQMissingBrokerLabel(t *testing.T) {
},
}
- provider := ArkMQBindingProvider{
- Client: fake.NewSimpleClientset(address),
- }
+ provider := ArkMQBindingProvider{}
_, err = provider.Translate(bindingContext, EndpointContext{
Type: camelv1.EndpointTypeSink,
@@ -512,7 +499,7 @@ func TestArkMQBrokerFallback(t *testing.T) {
},
}
- client, err := internal.NewFakeClient(svc)
+ client, err := internal.NewFakeClient(broker, address, svc)
require.NoError(t, err)
bindingContext := BindingContext{
@@ -530,9 +517,7 @@ func TestArkMQBrokerFallback(t *testing.T) {
},
}
- provider := ArkMQBindingProvider{
- Client: fake.NewSimpleClientset(broker, address),
- }
+ provider := ArkMQBindingProvider{}
binding, err := provider.Translate(bindingContext, EndpointContext{
Type: camelv1.EndpointTypeSink,
@@ -566,7 +551,7 @@ func TestArkMQMultipleBrokersFallback(t *testing.T) {
},
}
- client, err := internal.NewFakeClient()
+ client, err := internal.NewFakeClient(broker1, broker2, address)
require.NoError(t, err)
bindingContext := BindingContext{
@@ -584,9 +569,7 @@ func TestArkMQMultipleBrokersFallback(t *testing.T) {
},
}
- provider := ArkMQBindingProvider{
- Client: fake.NewSimpleClientset(broker1, broker2, address),
- }
+ provider := ArkMQBindingProvider{}
_, err = provider.Translate(bindingContext, EndpointContext{
Type: camelv1.EndpointTypeSink,
diff --git a/script/gen_client.sh b/script/gen_client.sh
index d3a56ca82..4aa177eae 100755
--- a/script/gen_client.sh
+++ b/script/gen_client.sh
@@ -59,12 +59,6 @@ $(go env GOPATH)/bin/client-gen \
--output-dir=./keda/clientset/ \
--output-pkg=github.com/apache/camel-k/v2/pkg/client/keda/clientset
-$(go env GOPATH)/bin/client-gen \
- --input arkmq/v1beta1 \
- --go-header-file=../../script/headers/default.txt \
- --input-base=github.com/apache/camel-k/v2/pkg/apis/duck \
- --output-dir=./arkmq/clientset/ \
- --output-pkg=github.com/apache/camel-k/v2/pkg/client/arkmq/clientset
$(go env GOPATH)/bin/lister-gen \
"github.com/apache/camel-k/v2/pkg/apis/camel/v1" \