当前位置: 首页>>代码示例>>Python>>正文


Python DockerTasker.image_exists方法代码示例

本文整理汇总了Python中atomic_reactor.core.DockerTasker.image_exists方法的典型用法代码示例。如果您正苦于以下问题:Python DockerTasker.image_exists方法的具体用法?Python DockerTasker.image_exists怎么用?Python DockerTasker.image_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在atomic_reactor.core.DockerTasker的用法示例。


在下文中一共展示了DockerTasker.image_exists方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_pull_base_image_plugin

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import image_exists [as 别名]
def test_pull_base_image_plugin(df_base, parent_registry, expected_w_reg, expected_wo_reg):
    if MOCK:
        mock_docker(remember_images=True)

    tasker = DockerTasker()
    workflow = DockerBuildWorkflow(MOCK_SOURCE, 'test-image')
    workflow.builder = MockBuilder()
    workflow.builder.base_image = ImageName.parse(df_base)

    assert not tasker.image_exists(BASE_IMAGE)
    assert not tasker.image_exists(BASE_IMAGE_W_REGISTRY)

    runner = PreBuildPluginsRunner(
        tasker,
        workflow,
        [{
            'name': PullBaseImagePlugin.key,
            'args': {'parent_registry': parent_registry, 'parent_registry_insecure': True}
        }]
    )

    runner.run()

    assert tasker.image_exists(BASE_IMAGE) == expected_wo_reg
    assert tasker.image_exists(BASE_IMAGE_W_REGISTRY) == expected_w_reg

    try:
        tasker.remove_image(BASE_IMAGE)
        tasker.remove_image(BASE_IMAGE_W_REGISTRY)
    except:
        pass
开发者ID:Akasurde,项目名称:atomic-reactor,代码行数:33,代码来源:test_pull_base_image.py

示例2: test_image_doesnt_exist

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import image_exists [as 别名]
def test_image_doesnt_exist():
    image = "lerknglekrnglekrnglekrnglekrng"
    if MOCK:
        mock_docker(should_raise_error={'inspect_image': [image]})

    t = DockerTasker()
    assert t.image_exists(image) is False
开发者ID:david-martin,项目名称:atomic-reactor,代码行数:9,代码来源:test_tasker.py

示例3: test_build_image_from_git

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import image_exists [as 别名]
def test_build_image_from_git(temp_image_name):
    if MOCK:
        mock_docker()

    t = DockerTasker()
    response = t.build_image_from_git(DOCKERFILE_GIT, temp_image_name, use_cache=True)
    list(response)
    assert response is not None
    assert t.image_exists(temp_image_name)
    t.remove_image(temp_image_name)
开发者ID:david-martin,项目名称:atomic-reactor,代码行数:12,代码来源:test_tasker.py

示例4: test_pull_base_image_plugin

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import image_exists [as 别名]
def test_pull_base_image_plugin(parent_registry, df_base, expected, not_expected):
    if MOCK:
        mock_docker(remember_images=True)

    tasker = DockerTasker(retry_times=0)
    workflow = DockerBuildWorkflow(MOCK_SOURCE, 'test-image')
    workflow.builder = MockBuilder()
    workflow.builder.base_image = ImageName.parse(df_base)

    expected = set(expected)
    expected.add(UNIQUE_ID)
    expected.add(df_base)
    all_images = set(expected).union(not_expected)
    for image in all_images:
        assert not tasker.image_exists(image)

    runner = PreBuildPluginsRunner(
        tasker,
        workflow,
        [{
            'name': PullBaseImagePlugin.key,
            'args': {'parent_registry': parent_registry, 'parent_registry_insecure': True}
        }]
    )

    runner.run()

    for image in expected:
        assert tasker.image_exists(image)
        assert image in workflow.pulled_base_images

    for image in not_expected:
        assert not tasker.image_exists(image)

    for image in workflow.pulled_base_images:
        assert tasker.image_exists(image)

    for image in all_images:
        try:
            tasker.remove_image(image)
        except:
            pass
    assert workflow.builder.base_image == df_base
开发者ID:vrutkovs,项目名称:atomic-reactor,代码行数:45,代码来源:test_pull_base_image.py

示例5: test_tag_and_push

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import image_exists [as 别名]
def test_tag_and_push(temp_image_name):
    if MOCK:
        mock_docker()

    t = DockerTasker()
    temp_image_name.registry = LOCALHOST_REGISTRY
    temp_image_name.tag = "1"
    output = t.tag_and_push_image(INPUT_IMAGE, temp_image_name, insecure=True)
    assert output is not None
    assert t.image_exists(temp_image_name)
    t.remove_image(temp_image_name)
