Update config util to take files as well as command-line text (#437)

This commit is contained in:
cybermaggedon 2025-07-16 19:55:04 +01:00 committed by GitHub
parent 54592b5e9f
commit a96d02da5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -118,7 +118,10 @@ def ensure_config(config, pulsar_host, pulsar_api_key):
print("Retrying...", flush=True) print("Retrying...", flush=True)
continue continue
def init(pulsar_admin_url, pulsar_host, pulsar_api_key, config, tenant): def init(
pulsar_admin_url, pulsar_host, pulsar_api_key, tenant,
config, config_file,
):
clusters = get_clusters(pulsar_admin_url) clusters = get_clusters(pulsar_admin_url)
@ -156,6 +159,18 @@ def init(pulsar_admin_url, pulsar_host, pulsar_api_key, config, tenant):
ensure_config(dec, pulsar_host, pulsar_api_key) ensure_config(dec, pulsar_host, pulsar_api_key)
elif config_file is not None:
try:
print("Decoding config...", flush=True)
dec = json.load(open(config_file))
print("Decoded.", flush=True)
except Exception as e:
print("Exception:", e, flush=True)
raise e
ensure_config(dec, pulsar_host, pulsar_api_key)
else: else:
print("No config to update.", flush=True) print("No config to update.", flush=True)
@ -188,6 +203,11 @@ def main():
help=f'Initial configuration to load', help=f'Initial configuration to load',
) )
parser.add_argument(
'-C', '--config-file',
help=f'Initial configuration to load from file',
)
parser.add_argument( parser.add_argument(
'-t', '--tenant', '-t', '--tenant',
default="tg", default="tg",