Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Allow default cluster_type #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions kafka_utils/kafka_check/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ def parse_args():
"--cluster-type",
"-t",
dest='cluster_type',
required=True,
help='Type of cluster',
help='Type of cluster. If not specified and there is only 1 cluster type configured, it will use that one.',
default=None,
)
parser.add_argument(
Expand Down
4 changes: 2 additions & 2 deletions kafka_utils/kafka_cluster_manager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def parse_args():
'--cluster-type',
'-t',
dest='cluster_type',
help='Type of the cluster.',
help='Type of cluster. If not specified and there is only 1 cluster type configured, it will use that one.',
type=str,
required=True,
default=None
)
parser.add_argument(
'--cluster-name',
Expand Down
4 changes: 2 additions & 2 deletions kafka_utils/kafka_consumer_manager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def parse_args():
"manipulate consumer offsets for a specific consumer group.",
)
parser.add_argument(
'--cluster-type', '-t', dest='cluster_type', required=True,
help='Type of Kafka cluster. This is a mandatory option.',
'--cluster-type', '-t', default=None, dest='cluster_type',
help='Type of cluster. If not specified and there is only 1 cluster type configured, it will use that one.',
)
parser.add_argument(
'--cluster-name', '-c', dest='cluster_name',
Expand Down
4 changes: 2 additions & 2 deletions kafka_utils/kafka_corruption_check/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def parse_args():
parser.add_argument(
'--cluster-type',
'-t',
required=True,
help='cluster type, e.g. "generic"',
default=None,
help='Type of cluster. If not specified and there is only 1 cluster type configured, it will use that one.',
)
parser.add_argument(
'--cluster-name',
Expand Down
4 changes: 2 additions & 2 deletions kafka_utils/kafka_rolling_restart/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def parse_opts():
parser.add_argument(
'--cluster-type',
'-t',
required=True,
help='cluster type, e.g. "standard"',
default=None,
help='Type of cluster. If not specified and there is only 1 cluster type configured, it will use that one.',
)
parser.add_argument(
'--cluster-name',
Expand Down
9 changes: 9 additions & 0 deletions kafka_utils/util/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ def get_cluster_config(
else:
config_dirs = [kafka_topology_base_path]

# If cluster_type is not set, and there is only one file in the config dir,
# then use that as the default cluster type
if cluster_type is None:
for config_dir in config_dirs:
cluster_types = [x for x in os.listdir(config_dir) if x.endswith(".yaml")]
if len(cluster_types) is 1:
cluster_type = cluster_types[0][:-5] # cut off the '.yaml' part
break

topology = None
for config_dir in config_dirs:
try:
Expand Down