1515"""
1616
1717from charon .config import get_config
18- from charon .cmd .internal import _decide_mode , _get_buckets
18+ from charon .cmd .internal import _decide_mode , _get_targets
1919from charon .cache import CFClient
2020from charon .pkgs .pkg_utils import invalidate_cf_paths
21+ from charon .types import TARGET_TYPE
2122from click import command , option , argument , group
22- from typing import List , Tuple
23+ from typing import List , Tuple , Optional
2324
2425import traceback
2526import logging
@@ -87,7 +88,7 @@ def invalidate(
8788 target : str ,
8889 paths : List [str ],
8990 path_file : str ,
90- config : str = None ,
91+ config : str = "" ,
9192 quiet : bool = False ,
9293 debug : bool = False
9394):
@@ -119,20 +120,20 @@ def invalidate(
119120 break
120121
121122 try :
122- (buckets , aws_profile ) = _init_cmd (target , config )
123+ (targets , aws_profile ) = _init_cmd (target , config )
123124
124- for b in buckets :
125+ for t in targets :
125126 cf_client = CFClient (aws_profile = aws_profile )
126127 # Per aws official doc, if the paths contains wildcard, it is
127128 # limited to 15 as max items in one request. Otherwise it could
128129 # be 3000
129130 if use_wildcard :
130131 invalidate_cf_paths (
131- cf_client , b , work_paths
132+ cf_client , t , work_paths
132133 )
133134 else :
134135 invalidate_cf_paths (
135- cf_client , b , work_paths , batch_size = 3000
136+ cf_client , t , work_paths , batch_size = 3000
136137 )
137138 except Exception :
138139 print (traceback .format_exc ())
@@ -181,7 +182,7 @@ def invalidate(
181182def check (
182183 invalidation_id : str ,
183184 target : str ,
184- config : str = None ,
185+ config : str = "" ,
185186 quiet : bool = False ,
186187 debug : bool = False
187188):
@@ -193,14 +194,14 @@ def check(
193194 is_quiet = quiet , is_debug = debug , use_log_file = False
194195 )
195196 try :
196- (buckets , aws_profile ) = _init_cmd (target , config )
197- if not buckets :
197+ (targets , aws_profile ) = _init_cmd (target , config )
198+ if not targets :
198199 sys .exit (1 )
199200
200- for b in buckets :
201+ for t in targets :
201202 cf_client = CFClient (aws_profile = aws_profile )
202- bucket_name = b [1 ]
203- domain = b [4 ]
203+ bucket_name = t [1 ]
204+ domain : Optional [ str ] = t [4 ]
204205 if not domain :
205206 domain = cf_client .get_domain_by_bucket (bucket_name )
206207 if domain :
@@ -221,7 +222,7 @@ def check(
221222 sys .exit (2 )
222223
223224
224- def _init_cmd (target : str , config : str ) -> Tuple [List [Tuple [ str , str , str , str , str ] ], str ]:
225+ def _init_cmd (target : str , config : str ) -> Tuple [List [TARGET_TYPE ], str ]:
225226 conf = get_config (config )
226227 if not conf :
227228 sys .exit (1 )
@@ -231,7 +232,7 @@ def _init_cmd(target: str, config: str) -> Tuple[List[Tuple[str, str, str, str,
231232 logger .error ("No AWS profile specified!" )
232233 sys .exit (1 )
233234
234- return (_get_buckets ([target ], conf ), aws_profile )
235+ return (_get_targets ([target ], conf ), aws_profile )
235236
236237
237238@group ()
0 commit comments