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


Python plugin.PostBuildPluginsRunner类代码示例

本文整理汇总了Python中atomic_reactor.plugin.PostBuildPluginsRunner的典型用法代码示例。如果您正苦于以下问题:Python PostBuildPluginsRunner类的具体用法?Python PostBuildPluginsRunner怎么用?Python PostBuildPluginsRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_pulp_tag_service_account_secret

def test_pulp_tag_service_account_secret(tmpdir, monkeypatch, caplog, reactor_config_map):
    v1_image_ids = {'x86_64': None,
                    'ppc64le': 'ppc64le_v1_image_id'}
    msg = "tagging v1-image-id ppc64le_v1_image_id for platform ppc64le"
    expected_results = {
        'redhat-image-name1': {'tag': 'latest:ppc64le_v1_image_id'},
    }

    tasker, workflow = prepare(v1_image_ids)
    monkeypatch.setenv('SOURCE_SECRET_PATH', str(tmpdir) + "/not-used")
    with open(os.path.join(str(tmpdir), "pulp.cer"), "wt") as cer:
        cer.write("pulp certificate\n")
    with open(os.path.join(str(tmpdir), "pulp.key"), "wt") as key:
        key.write("pulp key\n")

    runner = PostBuildPluginsRunner(tasker, workflow, [{
        'name': PLUGIN_PULP_TAG_KEY,
        'args': {
            'pulp_registry_name': 'test',
            'pulp_secret_path': str(tmpdir),
        }}])

    if reactor_config_map:
        workflow.plugin_workspace[ReactorConfigPlugin.key] = {}
        workflow.plugin_workspace[ReactorConfigPlugin.key][WORKSPACE_CONF_KEY] =\
            ReactorConfig({'version': 1,
                           'pulp': {'name': 'test',
                                    'auth': {'ssl_certs_dir': str(tmpdir)}}})

    results = runner.run()
    assert msg in caplog.text
    assert results['pulp_tag'] == expected_results
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:32,代码来源:test_pulp_tag.py

示例2: test_pulp_service_account_secret

def test_pulp_service_account_secret(tmpdir, monkeypatch, reactor_config_map):
    tasker, workflow = prepare()
    monkeypatch.setenv('SOURCE_SECRET_PATH', str(tmpdir) + "/not-used")
    with open(os.path.join(str(tmpdir), "pulp.cer"), "wt") as cer:
        cer.write("pulp certificate\n")
    with open(os.path.join(str(tmpdir), "pulp.key"), "wt") as key:
        key.write("pulp key\n")

    runner = PostBuildPluginsRunner(tasker, workflow, [{
        'name': PulpPushPlugin.key,
        'args': {
            'pulp_registry_name': 'test',
            'pulp_secret_path': str(tmpdir),
        }}])

    if reactor_config_map:
        workflow.plugin_workspace[ReactorConfigPlugin.key] = {}
        workflow.plugin_workspace[ReactorConfigPlugin.key][WORKSPACE_CONF_KEY] =\
            ReactorConfig({'version': 1,
                           'pulp': {'name': 'test',
                                    'auth': {'ssl_certs_dir': str(tmpdir)}}})

    runner.run()
    _, crane_images = workflow.postbuild_results[PulpPushPlugin.key]
    images = [i.to_str() for i in crane_images]
    assert "registry.example.com/image-name1:latest" in images
    assert "registry.example.com/prefix/image-name2:latest" in images
    assert "registry.example.com/image-name3:asd" in images
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:28,代码来源:test_pulp.py

示例3: test_pulp_source_secret

def test_pulp_source_secret(tmpdir, check_repo_retval, should_raise, monkeypatch):
    tasker, workflow = prepare(check_repo_retval=check_repo_retval)
    monkeypatch.setenv('SOURCE_SECRET_PATH', str(tmpdir))
    with open(os.path.join(str(tmpdir), "pulp.cer"), "wt") as cer:
        cer.write("pulp certificate\n")
    with open(os.path.join(str(tmpdir), "pulp.key"), "wt") as key:
        key.write("pulp key\n")

    runner = PostBuildPluginsRunner(tasker, workflow, [{
        'name': PulpPushPlugin.key,
        'args': {
            'pulp_registry_name': 'test'
        }}])

    if should_raise:
        with pytest.raises(Exception):
            runner.run()

        return

    runner.run()
    assert PulpPushPlugin.key is not None
    _, crane_images = workflow.postbuild_results[PulpPushPlugin.key]
    images = [i.to_str() for i in crane_images]
    assert "registry.example.com/image-name1:latest" in images
    assert "registry.example.com/prefix/image-name2:latest" in images
    assert "registry.example.com/image-name3:asd" in images
