Skip to content

Commit 43c786b

Browse files
authored
Refactor common code to remove deprecated client-pkg (#384)
* Refactor common code to remove deprecated client-pkg * Fix linter issues and headers
1 parent b9b04f0 commit 43c786b

File tree

178 files changed

+5626
-1376
lines changed

Some content is hidden

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

178 files changed

+5626
-1376
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ kn source kafka create mykafkasrc --servers my-cluster-kafka-bootstrap.kafka.svc
9090
-l, --label stringArray Metadata labels to set on the resources. Example: '--label key=value' You may be provide this flag multiple times.
9191
-n, --namespace string Specify the namespace to operate in.
9292
--servers stringArray Kafka bootstrap servers that the consumer will connect to, consist of a hostname plus a port pair, e.g. my-kafka-bootstrap.kafka:9092. Flag can be used multiple times.
93-
-s, --sink string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink channel:pipe' for a channel 'pipe', '--sink ksvc:mysvc:mynamespace' for a Knative service 'mysvc' in another namespace 'mynamespace', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver' in the current namespace. If a prefix is not provided, it is considered as a Knative service in the current namespace. If referring to a Knative service in another namespace, 'ksvc:name:namespace' combination must be provided explicitly.
93+
-s, --sink string Addressable sink for events. You can specify a broker, channel, Knative service, Kubernetes service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink channel:pipe' for a channel 'pipe', '--sink ksvc:mysvc:mynamespace' for a Knative service 'mysvc' in another namespace 'mynamespace', '--sink https://event.receiver.uri' for an HTTP URI, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver' in the current namespace, '--sink svc:receiver:mynamespace' for a Kubernetes service 'receiver' in the 'mynamespace' namespace, '--sink special.eventing.dev/v1alpha1/channels:pipe' for GroupVersionResource of v1alpha1 'pipe'. If a prefix is not provided, it is considered as a Knative service in the current namespace.
9494
--topics stringArray Topics to consume messages from. Flag can be used multiple times.
9595
```
9696

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@ go 1.24.0
55
require (
66
github.com/hashicorp/golang-lru v1.0.2
77
github.com/hashicorp/hcl v1.0.1-vault-5
8+
github.com/mitchellh/go-homedir v1.1.0
89
github.com/spf13/cobra v1.8.1
910
github.com/spf13/pflag v1.0.6
1011
gotest.tools/v3 v3.3.0
12+
k8s.io/api v0.33.1
1113
k8s.io/apimachinery v0.33.1
1214
k8s.io/client-go v0.33.1
13-
knative.dev/client-pkg v0.0.0-20250708014830-d390b195d2e7
1415
knative.dev/client/pkg v0.0.0-20250717154902-8216e64a8b5a
1516
knative.dev/eventing-kafka-broker v0.45.1-0.20250715130359-a50bc61f50c6
1617
knative.dev/hack v0.0.0-20250708013849-70d4b00da6ba
1718
knative.dev/pkg v0.0.0-20250716115900-19d3cc2da0b9
1819
)
1920

2021
require (
22+
emperror.dev/errors v0.8.1 // indirect
2123
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
2224
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect
2325
github.com/blendle/zapdriver v1.3.1 // indirect
@@ -54,7 +56,6 @@ require (
5456
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
5557
github.com/magiconair/properties v1.8.7 // indirect
5658
github.com/mailru/easyjson v0.9.0 // indirect
57-
github.com/mitchellh/go-homedir v1.1.0 // indirect
5859
github.com/mitchellh/mapstructure v1.5.0 // indirect
5960
github.com/moby/term v0.5.0 // indirect
6061
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@@ -99,7 +100,6 @@ require (
99100
gopkg.in/ini.v1 v1.67.0 // indirect
100101
gopkg.in/yaml.v2 v2.4.0 // indirect
101102
gopkg.in/yaml.v3 v3.0.1 // indirect
102-
k8s.io/api v0.33.1 // indirect
103103
k8s.io/apiextensions-apiserver v0.33.1 // indirect
104104
k8s.io/apiserver v0.33.1 // indirect
105105
k8s.io/cli-runtime v0.29.2 // indirect

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
3636
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
3737
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
3838
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
39+
emperror.dev/errors v0.8.1 h1:UavXZ5cSX/4u9iyvH6aDcuGkVjeexUGJ7Ij7G4VfQT0=
40+
emperror.dev/errors v0.8.1/go.mod h1:YcRvLPh626Ubn2xqtoprejnA5nFha+TJ+2vew48kWuE=
3941
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
4042
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
4143
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
@@ -372,11 +374,13 @@ go.opentelemetry.io/proto/otlp v1.7.0/go.mod h1:fSKjH6YJ7HDlwzltzyMj036AJ3ejJLCg
372374
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca h1:VdD38733bfYv5tUZwEIskMM93VanwNIi5bIKnDrJdEY=
373375
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca/go.mod h1:jxU+3+j+71eXOW14274+SmmuW82qJzl6iZSeqEtTGds=
374376
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
377+
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
375378
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
376379
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
377380
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
378381
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
379382
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
383+
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
380384
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
381385
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
382386
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
@@ -743,8 +747,6 @@ k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUy
743747
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8=
744748
k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJJI8IUa1AmH/qa0=
745749
k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
746-
knative.dev/client-pkg v0.0.0-20250708014830-d390b195d2e7 h1:wKqBJpOy2OWdNQRuk4jdSpobWhPTuXzR02sJ876dTX4=
747-
knative.dev/client-pkg v0.0.0-20250708014830-d390b195d2e7/go.mod h1:QazBaizv2HgvEGWpCVi4Pzw1fV0b2uzSN1IQajPk0Q0=
748750
knative.dev/client/pkg v0.0.0-20250717154902-8216e64a8b5a h1:uLflJhDxuRKHvwwwT43R7lM6BSqwlXh0AlfQJb8qQQE=
749751
knative.dev/client/pkg v0.0.0-20250717154902-8216e64a8b5a/go.mod h1:/Re0d4acx7YTwmNGfgztvqp/T5hJAW/6t87265oCZFE=
750752
knative.dev/eventing v0.45.1-0.20250716223301-c9821a9395d6 h1:5LJW8k0u/6uGwgj5WVTCbk7idl0LZ18vKIGYN9J9hDg=

hack/generate-docs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
"fmt"
1919
"os"
2020

21-
"knative.dev/client-pkg/pkg/kn-source-pkg/pkg/core"
22-
"knative.dev/client-pkg/pkg/kn-source-pkg/pkg/util"
21+
"knative.dev/kn-plugin-source-kafka/pkg/common/core"
22+
"knative.dev/kn-plugin-source-kafka/pkg/common/util"
2323
"knative.dev/kn-plugin-source-kafka/pkg/factories"
2424
)
2525

pkg/client/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ package client
1717
import (
1818
"context"
1919

20-
knerrors "knative.dev/client-pkg/pkg/errors"
21-
sourceclient "knative.dev/client-pkg/pkg/kn-source-pkg/pkg/client"
22-
sourcetypes "knative.dev/client-pkg/pkg/kn-source-pkg/pkg/types"
20+
knerrors "knative.dev/client/pkg/errors"
2321
v1beta1 "knative.dev/eventing-kafka-broker/control-plane/pkg/apis/sources/v1beta1"
2422
clientv1beta1 "knative.dev/eventing-kafka-broker/control-plane/pkg/client/clientset/versioned/typed/sources/v1beta1"
23+
sourceclient "knative.dev/kn-plugin-source-kafka/pkg/common/client"
24+
sourcetypes "knative.dev/kn-plugin-source-kafka/pkg/common/types"
2525
"knative.dev/kn-plugin-source-kafka/pkg/types"
2626

2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

pkg/client/client_fake.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ package client
1717
import (
1818
"k8s.io/client-go/rest"
1919

20-
sourcetypes "knative.dev/client-pkg/pkg/kn-source-pkg/pkg/types"
21-
"knative.dev/client-pkg/pkg/kn-source-pkg/pkg/types/typesfakes"
2220
"knative.dev/eventing-kafka-broker/control-plane/pkg/client/clientset/versioned/typed/sources/v1beta1/fake"
21+
sourcetypes "knative.dev/kn-plugin-source-kafka/pkg/common/types"
22+
"knative.dev/kn-plugin-source-kafka/pkg/common/types/typesfakes"
2323
"knative.dev/kn-plugin-source-kafka/pkg/types"
2424
)
2525

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package client
1616

1717
import (
18-
"knative.dev/client-pkg/pkg/kn-source-pkg/pkg/types"
18+
"knative.dev/kn-plugin-source-kafka/pkg/common/types"
1919

2020
"k8s.io/client-go/rest"
2121
)

pkg/common/client/client_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright © 2020 The Knative Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package client
16+
17+
import (
18+
"testing"
19+
20+
"gotest.tools/v3/assert"
21+
22+
"knative.dev/kn-plugin-source-kafka/pkg/common/types"
23+
24+
"k8s.io/client-go/rest"
25+
)
26+
27+
func TestNewKnSourceClient(t *testing.T) {
28+
knSourceClient := newFakeKnSourceClient()
29+
assert.Assert(t, knSourceClient != nil)
30+
}
31+
32+
func TestKnSourceParams(t *testing.T) {
33+
knSourceClient := newFakeKnSourceClient()
34+
assert.Equal(t, knSourceClient.KnSourceParams(), knSourceClient.knSourceParams)
35+
}
36+
37+
func TestNamespace(t *testing.T) {
38+
knSourceClient := newFakeKnSourceClient()
39+
assert.Equal(t, knSourceClient.Namespace(), "fake-namespace")
40+
}
41+
42+
func TestRestConfig(t *testing.T) {
43+
knSourceClient := newFakeKnSourceClient()
44+
assert.Assert(t, knSourceClient.RestConfig() != nil)
45+
}
46+
47+
// Private
48+
49+
func newFakeKnSourceClient() *knSourceClient {
50+
return NewKnSourceClient(&types.KnSourceParams{}, &rest.Config{}, "fake-namespace").(*knSourceClient)
51+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package source
1616

1717
import (
1818
"github.com/spf13/cobra"
19-
"knative.dev/client-pkg/pkg/kn-source-pkg/pkg/types"
19+
"knative.dev/kn-plugin-source-kafka/pkg/common/types"
2020
)
2121

2222
// NewCreateCommand for creating event sources
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright © 2020 The Knative Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package source
16+
17+
import (
18+
"testing"
19+
20+
"gotest.tools/v3/assert"
21+
22+
"knative.dev/kn-plugin-source-kafka/pkg/common/types"
23+
)
24+
25+
func TestNewCreateCommand(t *testing.T) {
26+
createCmd := NewCreateCommand(&types.KnSourceParams{})
27+
assert.Assert(t, createCmd != nil)
28+
assert.Equal(t, createCmd.Use, "create NAME [flags]")
29+
assert.Equal(t, createCmd.Short, "create {{.Name}} source")
30+
assert.Equal(t, createCmd.Example, "{{.CreateExample}}")
31+
}

0 commit comments

Comments
 (0)