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
5859 format of CF defining too, and each path should be in a single line.
5960 """
6061)
62+ @option (
63+ "--config" ,
64+ "-c" ,
65+ help = """
66+ The charon configuration yaml file path. Default is
67+ $HOME/.charon/charon.yaml
68+ """
69+ )
6170@option (
6271 "--debug" ,
6372 "-D" ,
@@ -79,6 +88,7 @@ def invalidate(
7988 target : str ,
8089 paths : List [str ],
8190 path_file : str ,
91+ config : str = "" ,
8292 quiet : bool = False ,
8393 debug : bool = False
8494):
@@ -110,20 +120,20 @@ def invalidate(
110120 break
111121
112122 try :
113- (buckets , aws_profile ) = _init_cmd (target )
123+ (targets , aws_profile ) = _init_cmd (target , config )
114124
115- for b in buckets :
125+ for t in targets :
116126 cf_client = CFClient (aws_profile = aws_profile )
117127 # Per aws official doc, if the paths contains wildcard, it is
118128 # limited to 15 as max items in one request. Otherwise it could
119129 # be 3000
120130 if use_wildcard :
121131 invalidate_cf_paths (
122- cf_client , b , work_paths
132+ cf_client , t , work_paths
123133 )
124134 else :
125135 invalidate_cf_paths (
126- cf_client , b , work_paths , batch_size = 3000
136+ cf_client , t , work_paths , batch_size = 3000
127137 )
128138 except Exception :
129139 print (traceback .format_exc ())
@@ -144,6 +154,14 @@ def invalidate(
144154 """ ,
145155 required = True
146156)
157+ @option (
158+ "--config" ,
159+ "-c" ,
160+ help = """
161+ The charon configuration yaml file path. Default is
162+ $HOME/.charon/charon.yaml
163+ """
164+ )
147165@option (
148166 "--debug" ,
149167 "-D" ,
@@ -164,6 +182,7 @@ def invalidate(
164182def check (
165183 invalidation_id : str ,
166184 target : str ,
185+ config : str = "" ,
167186 quiet : bool = False ,
168187 debug : bool = False
169188):
@@ -175,14 +194,14 @@ def check(
175194 is_quiet = quiet , is_debug = debug , use_log_file = False
176195 )
177196 try :
178- (buckets , aws_profile ) = _init_cmd (target )
179- if not buckets :
197+ (targets , aws_profile ) = _init_cmd (target , config )
198+ if not targets :
180199 sys .exit (1 )
181200
182- for b in buckets :
201+ for t in targets :
183202 cf_client = CFClient (aws_profile = aws_profile )
184- bucket_name = b [1 ]
185- domain = b [4 ]
203+ bucket_name = t [1 ]
204+ domain : Optional [ str ] = t [4 ]
186205 if not domain :
187206 domain = cf_client .get_domain_by_bucket (bucket_name )
188207 if domain :
@@ -203,8 +222,8 @@ def check(
203222 sys .exit (2 )
204223
205224
206- def _init_cmd (target : str ) -> Tuple [List [Tuple [ str , str , str , str , str ] ], str ]:
207- conf = get_config ()
225+ def _init_cmd (target : str , config : str ) -> Tuple [List [TARGET_TYPE ], str ]:
226+ conf = get_config (config )
208227 if not conf :
209228 sys .exit (1 )
210229
@@ -213,7 +232,7 @@ def _init_cmd(target: str) -> Tuple[List[Tuple[str, str, str, str, str]], str]:
213232 logger .error ("No AWS profile specified!" )
214233 sys .exit (1 )
215234
216- return (_get_buckets ([target ], conf ), aws_profile )
235+ return (_get_targets ([target ], conf ), aws_profile )
217236
218237
219238@group ()
0 commit comments