开发者ID:vrutkovs,项目名称:atomic-reactor,代码行数:27,代码来源:test_pulp.py

示例4: test_pulp_source_secret

def test_pulp_source_secret(tmpdir, check_repo_retval, should_raise, monkeypatch,
                            reactor_config_map):
    tasker, workflow = prepare(check_repo_retval=check_repo_retval)
    monkeypatch.setenv('SOURCE_SECRET_PATH', str(tmpdir))
    with open(os.path.join(str(tmpdir), "pulp.cer"), "wt") as cer:
        cer.write("pulp certificate\n")
    with open(os.path.join(str(tmpdir), "pulp.key"), "wt") as key:
        key.write("pulp key\n")

    runner = PostBuildPluginsRunner(tasker, workflow, [{
        'name': PulpPushPlugin.key,
        'args': {
            'pulp_registry_name': 'test'
        }}])

    if reactor_config_map:
        workflow.plugin_workspace[ReactorConfigPlugin.key] = {}
        workflow.plugin_workspace[ReactorConfigPlugin.key][WORKSPACE_CONF_KEY] =\
            ReactorConfig({'version': 1, 'pulp': {'name': 'test',
                                                  'auth': {'ssl_certs_dir': str(tmpdir)}}})

    if should_raise:
        with pytest.raises(Exception):
            runner.run()

        return

    runner.run()
    assert PulpPushPlugin.key is not None
    _, crane_images = workflow.postbuild_results[PulpPushPlugin.key]
    images = [i.to_str() for i in crane_images]
    assert "registry.example.com/image-name1:latest" in images
    assert "registry.example.com/prefix/image-name2:latest" in images
    assert "registry.example.com/image-name3:asd" in images
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:34,代码来源:test_pulp.py

示例5: test_cp_built_image_to_nfs

def test_cp_built_image_to_nfs(tmpdir, docker_tasker, dest_dir):
    mountpoint = tmpdir.join("mountpoint")

    def fake_check_call(cmd):
        assert cmd == [
            "mount",
            "-t", "nfs",
            "-o", "nolock",
            NFS_SERVER_PATH,
            mountpoint,
        ]
    flexmock(subprocess, check_call=fake_check_call)
    workflow = DockerBuildWorkflow({"provider": "git", "uri": "asd"}, "test-image")
    workflow.builder = X()
    workflow.exported_image_sequence.append({"path": os.path.join(str(tmpdir),
                                                             EXPORTED_SQUASHED_IMAGE_NAME)})
    open(workflow.exported_image_sequence[-1].get("path"), 'a').close()

    runner = PostBuildPluginsRunner(
        docker_tasker,
        workflow,
        [{
            'name': CopyBuiltImageToNFSPlugin.key,
            'args': {
                "nfs_server_path": NFS_SERVER_PATH,
                "dest_dir": dest_dir,
                "mountpoint": str(mountpoint),
            }
        }]
    )
    runner.run()
    if dest_dir is None:
        assert os.path.isfile(os.path.join(str(mountpoint), EXPORTED_SQUASHED_IMAGE_NAME))
    else:
        assert os.path.isfile(os.path.join(str(mountpoint), dest_dir, EXPORTED_SQUASHED_IMAGE_NAME))
开发者ID:Akasurde,项目名称:atomic-reactor,代码行数:35,代码来源:test_cp_built_image_to_nfs.py

示例6: test_pulp_dedup_layers

def test_pulp_dedup_layers(unsupported, unlink_exc, tmpdir, existing_layers, should_raise,
                           monkeypatch, subprocess_exceptions, reactor_config_map):
    tasker, workflow = prepare(
        check_repo_retval=0,
        existing_layers=existing_layers,
        subprocess_exceptions=subprocess_exceptions, unsupported=unsupported)
    monkeypatch.setenv('SOURCE_SECRET_PATH', str(tmpdir))
    with open(os.path.join(str(tmpdir), "pulp.cer"), "wt") as cer:
        cer.write("pulp certificate\n")
    with open(os.path.join(str(tmpdir), "pulp.key"), "wt") as key:
        key.write("pulp key\n")

    if unlink_exc is not None:
        (flexmock(os).should_receive('unlink')
         .and_raise(unlink_exc))

    runner = PostBuildPluginsRunner(tasker, workflow, [{
        'name': PulpPushPlugin.key,
        'args': {
            'pulp_registry_name': 'test'
        }}])

    if reactor_config_map:
        workflow.plugin_workspace[ReactorConfigPlugin.key] = {}
        workflow.plugin_workspace[ReactorConfigPlugin.key][WORKSPACE_CONF_KEY] =\
            ReactorConfig({'version': 1, 'pulp': {'name': 'test', 'auth': {}}})

    runner.run()
    assert PulpPushPlugin.key is not None
    top_layer, crane_images = workflow.postbuild_results[PulpPushPlugin.key]
    images = [i.to_str() for i in crane_images]
    assert "registry.example.com/image-name1:latest" in images
    assert "registry.example.com/prefix/image-name2:latest" in images
    assert "registry.example.com/image-name3:asd" in images
    assert top_layer == 'foo'
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:35,代码来源:test_pulp.py

示例7: test_pulp_tag_basic

def test_pulp_tag_basic(tmpdir, monkeypatch, v1_image_ids, should_raise, caplog):
    tasker, workflow = prepare(v1_image_ids)
    monkeypatch.setenv('SOURCE_SECRET_PATH', str(tmpdir))
    with open(os.path.join(str(tmpdir), "pulp.cer"), "wt") as cer:
        cer.write("pulp certificate\n")
    with open(os.path.join(str(tmpdir), "pulp.key"), "wt") as key:
        key.write("pulp key\n")

    runner = PostBuildPluginsRunner(tasker, workflow, [{
        'name': PLUGIN_PULP_TAG_KEY,
        'args': {
            'pulp_registry_name': 'test'
        }}])

    if should_raise:
        with pytest.raises(PluginFailedException):
            runner.run()
        return

    msg = None
    expected_results = {}
    for platform, v1_image_id in v1_image_ids.items():
        if v1_image_id:
            msg = "tagging v1-image-id ppc64le_v1_image_id for platform ppc64le"
            expected_results = {
                'redhat-image-name1': {'tag': 'latest:ppc64le_v1_image_id'},
            }
            break

    results = runner.run()
    if msg:
        assert msg in caplog.text()
    else:
        assert "tagging v1-image-id" not in caplog.text()
    assert results['pulp_tag'] == expected_results
开发者ID:vrutkovs,项目名称:atomic-reactor,代码行数:35,代码来源:test_pulp_tag.py

示例8: test_compare_components_plugin

def test_compare_components_plugin(tmpdir, caplog, base_from_scratch, mismatch, exception, fail):
    workflow = mock_workflow(tmpdir)
    worker_metadatas = mock_metadatas()

    # example data has 2 log items before component item hence output[2]
    component = worker_metadatas['ppc64le']['output'][2]['components'][0]
    if mismatch:
        component['version'] = 'bacon'
    if exception:
        workflow.plugin_workspace[ReactorConfigPlugin.key] = {
            WORKSPACE_CONF_KEY: ReactorConfig(
                {'version': 1, 'package_comparison_exceptions': [component['name']]}
            )
        }

    workflow.postbuild_results[PLUGIN_FETCH_WORKER_METADATA_KEY] = worker_metadatas
    workflow.builder.base_from_scratch = base_from_scratch

    runner = PostBuildPluginsRunner(
        None,
        workflow,
        [{
            'name': PLUGIN_COMPARE_COMPONENTS_KEY,
            "args": {}
        }]
    )

    if fail and not base_from_scratch:
        with pytest.raises(PluginFailedException):
            runner.run()
    else:
        runner.run()
        if base_from_scratch:
            log_msg = "Skipping comparing components: unsupported for FROM-scratch images"
            assert log_msg in caplog.text
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:35,代码来源:test_compare_components.py

示例9: test_pulp_tag_service_account_secret

def test_pulp_tag_service_account_secret(tmpdir, monkeypatch, caplog):
    v1_image_ids = {'x86_64': None,
                    'ppc64le': 'ppc64le_v1_image_id'}
    msg = "tagging v1-image-id ppc64le_v1_image_id for platform ppc64le"
    expected_results = {
        'redhat-image-name1': {'tag': 'latest:ppc64le_v1_image_id'},
    }

    tasker, workflow = prepare(v1_image_ids)
    monkeypatch.setenv('SOURCE_SECRET_PATH', str(tmpdir) + "/not-used")
    with open(os.path.join(str(tmpdir), "pulp.cer"), "wt") as cer:
        cer.write("pulp certificate\n")
    with open(os.path.join(str(tmpdir), "pulp.key"), "wt") as key:
        key.write("pulp key\n")

    runner = PostBuildPluginsRunner(tasker, workflow, [{
        'name': PLUGIN_PULP_TAG_KEY,
        'args': {
            'pulp_registry_name': 'test',
            'pulp_secret_path': str(tmpdir),
        }}])

    results = runner.run()
    assert msg in caplog.text()
    assert results['pulp_tag'] == expected_results
