Пример #1
0
def build(target_image):
    build = Build()
    build.debug = True
    build.playbook_path = basic_playbook_path
    build.base_image = base_image
    build.target_image = target_image
    build.metadata = ImageMetadata()
    build.state = BuildState.NEW
    build.builder_name = "buildah"  # test with all builders
    return build
Пример #2
0
def build_inside_openshift(app):
    """
    This is expected to run inside an openshift pod spawned via custom build

    :param app: instance of Application
    """
    playbook_path, base_image = okd_get_playbook_base()

    if playbook_path.startswith("/"):
        raise RuntimeError(
            "The path to playbook needs to be relative within the git repo.")

    uri, ref, target_image = okd_load_metadata()

    tmp = tempfile.mkdtemp(prefix="ab-okd")

    try:
        git_clone_to_path(uri, tmp, ref=ref)

        playbook_path = os.path.abspath(os.path.join(tmp, playbook_path))
        if not playbook_path.startswith(tmp):
            raise RuntimeError(
                "The path to playbook points outside of the git repo, this is not allowed."
            )

        build = Build()
        build.metadata = ImageMetadata()  # TODO: needs to be figured out
        build.playbook_path = playbook_path
        build.base_image = base_image
        build.target_image = target_image
        build.builder_name = "buildah"
        build.cache_tasks = False  # we have local storage in pod, so this doesn't make any sense
        app.build(build)

    finally:
        shutil.rmtree(tmp)