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

Adopt pulsar-admin-go sources #1079

Merged
merged 188 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
79db72a
Create new CODEOWNERS file
streamnativebot Sep 29, 2022
2c53688
Initialize the pulsarctl project (streamnative/pulsarctl#1)
sijie Jul 12, 2019
5e2f9b9
Add post request for project (streamnative/pulsarctl#7)
wolfstudy Aug 27, 2019
d84261f
Add cluster commands `get` (streamnative/pulsarctl#4)
zymap Aug 28, 2019
8b5979e
Make API version configurable (streamnative/pulsarctl#16)
zymap Aug 29, 2019
9e94a03
Add auth logic for `pulsarctl` (streamnative/pulsarctl#20)
wolfstudy Aug 30, 2019
b20eb2d
Add command cluster `update` (streamnative/pulsarctl#17)
zymap Sep 2, 2019
a698196
Add command cluster `update-peer-clusters` (streamnative/pulsarctl#18)
zymap Sep 2, 2019
192b87e
Add command cluster `get-peer-clusters` (streamnative/pulsarctl#19)
zymap Sep 3, 2019
1e28e8f
Add create cmd of Pulsar Functions (streamnative/pulsarctl#15)
wolfstudy Sep 3, 2019
90834a4
Add stop cmd for Pulsar Functions (streamnative/pulsarctl#25)
wolfstudy Sep 3, 2019
57d8ee7
Add command cluster `create-failure-domain` (streamnative/pulsarctl#21)
zymap Sep 3, 2019
1f63aee
Add delete cmd for Pulsar Functions (streamnative/pulsarctl#26)
wolfstudy Sep 3, 2019
d4d1472
Add command cluster `get-failure-domain` (streamnative/pulsarctl#22)
zymap Sep 4, 2019
a5b8bae
Add start cmd for Pulsar Functions (streamnative/pulsarctl#29)
wolfstudy Sep 4, 2019
02c0f3a
Add command cluster `list-failure-domains` (streamnative/pulsarctl#23)
zymap Sep 4, 2019
71d7224
Add restart, list and get cmd for Pulsar Functions (streamnative/puls…
wolfstudy Sep 4, 2019
1d203f4
Add update cmd for Pulsar Functions (streamnative/pulsarctl#33)
wolfstudy Sep 5, 2019
01e17a1
Add command cluster `delete-failure-domain` (streamnative/pulsarctl#24)
zymap Sep 5, 2019
ba32e6f
Add namespace and topic name check (streamnative/pulsarctl#37)
zymap Sep 6, 2019
9bfc52a
Add more tests and add encode topic method (streamnative/pulsarctl#38)
zymap Sep 6, 2019
9533f19
Add command cluster `update_failure_domain` (streamnative/pulsarctl#36)
zymap Sep 7, 2019
50d8c21
Add tenants related commands (streamnative/pulsarctl#28)
zymap Sep 9, 2019
9e987e2
Add stats, status, querystate, putstate, trigger cmds for Pulsar Func…
wolfstudy Sep 9, 2019
4823f99
Add partitioned topic command CURD (streamnative/pulsarctl#35)
zymap Sep 10, 2019
6557e3e
Add source command for pulsarctl (streamnative/pulsarctl#45)
wolfstudy Sep 11, 2019
fcf9c63
[issue:50] fix response status code error (streamnative/pulsarctl#53)
wolfstudy Sep 11, 2019
905bdba
Add command topic `lookup` and `bundle-range` (streamnative/pulsarctl…
zymap Sep 13, 2019
ffcf921
Add schemas commands for pulsarctl (streamnative/pulsarctl#52)
wolfstudy Sep 14, 2019
618b458
Add sink commands for pulsarctl (streamnative/pulsarctl#47)
wolfstudy Sep 16, 2019
ed0bd39
Add command topic `last-message-id` (streamnative/pulsarctl#42)
zymap Sep 16, 2019
d547979
Add create, delete, list, policies, topic commands for namespace ctl …
wolfstudy Sep 17, 2019
47fe630
Add backlog, retention and ttl commands for pulsarctl (streamnative/p…
wolfstudy Sep 17, 2019
a6be62b
Revert "Add backlog, retention and ttl commands for pulsarctl (stream…
wolfstudy Sep 17, 2019
043f9f2
Add topic stats command (streamnative/pulsarctl#46)
zymap Sep 17, 2019
d6906a7
Add antiAffinityGroup, persistence, clusters, unload, spliteBundle an…
wolfstudy Sep 18, 2019
bbb4973
Add topic permissions commands (streamnative/pulsarctl#48)
zymap Sep 19, 2019
241ceed
Add license header check for all files (streamnative/pulsarctl#69)
zymap Sep 24, 2019
eeb51ca
Add command topic `internal-info` (streamnative/pulsarctl#51)
zymap Sep 24, 2019
62d9224
Add command unsubscribe and clearBacklog and command set and get for …
zymap Sep 24, 2019
96207c6
Add golangci-lint to check project style (streamnative/pulsarctl#78)
zymap Oct 3, 2019
9d97597
Add website for pulsarctl (streamnative/pulsarctl#77)
wolfstudy Oct 8, 2019
c376a4f
Add topic command `compact` and `compact-status` (streamnative/pulsar…
zymap Oct 9, 2019
5faa609
Add topic command `unload` (streamnative/pulsarctl#76)
zymap Oct 10, 2019
c7431ab
Add namespaces permissions commands (streamnative/pulsarctl#71)
zymap Oct 10, 2019
44c1aac
Add topic command `offload` and `offload-status` (streamnative/pulsar…
zymap Oct 10, 2019
7509f2e
Add topic command `terminate` (streamnative/pulsarctl#73)
zymap Oct 11, 2019
e8eddf1
Add set and get commands for MaxConsumersPerSub and MaxConsumersPerTo…
zymap Oct 12, 2019
3dad4be
Add schema, offload and compaction commands of namespaces for pulsasr…
zymap Oct 12, 2019
67df593
Add subscription commands (streamnative/pulsarctl#58)
zymap Oct 14, 2019
849abea
Add broker-stats commands for pulsarctl (streamnative/pulsarctl#84)
wolfstudy Oct 16, 2019
bfbdb5e
Add broker commands for pulsarctl (streamnative/pulsarctl#87)
wolfstudy Oct 16, 2019
171985e
Provide the token auth (streamnative/pulsarctl#91)
zymap Oct 18, 2019
f5c13be
Add pulsarctl version info (streamnative/pulsarctl#95)
wolfstudy Oct 18, 2019
01c3e12
Add comments for admin api (streamnative/pulsarctl#104)
wolfstudy Oct 24, 2019
c3a3843
Add timeout for the http client (streamnative/pulsarctl#93)
zymap Oct 24, 2019
60f46ec
Add `SCOPE` for topic commands (streamnative/pulsarctl#72)
zymap Oct 24, 2019
a3adddb
Add ns-isolation-policy commands for pulsarctl (streamnative/pulsarct…
wolfstudy Oct 24, 2019
99b35e2
Add functions-worker commands for pulsarctl (streamnative/pulsarctl#92)
wolfstudy Oct 24, 2019
3d6ec7d
Add resource-quotas commands for pulsarctl (streamnative/pulsarctl#90)
wolfstudy Oct 24, 2019
a1f0e92
Refactor pulsar pkg for pulsarctl (streamnative/pulsarctl#124)
wolfstudy Oct 30, 2019
db3c5ac
[Issue:128] Fix deploying python function (streamnative/pulsarctl#130)
wolfstudy Nov 5, 2019
65aac06
Move description.go to cmdutils (streamnative/pulsarctl#133)
zymap Nov 11, 2019
310a46a
[BK-SUPPORT-PART-1] Separate HTTP client and admin client (streamnati…
zymap Nov 13, 2019
a44d970
Support create key pair command (streamnative/pulsarctl#149)
zymap Dec 9, 2019
599b902
Support create secret key command (streamnative/pulsarctl#145)
zymap Dec 10, 2019
73e888e
Support create token command (streamnative/pulsarctl#150)
zymap Dec 11, 2019
4eb9f49
Support validate token command (streamnative/pulsarctl#151)
zymap Dec 11, 2019
7ba1432
Support show a token content (streamnative/pulsarctl#152)
zymap Dec 15, 2019
3954cc8
Fixes error handle for bookKeeper error message (streamnative/pulsarc…
zymap Dec 20, 2019
9bb6ea8
Fixes unexpected error when request using pulsar 2.4.2 proxy (streamn…
zymap Dec 20, 2019
088a04a
Fix wrong http header when receive pulsar header (streamnative/pulsar…
zymap Jan 6, 2020
20e52fb
Using testcontainer to create a test framework for testing (streamnat…
zymap Jan 12, 2020
9ec3108
Add test for the auto recovery command (streamnative/pulsarctl#170)
zymap Jan 13, 2020
e5de719
Add context for pulsarctl (streamnative/pulsarctl#169)
wolfstudy Jan 14, 2020
28b53af
[issue-126] Implement JSON output format for list commands (streamna…
EronWright Jan 15, 2020
6cfa41f
Rework auth and add pulsar client conf (streamnative/pulsarctl#196)
rivernate Jan 18, 2020
18fa650
[issue:197]Check Nil interface the right way (streamnative/pulsarctl#…
wolfstudy Jan 20, 2020
75573ab
[issue:182] get-function-assignments has incorrect output (streamnati…
wolfstudy Jan 20, 2020
496dc2b
Change NameSpaceAuth to be an [] of AuthAction (streamnative/pulsarct…
rivernate Jan 22, 2020
38f85ce
Add RetentionPolicy parsing (streamnative/pulsarctl#201)
rivernate Jan 22, 2020
b63a856
[Issue 183] Fixes can not parse the `destination_auth` (streamnative/…
zymap Feb 5, 2020
dcac222
[Issue 180] Make error log use stderr (streamnative/pulsarctl#206)
zymap Feb 11, 2020
fac76ac
Add download command for functions CLI (streamnative/pulsarctl#221)
wolfstudy Apr 1, 2020
3e6e8bf
Fixes nil pointer when using tls (streamnative/pulsarctl#231)
zymap Jun 23, 2020
f2fffb0
Support oauth2 authentication for pulsarctl (streamnative/pulsarctl#233)
zymap Jul 7, 2020
c2e676f
Improve the oauth2 implementation (streamnative/pulsarctl#237)
zymap Jul 16, 2020
67d8e7f
Fix the TLS not working when enable the oauth2 authentication (stream…
zymap Jul 27, 2020
038aa70
Fixes default api version to be v2 (streamnative/pulsarctl#250)
milos-matijasevic Nov 23, 2020
89dbabe
Escape special characters in parts of the URL (streamnative/pulsarctl…
evanbattaglia Nov 24, 2020
2e5f83f
Improve the current unit tests (streamnative/pulsarctl#253)
zymap Nov 24, 2020
6f3e431
Updating fields in utils data (streamnative/pulsarctl#254)
milos-matijasevic Dec 11, 2020
51e30e9
Improve the current CI checks (streamnative/pulsarctl#258)
zymap Dec 28, 2020
35e336b
Handle the null response body (streamnative/pulsarctl#272)
zymap Jan 15, 2021
95a13c5
Fix the function download command issue (streamnative/pulsarctl#275)
zymap Jan 27, 2021
8ee23e3
Upgrade dependencies (streamnative/pulsarctl#285)
zymap Feb 20, 2021
b62976b
Fix the error introduce from the latest pulsar (streamnative/pulsarct…
zymap Mar 19, 2021
c30e5e2
Adds namespace topic auto-creation configuration (streamnative/pulsar…
volgorean May 14, 2021
6d4f084
Clone default transport instead of modifying directly (streamnative/p…
volgorean May 17, 2021
9da9310
Adds the `isOffloaded` field (streamnative/pulsarctl#288)
rivernate May 28, 2021
5e5bd64
Add command topic message ttl. (streamnative/pulsarctl#246) (#348)
limingnihao Jun 2, 2021
90376e2
Add command topic max producers. (streamnative/pulsarctl#246) (#353)
limingnihao Jun 2, 2021
42e66cd
Add command topic max consumers. (streamnative/pulsarctl#246) (#355)
limingnihao Jun 2, 2021
961a513
Add command topic max unacked messages per consumer. (streamnative/pu…
limingnihao Jun 3, 2021
4a89f57
Add command topic max unacked messages per subscription. (streamnativ…
limingnihao Jun 7, 2021
9765d75
Add command topic Persistence Policy. (streamnative/pulsarctl#246) (#…
limingnihao Jun 9, 2021
573d201
Support using Json to configure the token auth provider (streamnative…
zymap Jun 14, 2021
76cf94c
Support use short auth name to configure auth (streamnative/pulsarctl…
zymap Jun 15, 2021
8d49516
Bump version to 2.8.0-rc-202106151929 (streamnative/pulsarctl#372)
streamnativebot Jun 17, 2021
5ed4992
Add command topic Delayed Delivery Policies. (streamnative/pulsarctl#…
limingnihao Jun 18, 2021
be9fec9
Add command topic message dispatch rate. (streamnative/pulsarctl#246)…
limingnihao Jul 20, 2021
244b6ed
Fix the 400 error when create function (streamnative/pulsarctl#405)
zymap Jul 29, 2021
8c53ab7
Add command topic Deduplication(streamnative/pulsarctl#246) (#408)
limingnihao Aug 4, 2021
9b52eb6
fix: check the parse service url for errors (streamnative/pulsarctl#395)
nodece Aug 4, 2021
d790ef2
Fix the sink and source tests (streamnative/pulsarctl#411)
zymap Aug 6, 2021
2923f2b
Remove unknown error (streamnative/pulsarctl#422)
nodece Aug 16, 2021
33f895a
add pulsarctl namespace/topic set-publish-rate (streamnative/pulsarct…
flowchartsman Aug 20, 2021
2680f18
feat: add get/remove/set retention policy command for topic (streamna…
nodece Aug 23, 2021
0ed0f54
feat: add compaction threshold command for topic (streamnative/pulsar…
nodece Aug 30, 2021
20f6a8e
feat: add backlog quota command for topic (streamnative/pulsarctl#429)
nodece Sep 1, 2021
6b7464c
Add customRuntimeOptions to sinks and functions (streamnative/pulsarc…
jaysonsantos Sep 16, 2021
ae4c682
add packages management service APIs (streamnative/pulsarctl#450)
freeznet Sep 22, 2021
0625d9f
fix packages cmds (streamnative/pulsarctl#458)
freeznet Sep 24, 2021
05ca3bc
feat: add inactive topic policies command for topic (streamnative/pul…
nodece Sep 28, 2021
1dc569a
fix: fix checks the packages url and file path of the upload package …
nodece Sep 28, 2021
6f32c65
OAuth 2.0 Usability Improvements (+Azure AD) (streamnative/pulsarctl#…
EronWright Oct 7, 2021
e130e8b
Add support for sourceSubscriptionName to sinks (streamnative/pulsarc…
jaysonsantos Oct 9, 2021
b496a57
Support BacklogQuotaType when setting namespace backlog. (streamnativ…
MarvinCai Oct 23, 2021
ab53af8
fix: improve parse response avoid parse the empty body (streamnative/…
nodece Oct 26, 2021
36b3d58
Remove omitempty from booleans (streamnative/pulsarctl#500)
jaysonsantos Nov 4, 2021
0d85b55
ParseAuthAction supports new actions (streamnative/pulsarctl#512)
FushuWang Nov 25, 2021
870ba2e
fix: improve new client with auth provider (streamnative/pulsarctl#518)
nodece Dec 6, 2021
c322483
bump pulsar-client-go/oauth2 (streamnative/pulsarctl#533)
freeznet Dec 29, 2021
71d5a2a
fix: update type in namespace policies (streamnative/pulsarctl#556)
nodece Jan 11, 2022
94451d2
feat: add allow auto update schema cmd (streamnative/pulsarctl#567)
nodece Jan 24, 2022
75303e3
fix: create non-partitions topic (streamnative/pulsarctl#577)
nodece Feb 11, 2022
e72d8cc
fix: fix encode json body (streamnative/pulsarctl#610)
nodece Feb 18, 2022
8010192
fix: use nil instead of empty string as request body (streamnative/pu…
nodece Apr 29, 2022
d4139b6
support build with go 1.18 (streamnative/pulsarctl#699)
freeznet May 5, 2022
b508b2e
fix: fix tls insecure connection (streamnative/pulsarctl#731)
nodece Jun 6, 2022
effa6a9
Fix test new with custom auth provider (streamnative/pulsarctl#734)
nodece Jun 8, 2022
9455f79
fix: Remove encoding for the topic (streamnative/pulsarctl#828)
nodece Sep 14, 2022
fba5f5a
Update pulsarctl go version (streamnative/pulsarctl#853)
tuteng Oct 10, 2022
02a248d
add fields to topic stats (streamnative/pulsarctl#858)
wnyffenegger Oct 18, 2022
c4f9572
add estimated backlog size as measure of unconsumed messages (streamn…
wnyffenegger Oct 19, 2022
0eb52ba
support oauth2 with auth params (streamnative/pulsarctl#876)
freeznet Nov 7, 2022
09eb376
update resource keys to match comments (streamnative/pulsarctl#879)
asher-goldberg Nov 11, 2022
b03a0b2
Add get-message-by-id command (streamnative/pulsarctl#882)
nodece Nov 11, 2022
83d4413
fix: add miss fields to PersistentTopicInternalStats (streamnative/pu…
nodece Dec 12, 2022
2cfc156
Upgrade jwt package, support custom claim and header (streamnative/pu…
tuteng Dec 12, 2022
edefe76
Fix the wrong field of the internal stats and internal info (streamna…
zymap Dec 12, 2022
d3f0117
feat: support delete a subscription forcefully (streamnative/pulsarct…
nodece Dec 12, 2022
939d6f8
fix: fix token exp (streamnative/pulsarctl#976)
nodece Jan 31, 2023
f73cfe4
Add auth parameter to cluster management (streamnative/pulsarctl#986)
FushuWang Feb 17, 2023
27d1342
chore: go mod tidy
maxsxu Mar 1, 2023
68ea0e1
chore: add gitignore
maxsxu Mar 1, 2023
36dfedb
Bump golang.org/x/net from 0.0.0-20220225172249-27dd8689420f to 0.7.0…
dependabot[bot] Mar 8, 2023
ca7def0
Optimize project layout (streamnative/pulsar-admin-go#3)
maxsxu Mar 9, 2023
7c75a56
Decouple config and auth package (streamnative/pulsar-admin-go#4)
maxsxu Mar 14, 2023
8e11919
Add alias package (streamnative/pulsar-admin-go#5)
maxsxu Mar 16, 2023
5d930d4
fix: golangci-lint errors (streamnative/pulsar-admin-go#7)
maxsxu Mar 16, 2023
acd0207
ci: add lint and test (streamnative/pulsar-admin-go#6)
maxsxu Mar 16, 2023
0538889
chore: clean non-admin apis (streamnative/pulsar-admin-go#9)
maxsxu Mar 16, 2023
3926994
ci: add release workflow (streamnative/pulsar-admin-go#8)
maxsxu Mar 16, 2023
c0e22e8
docs: add README, LICENSE and CONTRIBUTING (streamnative/pulsar-admin…
maxsxu Mar 17, 2023
05d5764
fix: change copyright from ASF to StreamNative (streamnative/pulsar-a…
ericsyh Mar 18, 2023
8d40cc3
ci: add license header checker (streamnative/pulsar-admin-go#12)
maxsxu Mar 20, 2023
ccfe95e
chore: add Makefile (streamnative/pulsar-admin-go#13)
maxsxu Mar 20, 2023
3a224be
chore: replace deprecated ioutil pkg (streamnative/pulsar-admin-go#14)
maxsxu Mar 20, 2023
25e3907
fix: use auth provider as http round tripper (streamnative/pulsar-adm…
maxsxu Mar 22, 2023
20b2874
fix: config oauth2 with default flow (streamnative/pulsar-admin-go#16)
maxsxu Mar 23, 2023
e833c7a
docs: complete code demo (streamnative/pulsar-admin-go#17)
FushuWang Mar 23, 2023
d625c57
ci: add conventional commits PR title checker (streamnative/pulsar-ad…
maxsxu Mar 23, 2023
72084f3
docs: update contribution guides (streamnative/pulsar-admin-go#19)
maxsxu Mar 24, 2023
313eb6a
docs: add go reference badge (streamnative/pulsar-admin-go#20)
maxsxu Mar 27, 2023
28ce722
docs: add go report card badge (streamnative/pulsar-admin-go#21)
maxsxu Mar 27, 2023
1c2a9b0
feat: add new parameters for creating cluster (streamnative/pulsar-ad…
FushuWang Apr 23, 2023
8bc22e3
fix: keyring file dir path (streamnative/pulsar-admin-go#26)
maxsxu Jun 9, 2023
7a1166b
feat: Align function/sink/source config with pulsar master(@2b01f83e)…
jiangpengcheng Jun 30, 2023
03e087c
feat: add GetMessageID api (streamnative/pulsar-admin-go#28)
chrisxrepo Jul 7, 2023
96a43a2
feat: adds support for namespace scoped inactive topic policies (stre…
volgorean Jul 14, 2023
9d624d9
chore: add pull request template (streamnative/pulsar-admin-go#33)
maxsxu Jul 14, 2023
c1b9f76
feat: create parent dir for package downloading when necessary (strea…
jiangpengcheng Jul 19, 2023
08f1894
fix: use pointer for struct field so the default value from unmarshal…
jiangpengcheng Jul 19, 2023
c8416f0
fix: remove omitempty for bool value (streamnative/pulsar-admin-go#38)
jiangpengcheng Jul 20, 2023
df138b5
fix: Fix wrong model field (streamnative/pulsar-admin-go#42)
mattisonchao Aug 13, 2023
fe16fa6
chore: tidy pulsar-admin-go sources
tisonkun Aug 15, 2023
912281b
replace license header
tisonkun Aug 15, 2023
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ GOROOT ?= $(shell go env GOROOT)

build:
go build ./pulsar
go build ./pulsaradmin
go build -o bin/pulsar-perf ./perf

lint: bin/golangci-lint
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ require (
golang.org/x/mod v0.5.1
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/protobuf v1.30.0
)

require github.com/golang/protobuf v1.5.2

require (
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/ardielle/ardielle-go v1.5.2 // indirect
Expand All @@ -39,7 +41,6 @@ require (
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
Expand Down
60 changes: 60 additions & 0 deletions pulsaradmin/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Contributing guidelines

## Project structure

The overall project structure is illustrated below:

```text
├── pkg/
│ ├── admin/
│ │ ├── auth/
│ │ ├── config/
│ ├── rest/
│ └── utils/
└── alias.go
```

- The `alias.go` file in the root defines `pulsaradmin` package scope, which contains shortcuts of some types and functions from the `pkg`.
- The `pkg/admin` package contains all operations for pulsar admin resources. *Note: We should add a new file here if we wanna support a new resource.*
- The `pkg/admin/config` package contains configuration options for constructing a pulsar admin client.
- The `pkg/admin/auth` package contains auth providers which work in transport layer.
- The `pkg/rest` package contains a wrapped HTTP client for requesting pulsar REST API.
- The `pkg/utils` package contains common data structures and functions.

## Contributing steps
1. Submit an issue describing your proposed change.
2. Discuss and wait for proposal to be accepted.
3. Fork this repo, develop and test your code changes.
4. Submit a pull request.

## Conventions

Please read through below conventions before contributions.

### PullRequest conventions

- Use [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) to standardize PR title.

### Code conventions

- [Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments)
- [Effective Go](https://golang.org/doc/effective_go.html)
- Know and avoid [Go landmines](https://gist.github.com/lavalamp/4bd23295a9f32706a48f)
- Commenting
- [Go's commenting conventions](http://blog.golang.org/godoc-documenting-go-code)
- If reviewers ask questions about why the code is the way it is, that's a sign that comments might be helpful.
- Naming
- Please consider package name when selecting an interface name, and avoid redundancy. For example, `storage.Interface` is better than `storage.StorageInterface`.
- Do not use uppercase characters, underscores, or dashes in package names.
- Please consider parent directory name when choosing a package name. For example, `pkg/controllers/autoscaler/foo.go` should say `package autoscaler` not `package autoscalercontroller`.
- Unless there's a good reason, the `package foo` line should match the name of the directory in which the `.go` file exists.
- Importers can use a different name if they need to disambiguate.
- Locks should be called `lock` and should never be embedded (always `lock sync.Mutex`). When multiple locks are present, give each lock a distinct name following Go conventions: `stateLock`, `mapLock` etc.

### Folder and file conventions

- All filenames should be lowercase.
- Go source files and directories use underscores, not dashes.
- Package directories should generally avoid using separators as much as possible. When package names are multiple words, they usually should be in nested subdirectories.
- Document directories and filenames should use dashes rather than underscores.
- All source files should add a license at the beginning.
114 changes: 114 additions & 0 deletions pulsaradmin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Pulsar Admin Go Library

Pulsar-Admin-Go is a [Go](https://go.dev) library for [Apache Pulsar](https://pulsar.apache.org/). It provides a unified Go API for managing pulsar resources such as tenants, namespaces and topics, etc.

## Motivation

Currently, many projects (e.g, [terraform-provider-pulsar](https://github.com/streamnative/terraform-provider-pulsar) and [pulsar-resources-operator](https://github.com/streamnative/pulsar-resources-operator))
that need to manipulate the pulsar admin resources rely on the [pulsarctl](https://github.com/streamnative/pulsarctl),
which poses challenges for dependency management and versioning as we have to release a new pulsarctl to get updates.
So we decoupled the pulsar admin related api from pulsarctl and created the [pulsar-admin-go](https://github.com/apache/pulsar-client-go/pulsaradmin) library based on it,
which also provides a clearer perspective and maintainability from an architectural perspective.

## Quickstart

### Prerequisite

- go1.18+
- pulsar-admin-go in go.mod

```shell
go get github.com/apache/pulsar-client-go
```

### Manage pulsar tenants

- List all tenants

```go
import (
"github.com/apache/pulsar-client-go/pulsaradmin"
)

func main() {
cfg := &pulsaradmin.Config{}
admin, err := pulsaradmin.NewClient(cfg)
if err != nil {
panic(err)
}

tenants, _ := admin.Tenants().List()
}
```

### Manage pulsar namespaces

- List all namespaces

```go
import (
"github.com/apache/pulsar-client-go/pulsaradmin"
)

func main() {
cfg := &pulsaradmin.Config{}
admin, err := pulsaradmin.NewClient(cfg)
if err != nil {
panic(err)
}

namespaces, _ := admin.Namespaces().GetNamespaces("public")
}
```

- Create a new namespace

```go
import (
"github.com/apache/pulsar-client-go/pulsaradmin"
)

func main() {
cfg := &pulsaradmin.Config{}
admin, err := pulsaradmin.NewClient(cfg)
if err != nil {
panic(err)
}

admin.Namespaces().CreateNamespace("public/dev")
}
```

### Manage pulsar topics

- Create a topic

```go

import (
"github.com/apache/pulsar-client-go/pulsaradmin"
"github.com/apache/pulsar-client-go/pulsaradmin/pkg/utils"
)

func main() {
cfg := &pulsaradmin.Config{}
admin, err := pulsaradmin.NewClient(cfg)
if err != nil {
panic(err)
}

topic, _ := utils.GetTopicName("public/dev/topic")

admin.Topics().Create(*topic, 3)
}
```

## Contributing

Contributions are warmly welcomed and greatly appreciated!
The project follows the typical GitHub pull request model. See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
Before starting any work, please either comment on an existing issue, or file a new one.

## License

Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
34 changes: 34 additions & 0 deletions pulsaradmin/alias.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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.

package pulsaradmin

import (
"github.com/apache/pulsar-client-go/pulsaradmin/pkg/admin"
"github.com/apache/pulsar-client-go/pulsaradmin/pkg/admin/config"
)

// Client contains all admin interfaces for operating pulsar resources
type Client = admin.Client

// Config are the arguments for creating a new admin Client
type Config = config.Config

var (
// NewClient returns a new admin Client for operating pulsar resources
NewClient = admin.New
)
114 changes: 114 additions & 0 deletions pulsaradmin/pkg/admin/admin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// 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.

package admin

import (
"net/http"
"net/url"
"path"
"time"

"github.com/apache/pulsar-client-go/pulsaradmin/pkg/admin/auth"
"github.com/apache/pulsar-client-go/pulsaradmin/pkg/admin/config"
"github.com/apache/pulsar-client-go/pulsaradmin/pkg/rest"
"github.com/apache/pulsar-client-go/pulsaradmin/pkg/utils"
)

const (
DefaultWebServiceURL = "http://localhost:8080"
DefaultHTTPTimeOutDuration = 5 * time.Minute
ReleaseVersion = "None"
)

type TLSOptions struct {
TrustCertsFilePath string
AllowInsecureConnection bool
}

// Client provides a client to the Pulsar Restful API
type Client interface {
Clusters() Clusters
Functions() Functions
Tenants() Tenants
Topics() Topics
Subscriptions() Subscriptions
Sources() Sources
Sinks() Sinks
Namespaces() Namespaces
Schemas() Schema
NsIsolationPolicy() NsIsolationPolicy
Brokers() Brokers
BrokerStats() BrokerStats
ResourceQuotas() ResourceQuotas
FunctionsWorker() FunctionsWorker
Packages() Packages
}

type pulsarClient struct {
Client *rest.Client
APIVersion config.APIVersion
}

// New returns a new client
func New(config *config.Config) (Client, error) {
authProvider, err := auth.GetAuthProvider(config)
if err != nil {
return nil, err
}
return NewPulsarClientWithAuthProvider(config, authProvider)
}

// NewWithAuthProvider creates a client with auth provider.
// Deprecated: Use NewPulsarClientWithAuthProvider instead.
func NewWithAuthProvider(config *config.Config, authProvider auth.Provider) Client {
client, err := NewPulsarClientWithAuthProvider(config, authProvider)
if err != nil {
panic(err)
}
return client
}

// NewPulsarClientWithAuthProvider create a client with auth provider.
func NewPulsarClientWithAuthProvider(config *config.Config, authProvider auth.Provider) (Client, error) {
if len(config.WebServiceURL) == 0 {
config.WebServiceURL = DefaultWebServiceURL
}

return &pulsarClient{
APIVersion: config.PulsarAPIVersion,
Client: &rest.Client{
ServiceURL: config.WebServiceURL,
VersionInfo: ReleaseVersion,
HTTPClient: &http.Client{
Timeout: DefaultHTTPTimeOutDuration,
Transport: authProvider,
},
},
}, nil
}

func (c *pulsarClient) endpoint(componentPath string, parts ...string) string {
escapedParts := make([]string, len(parts))
for i, part := range parts {
escapedParts[i] = url.PathEscape(part)
}
return path.Join(
utils.MakeHTTPPath(c.APIVersion.String(), componentPath),
path.Join(escapedParts...),
)
}
Loading