开发者ID:vrutkovs,项目名称:atomic-reactor,代码行数:25,代码来源:test_pulp_tag.py

示例10: test_pulp

def test_pulp(tmpdir, check_repo_retval, should_raise):
    tasker = DockerTasker()
    workflow = DockerBuildWorkflow(SOURCE, "test-image")
    setattr(workflow, 'builder', X())
    setattr(workflow.builder, 'source', X())
    setattr(workflow.builder.source, 'dockerfile_path', None)
    setattr(workflow.builder.source, 'path', None)
    setattr(workflow, 'tag_conf', X())
    setattr(workflow.tag_conf, '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_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('push_tar_to_pulp')
     .with_args(object, object)
     .and_return([1, 2, 3]))
    (flexmock(dockpulp.Pulp)
     .should_receive('watch_tasks')
     .with_args(list))
    mock_docker()

    os.environ['SOURCE_SECRET_PATH'] = str(tmpdir)
    with open(os.path.join(str(tmpdir), "pulp.cer"), "wt") as cer:
        cer.write("pulp certificate\n")
    with open(os.path.join(str(tmpdir), "pulp.key"), "wt") as key:
        key.write("pulp key\n")

    runner = PostBuildPluginsRunner(tasker, workflow, [{
        'name': PulpPushPlugin.key,
        'args': {
            'pulp_registry_name': 'test'
        }}])

    if should_raise:
        with pytest.raises(Exception) as exc:
            runner.run()

        return

    runner.run()
    assert PulpPushPlugin.key is not None
    images = [i.to_str() for i in workflow.postbuild_results[PulpPushPlugin.key]]
    assert "registry.example.com/image-name1" in images
    assert "registry.example.com/prefix/image-name2" in images
    assert "registry.example.com/image-name3:asd" in images
开发者ID:TomasTomecek,项目名称:atomic-reactor,代码行数:60,代码来源:test_pulp.py

示例11: test_pulp_dedup_layers

def test_pulp_dedup_layers(
        tmpdir, existing_layers, should_raise, monkeypatch, subprocess_exceptions):
    tasker, workflow = prepare(
        check_repo_retval=0,
        existing_layers=existing_layers,
        subprocess_exceptions=subprocess_exceptions)
    monkeypatch.setenv('SOURCE_SECRET_PATH', str(tmpdir))
    with open(os.path.join(str(tmpdir), "pulp.cer"), "wt") as cer:
        cer.write("pulp certificate\n")
    with open(os.path.join(str(tmpdir), "pulp.key"), "wt") as key:
        key.write("pulp key\n")

    runner = PostBuildPluginsRunner(tasker, workflow, [{
        'name': PulpPushPlugin.key,
        'args': {
            'pulp_registry_name': 'test'
        }}])

    runner.run()
    assert PulpPushPlugin.key is not None
    top_layer, crane_images = workflow.postbuild_results[PulpPushPlugin.key]
    images = [i.to_str() for i in crane_images]
    assert "registry.example.com/image-name1:latest" in images
    assert "registry.example.com/prefix/image-name2:latest" in images
    assert "registry.example.com/image-name3:asd" in images
    assert top_layer == 'foo'
开发者ID:vrutkovs,项目名称:atomic-reactor,代码行数:26,代码来源:test_pulp.py

示例12: test_compress

    def test_compress(self, tmpdir, method, load_exported_image, extension):
        if MOCK:
            mock_docker()

        tasker = DockerTasker()
        workflow = DockerBuildWorkflow({'provider': 'git', 'uri': 'asd'}, 'test-image')
        workflow.builder = X()
        exp_img = os.path.join(str(tmpdir), 'img.tar')

        if load_exported_image:
            tarfile.open(exp_img, mode='w').close()
            workflow.exported_image_sequence.append({'path': exp_img})

        runner = PostBuildPluginsRunner(
            tasker,
            workflow,
            [{
                'name': CompressPlugin.key,
                'args': {
                    'method': method,
                    'load_exported_image': load_exported_image,
                },
            }]
        )

        runner.run()

        compressed_img = os.path.join(
            workflow.source.tmpdir,
            EXPORTED_COMPRESSED_IMAGE_NAME_TEMPLATE.format(extension))
        assert os.path.exists(compressed_img)
        assert workflow.exported_image_sequence[-1]['path'] == compressed_img
开发者ID:Akasurde,项目名称:atomic-reactor,代码行数:32,代码来源:test_compress.py

示例13: test_rpmqa_plugin