开发者ID:david-martin,项目名称:atomic-reactor,代码行数:13,代码来源:test_tasker.py

示例6: test_image_creation_local_repo

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import image_exists [as 别名]
def test_image_creation_local_repo():
    if MOCK:
        mock_docker()

    b = BuildImageBuilder(reactor_local_path=PARENT_DIR)
    df_dir_path = os.path.join(PARENT_DIR, 'images', 'privileged-builder')
    b.create_image(df_dir_path, TEST_BUILD_IMAGE)

    dt = DockerTasker()
    assert dt.image_exists(TEST_BUILD_IMAGE)
    dt.remove_image(TEST_BUILD_IMAGE)
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:13,代码来源:test_buildimage.py

示例7: test_tag_image

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import image_exists [as 别名]
def test_tag_image(temp_image_name):
    if MOCK:
        mock_docker()

    t = DockerTasker()
    temp_image_name.registry = "somewhere.example.com"
    temp_image_name.tag = "1"
    img = t.tag_image(INPUT_IMAGE, temp_image_name)
    try:
        assert t.image_exists(temp_image_name)
        assert img == temp_image_name.to_str()
    finally:
        t.remove_image(temp_image_name)
开发者ID:david-martin,项目名称:atomic-reactor,代码行数:15,代码来源:test_tasker.py

示例8: test_commit_container

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import image_exists [as 别名]
def test_commit_container(temp_image_name):
    if MOCK:
        mock_docker()

    t = DockerTasker()
    container_id = t.run(INPUT_IMAGE, command="id")
    t.wait(container_id)
    image_id = t.commit_container(container_id, message="test message", image=temp_image_name)
    try:
        assert t.image_exists(image_id)
    finally:
        t.remove_container(container_id)
        t.remove_image(image_id)
开发者ID:david-martin,项目名称:atomic-reactor,代码行数:15,代码来源:test_tasker.py

示例9: test_remove_image

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import image_exists [as 别名]
def test_remove_image(temp_image_name):
    if MOCK:
        mock_docker(inspect_should_fail=True)

    t = DockerTasker()
    container_id = t.run(input_image_name, command="id")
    t.wait(container_id)
    image_id = t.commit_container(container_id, image=temp_image_name)
    try:
        t.remove_container(container_id)
    finally:
        t.remove_image(image_id)
    assert not t.image_exists(temp_image_name)
开发者ID:david-martin,项目名称:atomic-reactor,代码行数:15,代码来源:test_tasker.py

示例10: test_build_image_from_path

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import image_exists [as 别名]
def test_build_image_from_path(tmpdir, temp_image_name):
    if MOCK:
        mock_docker()

    tmpdir_path = str(tmpdir.realpath())
    clone_git_repo(DOCKERFILE_GIT, tmpdir_path)
    df = tmpdir.join("Dockerfile")
    assert df.check()
    t = DockerTasker()
    response = t.build_image_from_path(tmpdir_path, temp_image_name, use_cache=True)
    list(response)
    assert response is not None
    assert t.image_exists(temp_image_name)
    t.remove_image(temp_image_name)
开发者ID:david-martin,项目名称:atomic-reactor,代码行数:16,代码来源:test_tasker.py

示例11: test_image_exists

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import image_exists [as 别名]
def test_image_exists():
    if MOCK:
        mock_docker()

    t = DockerTasker()
    assert t.image_exists(input_image_name) is True
开发者ID:david-martin,项目名称:atomic-reactor,代码行数:8,代码来源:test_tasker.py

