Skip to content

Commit 734fa0f

Browse files
committed
Fix: Effective value of azul_current_{catalog,source} is not obvious (#7503)
1 parent fa06223 commit 734fa0f

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

scripts/mirror.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,8 @@ def main(args):
7474
parser.add_argument('--catalog',
7575
metavar='NAME',
7676
choices=config.catalogs,
77-
default=config.default_catalog,
7877
help='The name of the catalog to mirror.')
7978
parser.add_argument('--sources',
80-
default=config.current_sources,
8179
nargs='+',
8280
help='Limit mirroring to a subset of the configured sources. '
8381
'Supports shell-style wildcards to match multiple sources per argument. '

scripts/reindex.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
)
1212
from azul.args import (
1313
AzulArgumentHelpFormatter,
14+
Origin,
1415
)
1516
from azul.azulclient import (
1617
AzulClient,
@@ -57,19 +58,9 @@
5758
parser.add_argument('--catalogs',
5859
nargs='+',
5960
metavar='NAME',
60-
default=[
61-
catalog.name
62-
for catalog in config.catalogs.values()
63-
if not catalog.is_integration_test_catalog
64-
]
65-
if config.current_catalog is None else
66-
[
67-
config.catalogs[config.current_catalog].name
68-
],
6961
choices=config.catalogs,
7062
help='The names of the catalogs to reindex.')
7163
parser.add_argument('--sources',
72-
default=config.current_sources,
7364
nargs='+',
7465
help='Limit reindexing to a subset of the configured sources. '
7566
'Supports shell-style wildcards to match multiple sources per argument. '
@@ -128,7 +119,29 @@ def main(argv: list[str]):
128119

129120
azul = AzulClient(num_workers=args.num_workers)
130121

131-
source_globs = set(args.sources)
122+
if args.catalog is None:
123+
catalog_origin = 'environment variable'
124+
if config.current_catalog is None:
125+
catalogs = [
126+
catalog.name
127+
for catalog in config.catalogs.values()
128+
if not catalog.is_integration_test_catalog
129+
]
130+
else:
131+
catalogs = [config.catalogs[config.current_catalog].name]
132+
else:
133+
catalog_origin = 'command line argument'
134+
catalogs = args.catalogs
135+
log.info('Using catalog(s) specified via %s: %r', catalog_origin, catalogs)
136+
137+
if len(args.sources) == 0:
138+
source_origin = 'environment variable'
139+
source_globs = set(config.current_sources)
140+
else:
141+
source_origin = 'command line argument'
142+
source_globs = set(args.sources)
143+
log.info('Using source glob(s) specified via %s: %r', source_origin, source_globs)
144+
132145
every_source = '*' in source_globs
133146
deindex = args.deindex or (args.delete and not every_source)
134147
delete = args.delete and every_source
@@ -146,15 +159,15 @@ def main(argv: list[str]):
146159
parser.error('--deindex is incompatible with --create and --delete.')
147160
assert False
148161

149-
sources_by_catalog = azul.matching_sources(args.catalogs, source_globs)
162+
sources_by_catalog = azul.matching_sources(catalogs, source_globs)
150163
azul.require_no_failures_before()
151164

152165
if deindex:
153166
for catalog, sources in sources_by_catalog.items():
154167
if sources:
155168
azul.deindex(catalog, sources)
156169

157-
azul.reset_indexer(args.catalogs,
170+
azul.reset_indexer(catalogs,
158171
purge_queues=args.purge,
159172
delete_indices=delete,
160173
create_indices=args.create or args.index and delete)
@@ -182,7 +195,7 @@ def main(argv: list[str]):
182195
if args.wait:
183196
if num_notifications == 0:
184197
log.warning('No notifications for prefix %r and catalogs %r were sent',
185-
args.prefix, args.catalogs)
198+
args.prefix, catalogs)
186199
else:
187200
azul.wait_for_indexer()
188201
azul.require_no_failures_after()

0 commit comments

Comments
 (0)