Skip to content

Instantly share code, notes, and snippets.

@visortelle
Last active July 2, 2023 07:12
Show Gist options
  • Save visortelle/9b94d8a6e10fe585e022d78029f6b182 to your computer and use it in GitHub Desktop.
Save visortelle/9b94d8a6e10fe585e022d78029f6b182 to your computer and use it in GitHub Desktop.
Aliases for Apache Pulsar CLI tools with JWT auth. Add it to your ~/.bashrc or ~/.zshrc.

Aliases for Apache Pulsar CLI tools with JWT auth

Usage

  • Add the pulsar-cli-aliases.shfile content to your ~/.bashrc or ~/.zshrc.
  • Fill pulsar_jwt, pulsar_url, pulsar_admin_url with your values.
  • Then use short commands like pa topics stats public/default/topic-a instead of
pulsar-admin \
    --admin-url https://cluster-123.o-xgfek.snio.cloud \
    --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationToken \
    --auth-params token:eyJhbGciOiJSUzI1fasdfNiIscCI6IkpXVCIsImtpZCI6Ik5rRXdSVasdfVVOQlJrWTJNalEzTVRZek9FVkZRVVUyT0RNME5qUkRRVEU1T1VNMU16STVPUSJ9.eyJodHRwczovL3N0cmVhbW5hdGl2ZS5pby91c2VybmFtZSI6ImNsdXN0ZXItYi1hZG1pbkBvLXh5NmVrLmF1dGguc3RyZWFtbmF0aXZlLmNsb3VkIiwiaXNzIjoiaHR0cHM6Ly9hdXRoLnN0cmVhbW5hdGl2ZS5jbG91ZC8iLCJzdWIiOiJ6NUQxcVIyTllxN250amhZN0dHSnZqNkRrcG1PRk1EREBjbGllbnRzIiwiYXVkIjoidXJuOnNuOnB1bHNhcjpvLXh5NmVrOmluc3RhbmNlLWMiLCJpYXQiOjE2ODY1Njg2NTIsImV4cCI6MTY4NzE3MzQ1MiwiYXpwIjoiejVEMXFSMk5ZcTdudGpoWTdHR0p2ajZEa3BtT0ZNREQiLCJzY29wZSI6ImFkbWluIGFjY2VzcyIsImd0eSI6ImNsaWVudC1jcmVkZW50aWFscyIsInBlcm1pc3Npb25zIjpbImFkbWluIiwiYWNjZXNzIl19.f7eqvFCE90OXCQMMsg2ziQ3r32Ixb0kH_W8QErVZBpeH5lZbley3Vy78M75s3vXHdyhiwaGK8UIe43jP3x1OoHV4bkM0DMIKYEQ7dhAdG9D1oE4_dyvaoJddtdpLGAPvyQUhJTR75PyD3ynkYdOuNqhguCGMwc0Nr1CEtrje0s3YRcycfpypXH59c4-GrjEfT9h-VXCVQxDG-SkG8H0SkuJJDZUawbIX8cEUBiDRsZmd4zzQx_uBDSBtvfzmohtdlA_C8OPO1C-1vdj624aslz0ssq4uz_hivDZEHIdKWlX3jJm4Mzf6toXYMaFoXH1leYgJ_xO28rzTOlCVQ2sMcw \
    topics stats public/default/topic-a
pulsar_jwt="..."
pulsar_url="..."
pulsar_admin_url="..."
pc() {
pulsar-client \
--url ${pulsar_url} \
--auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationToken \
--auth-params token:${pulsar_jwt} \
$@
}
export -f pc &> /dev/null
pa() {
pulsar-admin \
--admin-url ${pulsar_admin_url} \
--auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationToken \
--auth-params token:${pulsar_jwt} \
$@
}
export -f pa &> /dev/null
pperf() {
pulsar-perf \
$@ \
--service-url ${pulsar_url} \
--auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationToken \
--auth-params token:${pulsar_jwt}
}
export -f pperf &> /dev/null
@visortelle
Copy link
Author

@alexesom good catch. Fixed.
In Zsh it's a valid syntax, but Bash fails with an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment