Skip to content

Commit

Permalink
Bring current completions up-to-date with Kafka 0.11 in switches and …
Browse files Browse the repository at this point in the history
…1.0 in producer and consumer properties. Add kafka-acls completion. Complete kafka utilities that end with .sh as well (e.g both kafka-acls and kafka-acls.sh).

Signed-off-by: Marios Andreopoulos <[email protected]>
  • Loading branch information
andmarios committed Dec 1, 2017
1 parent 2c19a9e commit 8155e51
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 8 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ You will find the completion file under `release/kafka`. You can source it in
your terminal or drop it in `/etc/bash_completion.d/`. You have to set up
bash-completion too, which depends on your distribution of choice.

Currently completion is provided for three utilities:
Currently completion is provided for five utilities:

- kafka-topics
- kafka-console-consumer
- kafka-console-producer
- kafka-console-consumer / kafka-avro-console-consumer
- kafka-console-producer / kafka-avro-console-producer
- kafka-mirrormaker
- kafka-acls

We provide completion for options, kafka configs and kafka properties.
Especially for `kafka-topics` if you set the `--zookeeper` switch, we try to
Expand Down
104 changes: 104 additions & 0 deletions src/kafka-acls
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# bash completion for kafka-acls -*- shell-script -*-

_landoop-acls-operations()
{
local cur prev configs
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
configs="Read \
Write \
Create \
Delete \
Alter \
Describe \
ClusterAction \
AlterConfigs \
DescribeConfigs \
IdempotentWrite \
All"

COMPREPLY=( $(compgen -W "${configs}" -- ${cur}) )
compopt -o nospace
return 0
}

_landoop-acls-authorizer-configs()
{
local cur prev configs
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
configs="zookeeper.connect="

COMPREPLY=( $(compgen -W "${configs}" -- ${cur}) )
compopt -o nospace
return 0
}

_landoop-kafka-acls() {
local cur prev opts wotherarg wfileargs wdirargs allopts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
wotherarg="--allow-host \
--allow-principal \
--authorizer \
--deny-host \
--deny-principal \
--group \
--operation \
--topic \
--transactional-id"
# wfileargs=""
# wdirargs=""
opts="--add \
--cluster \
--consumer \
--force \
--help \
--idempotent \
--list \
--producer \
--remove"
allopts="$wotherarg $opts $wfileargs $wdirargs"

case "$prev" in
--allow_host)
_known_hosts
return 0
;;
--deny-host)
_known_hosts
return 0
;;
--authorizer)
_landoop-acls-authorizer-configs
return 0
;;
--operation)
_landoop-acls-operations
return 0
;;
# @(${wfileargs// /|}))
# _filedir
# return 0
# ;;
# @(${wdirargs// /|}))
# _filedir -d
# return 0
# ;;
@(${wotherarg// /|}))
return 0
;;
esac

if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${allopts}" -- ${cur}) )
return 0
fi
}

complete -F _landoop-kafka-acls kafka-acls
complete -F _landoop-kafka-acls kafka-acls.sh

21 changes: 21 additions & 0 deletions src/kafka-console-consumer
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ _landoop-consumer-configs()
enable.auto.commit= \
exclude.internal.topics= \
fetch.max.bytes= \
isolation.level= \
max.poll.interval.ms= \
max.poll.records= \
partition.assignment.strategy= \
Expand Down Expand Up @@ -66,6 +67,19 @@ _landoop-consumer-configs()
return 0
}

_landoop-consumer-isolation-configs()
{
local cur prev configs
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
configs="read_committed \
read_uncommitted"

COMPREPLY=( $(compgen -W "${configs}" -- ${cur}) )
compopt -o nospace
return 0
}