def test_rpmqa_plugin(remove_container_error, ignore_autogenerated):
    if MOCK:
        should_raise_error = {}
        if remove_container_error:
            should_raise_error['remove_container'] = None
        mock_docker(should_raise_error=should_raise_error)

    tasker = DockerTasker()
    workflow = DockerBuildWorkflow(SOURCE, "test-image")
    setattr(workflow, 'builder', X())
    setattr(workflow.builder, 'image_id', "asd123")
    setattr(workflow.builder, 'base_image', ImageName(repo='fedora', tag='21'))
    setattr(workflow.builder, "source", X())
    setattr(workflow.builder.source, 'dockerfile_path', "/non/existent")
    setattr(workflow.builder.source, 'path', "/non/existent")

    flexmock(docker.Client, logs=mock_logs)
    runner = PostBuildPluginsRunner(
        tasker,
        workflow,
        [{"name": PostBuildRPMqaPlugin.key,
          "args": {
              'image_id': TEST_IMAGE,
              "ignore_autogenerated_gpg_keys": ignore_autogenerated["ignore"]}}
    ])
    results = runner.run()
    assert results[PostBuildRPMqaPlugin.key] == ignore_autogenerated["package_list"]
开发者ID:maxamillion,项目名称:atomic-reactor,代码行数:27,代码来源:test_rpmqa.py

示例14: test_rpmqa_plugin_skip

def test_rpmqa_plugin_skip(docker_tasker):  # noqa
    """
    Test skipping the plugin if workflow.image_components is already set
    """

    workflow = DockerBuildWorkflow(SOURCE, "test-image")
    setattr(workflow, 'builder', X())
    setattr(workflow.builder, 'image_id', "asd123")
    setattr(workflow.builder, 'base_image', ImageName(repo='fedora', tag='21'))
    setattr(workflow.builder, "source", X())
    setattr(workflow.builder.source, 'dockerfile_path', "/non/existent")
    setattr(workflow.builder.source, 'path', "/non/existent")

    image_components = {
        'type': 'rpm',
        'name': 'something'
    }
    setattr(workflow, 'image_components', image_components)

    mock_docker()
    flexmock(docker.APIClient, logs=mock_logs_raise)
    runner = PostBuildPluginsRunner(docker_tasker, workflow,
                                    [{"name": PostBuildRPMqaPlugin.key,
                                      "args": {'image_id': TEST_IMAGE}}])
    results = runner.run()
    assert results[PostBuildRPMqaPlugin.key] is None
    assert workflow.image_components == image_components
开发者ID:vrutkovs,项目名称:atomic-reactor,代码行数:27,代码来源:test_rpmqa.py

示例15: build_docker_image

    def build_docker_image(self):
        """
        build docker image

        :return: BuildResults
        """
        self.builder = InsideBuilder(self.source, self.image)
        try:
            # time to run pre-build plugins, so they can access cloned repo
            logger.info("running pre-build plugins")
            prebuild_runner = PreBuildPluginsRunner(self.builder.tasker, self, self.prebuild_plugins_conf,
                                                    plugin_files=self.plugin_files)
            try:
                prebuild_runner.run()
            except PluginFailedException as ex:
                logger.error("one or more prebuild plugins failed: %s", ex)
                raise

            build_result = self.builder.build()
            self.build_logs = build_result.logs

            self.build_failed = build_result.is_failed()

            if not build_result.is_failed():
                self.built_image_inspect = self.builder.inspect_built_image()

            # run prepublish plugins
            prepublish_runner = PrePublishPluginsRunner(self.builder.tasker, self, self.prepublish_plugins_conf,
                                                        plugin_files=self.plugin_files)
            try:
                prepublish_runner.run()
            except PluginFailedException as ex:
                logger.error("one or more prepublish plugins failed: %s", ex)
                raise

            if not build_result.is_failed():
                for registry in self.push_conf.docker_registries:
                    self.builder.push_built_image(registry.uri,
                                                  insecure=registry.insecure)

            postbuild_runner = PostBuildPluginsRunner(self.builder.tasker, self, self.postbuild_plugins_conf,
                                                      plugin_files=self.plugin_files)
            try:
                postbuild_runner.run()
            except PluginFailedException as ex:
                logger.error("one or more postbuild plugins failed: %s", ex)
                raise

            return build_result
        finally:
            self.source.remove_tmpdir()

            exit_runner = ExitPluginsRunner(self.builder.tasker, self,
                                            self.exit_plugins_conf,
                                            plugin_files=self.plugin_files)
            try:
                exit_runner.run()
            except PluginFailedException as ex:
                logger.error("one or more exit plugins failed: %s", ex)
开发者ID:fr34k8,项目名称:atomic-reactor,代码行数:59,代码来源:inner.py


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