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


Python DockerBuildWorkflow.source方法代码示例

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


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

示例1: test_distgit_fetch_artefacts_failure

# 需要导入模块: from atomic_reactor.inner import DockerBuildWorkflow [as 别名]
# 或者: from atomic_reactor.inner.DockerBuildWorkflow import source [as 别名]
def test_distgit_fetch_artefacts_failure(tmpdir, docker_tasker):  # noqa
    command = 'fedpkg sources'
    expected_command = ['fedpkg', 'sources']

    workflow = DockerBuildWorkflow(MOCK_SOURCE, 'test-image')
    workflow.builder = X()
    workflow.source = flexmock(path=str(tmpdir))

    initial_dir = os.getcwd()
    assert initial_dir != str(tmpdir)

    (flexmock(pre_pyrpkg_fetch_artefacts.subprocess)
        .should_receive('check_call')
        .with_args(expected_command)
        .and_raise(RuntimeError)
        .once())

    runner = PreBuildPluginsRunner(
        docker_tasker,
        workflow,
        [{
            'name': DistgitFetchArtefactsPlugin.key,
            'args': {'command': command}
        }]
    )
    with pytest.raises(PluginFailedException):
        runner.run()

    assert os.getcwd() == initial_dir
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:31,代码来源:test_pyrpkg_fetch_artefacts.py

示例2: prepare

# 需要导入模块: from atomic_reactor.inner import DockerBuildWorkflow [as 别名]
# 或者: from atomic_reactor.inner.DockerBuildWorkflow import source [as 别名]
    def prepare(self, df_path, inherited_user='', hide_files=None, parent_images=None):
        if MOCK:
            mock_docker()
        tasker = DockerTasker()
        workflow = DockerBuildWorkflow(SOURCE, "test-image")
        workflow.source = MockSource(df_path)
        workflow.builder = (StubInsideBuilder()
                            .for_workflow(workflow)
                            .set_df_path(df_path))

        for parent in parent_images or []:
            workflow.builder.set_parent_inspection_data(parent, {
                INSPECT_CONFIG: {
                    'User': inherited_user,
                },
            })

        if hide_files is not None:
            reactor_config = ReactorConfig({
                'version': 1,
                'hide_files': hide_files
            })
            workflow.plugin_workspace[ReactorConfigPlugin.key] = {
                WORKSPACE_CONF_KEY: reactor_config
            }

        return tasker, workflow
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:29,代码来源:test_hide_files.py

示例3: test_distgit_fetch_artefacts_plugin

# 需要导入模块: from atomic_reactor.inner import DockerBuildWorkflow [as 别名]
# 或者: from atomic_reactor.inner.DockerBuildWorkflow import source [as 别名]
def test_distgit_fetch_artefacts_plugin(tmpdir, docker_tasker):  # noqa
    command = 'fedpkg sources'
    expected_command = ['fedpkg', 'sources']

    workflow = DockerBuildWorkflow(MOCK_SOURCE, 'test-image')
    workflow.builder = X()
    workflow.source = flexmock(path=str(tmpdir))

    initial_dir = os.getcwd()
    assert initial_dir != str(tmpdir)

    def assert_tmpdir(*args, **kwargs):
        assert os.getcwd() == str(tmpdir)

    (flexmock(pre_pyrpkg_fetch_artefacts.subprocess)
        .should_receive('check_call')
        .with_args(expected_command)
        .replace_with(assert_tmpdir)
        .once())

    runner = PreBuildPluginsRunner(
        docker_tasker,
        workflow,
        [{
            'name': DistgitFetchArtefactsPlugin.key,
            'args': {'command': command}
        }]
    )
    runner.run()

    assert os.getcwd() == initial_dir
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:33,代码来源:test_pyrpkg_fetch_artefacts.py

示例4: mock_workflow

# 需要导入模块: from atomic_reactor.inner import DockerBuildWorkflow [as 别名]
# 或者: from atomic_reactor.inner.DockerBuildWorkflow import source [as 别名]
def mock_workflow(tmpdir):
    workflow = DockerBuildWorkflow({"provider": "git", "uri": "asd"}, TEST_IMAGE)
    workflow.source = StubSource()
    builder = StubInsideBuilder().for_workflow(workflow)
    builder.set_df_path(str(tmpdir))
    builder.tasker = flexmock()
    workflow.builder = flexmock(builder)
    return workflow
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:10,代码来源:test_export_operator_manifests.py

示例5: prepare

