Ejemplo n.º 1
0
def export_docker_images(
        project: Project,
        destination: str,
        commit: Optional[str],
        extra_docker_images: Iterable[str] = (),
) -> None:
    commit = expand_commit_id(project.directory, commit=(commit or 'HEAD'))
    docker_images = {
        step.image
        for step in project.get_config(commit).steps.values()
    }
    docker_images |= set(extra_docker_images)
    for i, image in enumerate(docker_images, 1):
        output_path = os.path.join(destination,
                                   sanitize_filename(f'docker-{image}.tar'))
        if image not in extra_docker_images:
            print_parcel_progress('::: Pulling image {}/{} ({})'.format(
                i,
                len(docker_images),
                image,
            ))
            subprocess.check_call(['docker', 'pull', image])
        print_parcel_progress(
            f'::: Exporting image {i}/{len(docker_images)} ({image})')
        export_docker_image(image, output_path)
Ejemplo n.º 2
0
def get_current_config(project: Project) -> Optional[Config]:
    try:
        return project.get_config()
    except FileNotFoundError:
        return None
Ejemplo n.º 3
0
def get_current_config(project: Project, yaml_file: Optional[str] = None) -> Optional[Config]:
    try:
        return project.get_config(yaml_path=yaml_file)
    except FileNotFoundError:
        return None