(argv)
| 471 | |
| 472 | |
| 473 | def main(argv): |
| 474 | if len(argv) > 1: |
| 475 | raise app.UsageError('Too many command-line arguments.') |
| 476 | |
| 477 | # Read the full spec file, used for everything |
| 478 | with open(FLAGS.spec_file, 'r') as spec_file: |
| 479 | tag_spec = yaml.safe_load(spec_file) |
| 480 | |
| 481 | # Get existing partial contents |
| 482 | partials = gather_existing_partials(FLAGS.partial_dir) |
| 483 | |
| 484 | # Abort if spec.yaml is invalid |
| 485 | schema = yaml.safe_load(SCHEMA_TEXT) |
| 486 | v = TfDockerTagValidator(schema, partials=partials) |
| 487 | if not v.validate(tag_spec): |
| 488 | eprint('> Error: {} is an invalid spec! The errors are:'.format( |
| 489 | FLAGS.spec_file)) |
| 490 | eprint(yaml.dump(v.errors, indent=2)) |
| 491 | exit(1) |
| 492 | tag_spec = v.normalized(tag_spec) |
| 493 | |
| 494 | # Assemble tags and images used to build them |
| 495 | all_tags = assemble_tags(tag_spec, FLAGS.arg, FLAGS.release, partials) |
| 496 | |
| 497 | # Empty Dockerfile directory if building new Dockerfiles |
| 498 | if FLAGS.construct_dockerfiles: |
| 499 | eprint('> Emptying Dockerfile dir "{}"'.format(FLAGS.dockerfile_dir)) |
| 500 | shutil.rmtree(FLAGS.dockerfile_dir, ignore_errors=True) |
| 501 | mkdir_p(FLAGS.dockerfile_dir) |
| 502 | |
| 503 | # Set up Docker helper |
| 504 | dock = docker.from_env() |
| 505 | |
| 506 | # Login to Docker if uploading images |
| 507 | if FLAGS.upload_to_hub: |
| 508 | if not FLAGS.hub_username: |
| 509 | eprint('> Error: please set --hub_username when uploading to Dockerhub.') |
| 510 | exit(1) |
| 511 | if not FLAGS.hub_repository: |
| 512 | eprint( |
| 513 | '> Error: please set --hub_repository when uploading to Dockerhub.') |
| 514 | exit(1) |
| 515 | if not FLAGS.hub_password: |
| 516 | eprint('> Error: please set --hub_password when uploading to Dockerhub.') |
| 517 | exit(1) |
| 518 | dock.login( |
| 519 | username=FLAGS.hub_username, |
| 520 | password=FLAGS.hub_password, |
| 521 | ) |
| 522 | |
| 523 | # Each tag has a name ('tag') and a definition consisting of the contents |
| 524 | # of its Dockerfile, its build arg list, etc. |
| 525 | failed_tags = [] |
| 526 | succeeded_tags = [] |
| 527 | for tag, tag_defs in all_tags.items(): |
| 528 | for tag_def in tag_defs: |
| 529 | eprint('> Working on {}'.format(tag)) |
| 530 |
nothing calls this directly
no test coverage detected