示例12: test_pull_base_image_plugin

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import image_exists [as 别名]
def test_pull_base_image_plugin(parent_registry, df_base, expected, not_expected,
                                reactor_config_map, inspect_only, workflow_callback=None,
                                check_platforms=False, parent_images=None, organization=None,
                                parent_images_digests=None):
    if MOCK:
        mock_docker(remember_images=True)

    tasker = DockerTasker(retry_times=0)
    buildstep_plugin = [{
        'name': PLUGIN_BUILD_ORCHESTRATE_KEY,
        'args': {'platforms': ['x86_64']},
    }]
    parent_images = parent_images or {ImageName.parse(df_base): None}
    workflow = DockerBuildWorkflow(MOCK_SOURCE, 'test-image', buildstep_plugins=buildstep_plugin,)
    builder = workflow.builder = MockBuilder()
    builder.base_image = builder.original_base_image = ImageName.parse(df_base)
    builder.parent_images = parent_images

    expected = set(expected)
    for nonce in range(len(parent_images)):
        expected.add("{}:{}".format(UNIQUE_ID, nonce))
    all_images = set(expected).union(not_expected)
    for image in all_images:
        assert not tasker.image_exists(image)

    if reactor_config_map:
        workflow.plugin_workspace[ReactorConfigPlugin.key] = {}
        workflow.plugin_workspace[ReactorConfigPlugin.key][WORKSPACE_CONF_KEY] =\
            ReactorConfig({'version': 1,
                           'source_registry': {'url': parent_registry,
                                               'insecure': True},
                           'registries_organization': organization})

    if workflow_callback:
        workflow = workflow_callback(workflow)

    runner = PreBuildPluginsRunner(
        tasker,
        workflow,
        [{
            'name': PullBaseImagePlugin.key,
            'args': {'parent_registry': parent_registry,
                     'parent_registry_insecure': True,
                     'check_platforms': check_platforms,
                     'inspect_only': inspect_only,
                     'parent_images_digests': parent_images_digests,
                     }
        }]
    )

    if parent_registry is None and reactor_config_map:
        with pytest.raises(PluginFailedException):
            runner.run()
        return

    runner.run()
    if not inspect_only:
        assert workflow.builder.base_image.to_str().startswith(UNIQUE_ID + ":")

    for image in expected:
        if inspect_only:
            assert not tasker.image_exists(image)
            assert image not in workflow.pulled_base_images
        else:
            assert tasker.image_exists(image)
            assert image in workflow.pulled_base_images

    for image in not_expected:
        assert not tasker.image_exists(image)

    for image in workflow.pulled_base_images:
        assert tasker.image_exists(image)

    for df, tagged in workflow.builder.parent_images.items():
        assert tagged is not None, "Did not tag parent image " + str(df)
    # tags should all be unique
    assert len(set(workflow.builder.parent_images.values())) == len(workflow.builder.parent_images)
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:79,代码来源:test_pull_base_image.py

示例13: test_pull_base_image_special

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import image_exists [as 别名]
def test_pull_base_image_special(add_another_parent, special_image, change_base, skip_parent,
                                 reactor_config_map, monkeypatch):
    monkeypatch.setenv("BUILD", json.dumps({
        'metadata': {
            'name': UNIQUE_ID,
        },
    }))

    if MOCK:
        mock_docker(remember_images=True)

    tasker = DockerTasker(retry_times=0)
    buildstep_plugin = [{
        'name': PLUGIN_BUILD_ORCHESTRATE_KEY,
        'args': {'platforms': ['x86_64']},
    }]
    workflow = DockerBuildWorkflow(MOCK_SOURCE, special_image, buildstep_plugins=buildstep_plugin,)
    builder = workflow.builder = MockBuilder()
    builder.parent_images = {}
    builder.set_base_image(special_image)
    if add_another_parent:
        builder.parent_images[BASE_IMAGE_NAME_W_SHA] = None
    parent_images = builder.parent_images

    expected = set([])
    for nonce in range(len(parent_images) - skip_parent):
        expected.add("{}:{}".format(UNIQUE_ID, nonce))
    for image in expected:
        assert not tasker.image_exists(image)

    if reactor_config_map:
        workflow.plugin_workspace[ReactorConfigPlugin.key] = {}
        workflow.plugin_workspace[ReactorConfigPlugin.key][WORKSPACE_CONF_KEY] =\
            ReactorConfig({'version': 1,
                           'source_registry': {'url': LOCALHOST_REGISTRY,
                                               'insecure': True},
                           'registries_organization': None})

    runner = PreBuildPluginsRunner(
        tasker,
        workflow,
        [{
            'name': PullBaseImagePlugin.key,
            'args': {'parent_registry': LOCALHOST_REGISTRY,
                     'parent_registry_insecure': True,
                     }
        }]
    )

    runner.run()
    if change_base:
        assert workflow.builder.base_image.to_str().startswith(UNIQUE_ID)
    else:
        assert workflow.builder.base_image.to_str().startswith(special_image)
    for image in expected:
        assert tasker.image_exists(image)
        assert image in workflow.pulled_base_images

    for image in workflow.pulled_base_images:
        assert tasker.image_exists(image)

    for df, tagged in workflow.builder.parent_images.items():
        assert tagged is not None, "Did not tag parent image " + str(df)
    assert len(set(workflow.builder.parent_images.values())) == len(workflow.builder.parent_images)
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:66,代码来源:test_pull_base_image.py


注:本文中的atomic_reactor.core.DockerTasker.image_exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。