# 需要导入模块: from atomic_reactor.inner import DockerBuildWorkflow [as 别名]
# 或者: from atomic_reactor.inner.DockerBuildWorkflow import source [as 别名]
def prepare():
    if MOCK:
        mock_docker()
    tasker = DockerTasker()
    workflow = DockerBuildWorkflow(SOURCE, "test-image")
    workflow.source = StubSource()
    workflow.builder = StubInsideBuilder().for_workflow(workflow)

    session = MockedClientSession(hub='', opts=None)
    workflow.koji_session = session
    flexmock(koji,
             ClientSession=session,
             PathInfo=MockedPathInfo)

    return tasker, workflow
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:17,代码来源:test_koji.py

示例6: workflow

# 需要导入模块: from atomic_reactor.inner import DockerBuildWorkflow [as 别名]
# 或者: from atomic_reactor.inner.DockerBuildWorkflow import source [as 别名]
def workflow(tmpdir):
    if MOCK:
        mock_docker()
    workflow = DockerBuildWorkflow(MOCK_SOURCE, 'test-image')
    workflow.builder = MockInsideBuilder(tmpdir)
    workflow.source = workflow.builder.source
    workflow._tmpdir = tmpdir

    flexmock(workflow, base_image_inspect={})

    mock_reactor_config(tmpdir)
    mock_repo_config(tmpdir)
    mock_odcs_request()
    workflow._koji_session = mock_koji_session()
    return workflow
开发者ID:vrutkovs,项目名称:atomic-reactor,代码行数:17,代码来源:test_resolve_composes.py

示例7: prepare

# 需要导入模块: from atomic_reactor.inner import DockerBuildWorkflow [as 别名]
# 或者: from atomic_reactor.inner.DockerBuildWorkflow import source [as 别名]
    def prepare(self, tmpdir, key, value, update_labels_args=None, update_labels_kwargs=None,
                reactor_config_map=False, base_from_scratch=False, custom_base=False):
        if MOCK:
            mock_docker()
        tasker = DockerTasker()

        workflow = DockerBuildWorkflow(MOCK_SOURCE, 'test-image')
        workflow.builder = MockInsideBuilder(tmpdir)
        workflow.builder.base_from_scratch = base_from_scratch
        workflow.builder.custom_base_image = custom_base
        workflow.source = workflow.builder.source
        setattr(workflow.builder, 'base_image_inspect', {})

        expectation = (flexmock(OSBS)
                       .should_receive('update_labels_on_build_config'))
        if update_labels_args is not None:
            if update_labels_kwargs is None:
                update_labels_kwargs = {}

            expectation.with_args(*update_labels_args)

        namespace = None
        if update_labels_kwargs is not None:
            namespace = update_labels_kwargs.get('namespace')
        (flexmock(osbs.conf).should_call('Configuration')
         .with_args(namespace=namespace, conf_file=None, verify_ssl=True, openshift_url="",
                    use_auth=True, build_json_dir=None))

        if reactor_config_map:
            workflow.plugin_workspace[ReactorConfigPlugin.key] = {}
            workflow.plugin_workspace[ReactorConfigPlugin.key][WORKSPACE_CONF_KEY] =\
                ReactorConfig({'version': 1,
                               'openshift': {
                                   'url': '',
                                   'insecure': False,
                                   'auth': {'enable': True}}})

        runner = PreBuildPluginsRunner(tasker, workflow, [
            {
                'name': CheckAndSetRebuildPlugin.key,
                'args': {
                    'label_key': key,
                    'label_value': value,
                    'url': '',
                },
            }
        ])
        return workflow, runner
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:50,代码来源:test_check_and_set_rebuild.py

示例8: prepare

