def test_current_user(mock_uid, mock_getpwuid): assert current_user() == mock_getpwuid.pw_name
build.mkdir() for tag, params in IMAGES.items(): report('Templating out {}'.format(tag)) assert re.match(r'^[a-z\-:]+$', tag), tag p = build / tag if p.is_dir(): shutil.rmtree(str(p)) shutil.copytree('include', str(p)) with (p / 'Dockerfile').open('w') as f: f.write( template.render(**dict(DEFAULT_IMAGE_OPTIONS, **params)) + '\n') temp_tag = '{}-test-{}'.format(current_user(), tag) report('Building {} (as {})'.format(tag, temp_tag)) subprocess.check_call(('docker', 'build') + (('--no-cache', ) if args.push else ()) + ('-t', temp_tag, str(p))) report( 'Successfully built {} (as {})'.format(tag, temp_tag), color=bg_green, ) if args.push: for new_tag in ('theocf/{}', 'docker-push.ocf.berkeley.edu/theocf/{}'): new_tag = new_tag.format(tag) report('Tagging {} as {} for push'.format(temp_tag, new_tag)) subprocess.check_call((
build = Path('build') if not build.is_dir(): build.mkdir() for tag, params in IMAGES.items(): report('Templating out {}'.format(tag)) assert re.match(r'^[a-z\-:]+$', tag), tag p = build / tag if p.is_dir(): shutil.rmtree(str(p)) shutil.copytree('include', str(p)) with (p / 'Dockerfile').open('w') as f: f.write(template.render(**dict(DEFAULT_IMAGE_OPTIONS, **params)) + '\n') temp_tag = '{}-test-{}'.format(current_user(), tag) report('Building {} (as {})'.format(tag, temp_tag)) subprocess.check_call( ('docker', 'build') + (('--no-cache',) if args.push else ()) + ('-t', temp_tag, str(p)) ) report( 'Successfully built {} (as {})'.format(tag, temp_tag), color=bg_green, ) if args.push: for new_tag in ('theocf/{}', 'docker-push.ocf.berkeley.edu/theocf/{}'): new_tag = new_tag.format(tag) report('Tagging {} as {} for push'.format(temp_tag, new_tag))