_landoop-kafka-console-consumer() {
local cur prev opts wotherarg wfileargs wdirargs allopts
Expand All @@ -76,6 +90,7 @@ _landoop-kafka-console-consumer() {
--bootstrap-server \
--consumer-property \
--formatter \
--isolation-level \
--key-deserializer \
--max-messages \
--offset \
Expand Down Expand Up @@ -106,6 +121,10 @@ _landoop-kafka-console-consumer() {
_landoop-consumer-configs
return 0
;;
--isolation-level)
_landoop-consumer-isolation-configs
return 0
;;
@(${wfileargs// /|}))
_filedir
return 0
Expand All @@ -127,3 +146,5 @@ _landoop-kafka-console-consumer() {

complete -F _landoop-kafka-console-consumer kafka-console-consumer
complete -F _landoop-kafka-console-consumer kafka-avro-console-consumer
complete -F _landoop-kafka-console-consumer kafka-console-consumer.sh
complete -F _landoop-kafka-console-consumer kafka-avro-console-consumer.sh
29 changes: 26 additions & 3 deletions src/kafka-console-producer
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ _landoop-producer-configs()
ssl.protocol= \
ssl.provider= \
ssl.truststore.type= \
timeout.ms= \
block.on.buffer.full= \
enable.idempotence= \
interceptor.classes= \
max.in.flight.requests.per.connection= \
metadata.fetch.timeout.ms= \
metadata.max.age.ms= \
metric.reporters= \
metrics.num.samples= \
metrics.recording.level= \
metrics.sample.window.ms= \
reconnect.backoff.ms= \
retry.backoff.ms= \
Expand All @@ -56,13 +56,30 @@ _landoop-producer-configs()
ssl.endpoint.identification.algorithm= \
ssl.keymanager.algorithm= \
ssl.secure.random.implementation= \
ssl.trustmanager.algorithm="
ssl.trustmanager.algorithm= \
transaction.timeout.ms \
transactional.id"

COMPREPLY=( $(compgen -W "${configs}" -- ${cur}) )
compopt -o nospace
return 0
}

_landoop-producer-compression-configs()
{
local cur prev configs
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
configs="none \
gzip \
snappy \
lz4"

COMPREPLY=( $(compgen -W "${configs}" -- ${cur}) )
compopt -o nospace
return 0
}

_landoop-kafka-console-producer() {
local cur prev opts wotherarg wfileargs wdirargs allopts
Expand Down Expand Up @@ -106,6 +123,10 @@ _landoop-kafka-console-producer() {
_landoop-producer-configs
return 0
;;
--compression-codec)
_landoop-producer-compression-configs
return 0
;;
@(${wfileargs// /|}))
_filedir
return 0
Expand All @@ -127,3 +148,5 @@ _landoop-kafka-console-producer() {

complete -F _landoop-kafka-console-producer kafka-console-producer
complete -F _landoop-kafka-console-producer kafka-avro-console-producer
complete -F _landoop-kafka-console-producer kafka-console-producer.sh
complete -F _landoop-kafka-console-producer kafka-avro-console-producer.sh
1 change: 1 addition & 0 deletions src/kafka-mirror-maker
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ _landoop-kafka-mirror-maker() {
}

complete -F _landoop-kafka-mirror-maker kafka-mirror-maker
complete -F _landoop-kafka-mirror-maker kafka-mirror-maker.sh
5 changes: 3 additions & 2 deletions src/kafka-topics
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ _landoop-kafka-topics-configs()
file.delete.delay.ms= \
flush.messages= \
flush.ms= \
follower.replication.throttled= \
follower.replication.throttled.replicas= \
index.interval.bytes= \
leader.replication.throttled.replicas= \
max.message.bytes= \
Expand Down Expand Up @@ -48,7 +48,7 @@ _landoop-kafka-topics-delete-configs()
file.delete.delay.ms \
flush.messages \
flush.ms \
follower.replication.throttled \
follower.replication.throttled.replicas \
index.interval.bytes \
leader.replication.throttled.replicas \
max.message.bytes \
Expand Down Expand Up @@ -147,3 +147,4 @@ _landoop-kafka-topics() {
}

complete -F _landoop-kafka-topics kafka-topics
complete -F _landoop-kafka-topics kafka-topics.sh

0 comments on commit 8155e51

Please sign in to comment.