# 需要导入模块: from atomic_reactor.inner import DockerBuildWorkflow [as 别名]
# 或者: from atomic_reactor.inner.DockerBuildWorkflow import source [as 别名]
def prepare(testfile="test-image", check_repo_retval=0):
    if MOCK:
        mock_docker()
    tasker = DockerTasker()
    workflow = DockerBuildWorkflow(SOURCE, testfile)
    workflow.source = StubSource()
    workflow.builder = StubInsideBuilder()
    workflow.tag_conf = StubTagConf().set_images([
        ImageName(repo="image-name1"),
        ImageName(namespace="prefix",
                  repo="image-name2"),
        ImageName(repo="image-name3",
                  tag="asd"),
    ])

    # Mock dockpulp and docker
    dockpulp.Pulp = flexmock(dockpulp.Pulp)
    dockpulp.Pulp.registry = 'registry.example.com'
    (flexmock(dockpulp.imgutils).should_receive('get_metadata')
     .with_args(object)
     .and_return([{'id': 'foo'}]))
    (flexmock(dockpulp.imgutils).should_receive('get_manifest')
     .with_args(object)
     .and_return([{'id': 'foo'}]))
    (flexmock(dockpulp.imgutils).should_receive('get_versions')
     .with_args(object)
     .and_return({'id': '1.6.0'}))
    (flexmock(dockpulp.imgutils).should_receive('check_repo')
     .and_return(check_repo_retval))
    (flexmock(dockpulp.Pulp)
     .should_receive('set_certs')
     .with_args(object, object))
    (flexmock(dockpulp.Pulp)
     .should_receive('login')
     .with_args(object, object))
    (flexmock(dockpulp.Pulp)
     .should_receive('getRepos')
     .with_args(list, fields=list, distributors=True)
     .and_return([
         {"id": "redhat-image-name1"},
         {"id": "redhat-prefix-image-name2"}
      ]))
    (flexmock(dockpulp.Pulp)
     .should_receive('createRepo'))

    mock_docker()
    return tasker, workflow
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:49,代码来源:test_pulp_util.py

示例9: mock_workflow

# 需要导入模块: from atomic_reactor.inner import DockerBuildWorkflow [as 别名]
# 或者: from atomic_reactor.inner.DockerBuildWorkflow import source [as 别名]
def mock_workflow():
    """
    Provide just enough structure that workflow can be used to run the plugin.
    Defaults below are solely to enable that purpose; tests where those values
    matter should provide their own.
    """

    workflow = DockerBuildWorkflow(SOURCE, "mock:default_built")
    workflow.source = StubSource()
    builder = StubInsideBuilder().for_workflow(workflow)
    builder.set_df_path('/mock-path')
    base_image_name = ImageName.parse("mock:tag")
    builder.parent_images[ImageName.parse("mock:base")] = base_image_name
    builder.base_image = base_image_name
    builder.tasker = flexmock()
    workflow.builder = flexmock(builder)

    return workflow
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:20,代码来源:test_change_from_in_df.py

示例10: prepare

# 需要导入模块: from atomic_reactor.inner import DockerBuildWorkflow [as 别名]
# 或者: from atomic_reactor.inner.DockerBuildWorkflow import source [as 别名]
def prepare(df_path, inherited_user=''):
    if MOCK:
        mock_docker()
    tasker = DockerTasker()
    workflow = DockerBuildWorkflow(SOURCE, "test-image")
    workflow.source = StubSource()
    workflow.builder = (StubInsideBuilder()
                        .for_workflow(workflow)
                        .set_df_path(df_path)
                        .set_inspection_data({
                            INSPECT_CONFIG: {
                                'User': inherited_user,
                            },
                        }))

    (flexmock(requests.Response, content=repocontent)
     .should_receive('raise_for_status')
     .and_return(None))
    (flexmock(requests.Session, get=lambda *_: requests.Response()))
    return tasker, workflow
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:22,代码来源:test_yum_inject.py

示例11: workflow

# 需要导入模块: from atomic_reactor.inner import DockerBuildWorkflow [as 别名]
# 或者: from atomic_reactor.inner.DockerBuildWorkflow import source [as 别名]
def workflow(tmpdir):
    if MOCK:
        mock_docker()

    buildstep_plugin = [{
        'name': OrchestrateBuildPlugin.key,
        'args': {
            'platforms': ODCS_COMPOSE_DEFAULT_ARCH_LIST
        },
    }]
    workflow = DockerBuildWorkflow(MOCK_SOURCE, 'test-image', buildstep_plugins=buildstep_plugin, )
    workflow.builder = MockInsideBuilder(tmpdir)
    workflow.source = workflow.builder.source
    workflow._tmpdir = tmpdir
    workflow.prebuild_results[PLUGIN_CHECK_AND_SET_PLATFORMS_KEY] = set(
                                                                    ODCS_COMPOSE_DEFAULT_ARCH_LIST)
    setattr(workflow.builder, 'base_image_inspect', {})

    mock_reactor_config(workflow, tmpdir)
    mock_repo_config(tmpdir)
    mock_odcs_request()
    workflow._koji_session = mock_koji_session()
    return workflow
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:25,代码来源:test_resolve_composes.py

示例12: mock_environment

