Skip to content

Commit 0ec8261

Browse files
committed
core-services/prow/02_config: Enumerate multi-count names
The names are used for custom resources, so we need unique names for each entry [1]. Consuming jobs will have to split on the --, which is hopefully unique enough, to get the raw name (if they plan to use it to select a region or similar). I'm not using '-', because: a. I wanted to avoid enumerating single-count entries. b. I wanted consumers to not have to care about whether they were drawing from a single-count or multi-count entry. Using a separator that is not part of the raw names means that consumers can always split on that separator without having to worry about whether they were drawing from a single-count or a multi-count name. [1]: #12589 (comment)
1 parent fa0df45 commit 0ec8261

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

core-services/prow/02_config/generate-boskos.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@
6767
else:
6868
resource['names'] = []
6969
for name, count in sorted(data.items()):
70-
resource['names'].extend([name]*count)
70+
if '--' in name:
71+
raise ValueError('double-dashes are used internally, so {!r} is invalid'.format(name))
72+
if count > 1:
73+
width = len(str(count-1))
74+
resource['names'].extend(['{name}--{i:0>{width}}'.format(name=name, i=i, width=width) for i in range(count)])
75+
else:
76+
resource['names'].append(name)
7177
config['resources'].append(resource)
7278

7379
with open('_boskos.yaml', 'w') as f:

0 commit comments

Comments
 (0)