Find and read all available partials. Args: partial_path (string): read partials from this directory. Returns: Dict[string, string] of partial short names (like "ubuntu/python" or "bazel") to the full contents of that partial.
(partial_path)
| 445 | |
| 446 | |
| 447 | def gather_existing_partials(partial_path): |
| 448 | """Find and read all available partials. |
| 449 | |
| 450 | Args: |
| 451 | partial_path (string): read partials from this directory. |
| 452 | |
| 453 | Returns: |
| 454 | Dict[string, string] of partial short names (like "ubuntu/python" or |
| 455 | "bazel") to the full contents of that partial. |
| 456 | """ |
| 457 | partials = {} |
| 458 | for path, _, files in os.walk(partial_path): |
| 459 | for name in files: |
| 460 | fullpath = os.path.join(path, name) |
| 461 | if '.partial.Dockerfile' not in fullpath: |
| 462 | eprint(('> Probably not a problem: skipping {}, which is not a ' |
| 463 | 'partial.').format(fullpath)) |
| 464 | continue |
| 465 | # partial_dir/foo/bar.partial.Dockerfile -> foo/bar |
| 466 | simple_name = fullpath[len(partial_path) + 1:-len('.partial.dockerfile')] |
| 467 | with open(fullpath, 'r') as f: |
| 468 | partial_contents = f.read() |
| 469 | partials[simple_name] = partial_contents |
| 470 | return partials |
| 471 | |
| 472 | |
| 473 | def main(argv): |