# 需要导入模块: from atomic_reactor.inner import DockerBuildWorkflow [as 别名]
# 或者: from atomic_reactor.inner.DockerBuildWorkflow import source [as 别名]
def mock_environment(tmpdir, session=None, name=None,
                     component=None, version=None, release=None,
                     source=None, build_process_failed=False,
                     docker_registry=True, pulp_registries=0,
                     blocksize=None, task_states=None,
                     additional_tags=None, has_config=None,
                     prefer_schema1_digest=True):
    if session is None:
        session = MockedClientSession('', task_states=None)
    if source is None:
        source = GitSource('git', 'git://hostname/path')

    if MOCK:
        mock_docker()
    tasker = DockerTasker()
    workflow = DockerBuildWorkflow(SOURCE, "test-image")
    base_image_id = '123456parent-id'
    workflow.source = StubSource()
    workflow.builder = StubInsideBuilder().for_workflow(workflow)
    workflow.builder.image_id = '123456imageid'
    workflow.builder.set_inspection_data({'Id': base_image_id})
    setattr(workflow, 'tag_conf', TagConf())
    with open(os.path.join(str(tmpdir), 'Dockerfile'), 'wt') as df:
        df.write('FROM base\n'
                 'LABEL BZComponent={component} com.redhat.component={component}\n'
                 'LABEL Version={version} version={version}\n'
                 'LABEL Release={release} release={release}\n'
                 .format(component=component, version=version, release=release))
        workflow.builder.set_df_path(df.name)
    if name and version:
        workflow.tag_conf.add_unique_image('user/test-image:{v}-timestamp'
                                           .format(v=version))
    if name and version and release:
        workflow.tag_conf.add_primary_images(["{0}:{1}-{2}".format(name,
                                                                   version,
                                                                   release),
                                              "{0}:{1}".format(name, version),
                                              "{0}:latest".format(name)])

    if additional_tags:
        workflow.tag_conf.add_primary_images(["{0}:{1}".format(name, tag)
                                              for tag in additional_tags])

    flexmock(subprocess, Popen=fake_Popen)
    flexmock(koji, ClientSession=lambda hub, opts: session)
    flexmock(GitSource)
    setattr(workflow, 'source', source)
    setattr(workflow.source, 'lg', X())
    setattr(workflow.source.lg, 'commit_id', '123456')
    setattr(workflow, 'push_conf', PushConf())
    if docker_registry:
        docker_reg = workflow.push_conf.add_docker_registry('docker.example.com')

        for image in workflow.tag_conf.images:
            tag = image.to_str(registry=False)

            if pulp_registries and prefer_schema1_digest:
                docker_reg.digests[tag] = ManifestDigest(v1=fake_digest(image),
                                                         v2='sha256:not-used')
            else:
                docker_reg.digests[tag] = ManifestDigest(v1='sha256:not-used',
                                                         v2=fake_digest(image))

            if has_config:
                docker_reg.config = {
                    'config': {'architecture': LOCAL_ARCH},
                    'container_config': {}
                }

    for pulp_registry in range(pulp_registries):
        workflow.push_conf.add_pulp_registry('env', 'pulp.example.com')

    with open(os.path.join(str(tmpdir), 'image.tar.xz'), 'wt') as fp:
        fp.write('x' * 2**12)
        setattr(workflow, 'exported_image_sequence', [{'path': fp.name,
                                                       'type': IMAGE_TYPE_DOCKER_ARCHIVE}])

    if build_process_failed:
        workflow.build_result = BuildResult(logs=["docker build log - \u2018 \u2017 \u2019 \n'"],
                                            fail_reason="not built")
    else:
        workflow.build_result = BuildResult(logs=["docker build log - \u2018 \u2017 \u2019 \n'"],
                                            image_id="id1234")
    workflow.prebuild_plugins_conf = {}

    workflow.image_components = parse_rpm_output([
        "name1;1.0;1;" + LOCAL_ARCH + ";0;2000;" + FAKE_SIGMD5.decode() + ";23000;"
        "RSA/SHA256, Tue 30 Aug 2016 00:00:00, Key ID 01234567890abc;(none)",
        "name2;2.0;1;" + LOCAL_ARCH + ";0;3000;" + FAKE_SIGMD5.decode() + ";24000"
        "RSA/SHA256, Tue 30 Aug 2016 00:00:00, Key ID 01234567890abd;(none)",
    ])

    return tasker, workflow
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:95,代码来源:test_koji_upload.py


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