|
50 | 50 | Project Version Name |
51 | 51 | -sp SUBPROJECT_LIST, --subproject-list SUBPROJECT_LIST |
52 | 52 | List of subprojects to generate with subproject:container:tag |
| 53 | + -ssf SUBPROJECT_SPEC_FILE, --subproject-spec-file SUBPROJECT_SPEC_FILE |
| 54 | + Excel file containing subproject specification |
53 | 55 | -nv, --no-verify Disable TLS certificate verification |
54 | 56 | -rm, --remove Remove project structure with all subprojects (DANGEROUS!) |
55 | 57 | --clone-from CLONE_FROM |
|
60 | 62 | if container name omited it will be set to subproject |
61 | 63 | if tag omited it would be set to 'latest' |
62 | 64 |
|
| 65 | +Subprojects an be specified in excel file with -ssf --subproject-spec-file parameter. |
| 66 | +Excel file should contain one worksheet with first row containing column names as following: |
| 67 | +Container Name, Image ID, Version, Project Name |
| 68 | +and subsequent rows containing data |
| 69 | +
|
63 | 70 | Container image name scanned will be written into project version nickname field |
64 | 71 |
|
65 | 72 | |
@@ -197,9 +204,36 @@ def add_component_to_version_bom(child_version, version): |
197 | 204 | data = { 'component': child_version['_meta']['href']} |
198 | 205 | return bd.session.post(url, json=data) |
199 | 206 |
|
| 207 | +def get_child_spec_list(args): |
| 208 | + if args.subproject_list: |
| 209 | + return args.subproject_list.split(',') |
| 210 | + else: |
| 211 | + print("processing excel") |
| 212 | + import openpyxl |
| 213 | + wb = openpyxl.load_workbook(args.subproject_spec_file) |
| 214 | + ws = wb.active |
| 215 | + project_list = [] |
| 216 | + row_number = 0 |
| 217 | + for row in ws.values: |
| 218 | + row_number += 1 |
| 219 | + if (row_number == 1 and |
| 220 | + row[0] == 'Container Name' and |
| 221 | + row[1] == 'Image ID' and |
| 222 | + row[2] == 'Version' and |
| 223 | + row[3] == 'Project Name'): |
| 224 | + print("File Format checks out (kind of)") |
| 225 | + continue |
| 226 | + elif row_number > 1: |
| 227 | + project_list.append(f"{row[3]}:{row[0]}:{row[2]}") |
| 228 | + else: |
| 229 | + logging.error(f"Could not parse input file {args.subproject_spec_file}") |
| 230 | + sys.exit(1) |
| 231 | + return (project_list) |
| 232 | + |
200 | 233 | def create_and_add_child_projects(version, args): |
201 | 234 | version_url = version['_meta']['href'] + '/components' |
202 | | - for child_spec in [x.split(':') for x in args.subproject_list.split(",")]: |
| 235 | + child_spec_list = get_child_spec_list(args) |
| 236 | + for child_spec in [x.split(':') for x in child_spec_list]: |
203 | 237 | i = iter(child_spec) |
204 | 238 | child = next(i) |
205 | 239 | repo = next(i, child) |
@@ -299,7 +333,9 @@ def parse_command_args(): |
299 | 333 | parser.add_argument("-pg", "--project_group", required=False, default='Multi-Image', help="Project Group to be used") |
300 | 334 | parser.add_argument("-p", "--project-name", required=True, help="Project Name") |
301 | 335 | parser.add_argument("-pv", "--version-name", required=True, help="Project Version Name") |
302 | | - parser.add_argument("-sp", "--subproject-list", required=False, help="List of subprojects to generate with subproject:container:tag") |
| 336 | + group = parser.add_mutually_exclusive_group() |
| 337 | + group.add_argument("-sp", "--subproject-list", required=False, help="List of subprojects to generate with subproject:container:tag") |
| 338 | + group.add_argument("-ssf", "--subproject-spec-file", required=False, help="Excel file containing subproject specification") |
303 | 339 | parser.add_argument("-nv", "--no-verify", action='store_false', help="Disable TLS certificate verification") |
304 | 340 | parser.add_argument("-rm", "--remove", action='store_true', required=False, help="Remove project structure with all subprojects (DANGEROUS!)") |
305 | 341 | parser.add_argument("--clone-from", required=False, help="Main project version to use as template for cloning") |
|
0 commit comments