3
3
import sys
4
4
from datetime import datetime
5
5
from io import BytesIO
6
+ from typing import Optional
6
7
7
8
import click
8
9
from test_framework .messages import ser_uint256
@@ -22,22 +23,24 @@ def bitcoin():
22
23
@click .argument ("tank" , type = str )
23
24
@click .argument ("method" , type = str )
24
25
@click .argument ("params" , type = str , nargs = - 1 ) # this will capture all remaining arguments
25
- def rpc (tank : str , method : str , params : str ):
26
+ @click .option ("--namespace" , default = None , show_default = True )
27
+ def rpc (tank : str , method : str , params : str , namespace : Optional [str ]):
26
28
"""
27
29
Call bitcoin-cli <method> [params] on <tank pod name>
28
30
"""
29
31
try :
30
- result = _rpc (tank , method , params )
32
+ result = _rpc (tank , method , params , namespace )
31
33
except Exception as e :
32
34
print (f"{ e } " )
33
35
sys .exit (1 )
34
36
print (result )
35
37
36
38
37
- def _rpc (tank : str , method : str , params : str ):
39
+ def _rpc (tank : str , method : str , params : str , namespace : Optional [ str ] = None ):
38
40
# bitcoin-cli should be able to read bitcoin.conf inside the container
39
41
# so no extra args like port, chain, username or password are needed
40
- namespace = get_default_namespace ()
42
+ if not namespace :
43
+ namespace = get_default_namespace ()
41
44
if params :
42
45
cmd = f"kubectl -n { namespace } exec { tank } -- bitcoin-cli { method } { ' ' .join (map (str , params ))} "
43
46
else :
0 commit comments