sync
This commit is contained in:
@@ -239,7 +239,8 @@ Examples:
|
||||
|
||||
parser.add_argument(
|
||||
'--addr',
|
||||
default=os.environ.get('CONSUL_HTTP_ADDR', 'http://consul.service.dc1.consul:8500'),
|
||||
# Handle case where env var exists but is empty
|
||||
default=os.environ.get('CONSUL_HTTP_ADDR') or 'http://consul.service.dc1.consul:8500',
|
||||
help='Consul API address (default: $CONSUL_HTTP_ADDR or http://consul.service.dc1.consul:8500)'
|
||||
)
|
||||
|
||||
@@ -257,10 +258,24 @@ Examples:
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Debug: Check what values we're getting
|
||||
env_addr = os.environ.get('CONSUL_HTTP_ADDR')
|
||||
print(f"DEBUG: CONSUL_HTTP_ADDR env var: {repr(env_addr)}")
|
||||
print(f"DEBUG: args.addr: {repr(args.addr)}")
|
||||
|
||||
# Show which Consul server we're connecting to
|
||||
consul_source = "environment variable CONSUL_HTTP_ADDR" if os.environ.get('CONSUL_HTTP_ADDR') else "default address"
|
||||
# Check if env var exists and is not empty
|
||||
if env_addr and env_addr.strip():
|
||||
consul_source = "environment variable CONSUL_HTTP_ADDR"
|
||||
else:
|
||||
consul_source = "default address"
|
||||
print(f"Using Consul server from {consul_source}: {args.addr}")
|
||||
|
||||
# Validate the address is not empty
|
||||
if not args.addr or args.addr.strip() == '':
|
||||
print("ERROR: Consul address is empty! Please set CONSUL_HTTP_ADDR environment variable or use --addr flag")
|
||||
sys.exit(1)
|
||||
|
||||
# Create backup client and run backup
|
||||
backup = ConsulBackup(consul_addr=args.addr, token=args.token)
|
||||
exit_code = backup.backup_kv_store(output_dir=args.output)
|
||||
|
||||
Reference in New Issue
Block a user