本文整理汇总了Python中atomic_reactor.inner.DockerBuildWorkflow.plugin_workspace方法的典型用法代码示例。如果您正苦于以下问题:Python DockerBuildWorkflow.plugin_workspace方法的具体用法?Python DockerBuildWorkflow.plugin_workspace怎么用?Python DockerBuildWorkflow.plugin_workspace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atomic_reactor.inner.DockerBuildWorkflow
的用法示例。
在下文中一共展示了DockerBuildWorkflow.plugin_workspace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare
# 需要导入模块: from atomic_reactor.inner import DockerBuildWorkflow [as 别名]
# 或者: from atomic_reactor.inner.DockerBuildWorkflow import plugin_workspace [as 别名]
def prepare(success=True, v1_image_ids={}):
if MOCK:
mock_docker()
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(repo="image-name1",
tag="2"),
ImageName(namespace="namespace",
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('check_repo')
.and_return(0))
(flexmock(dockpulp.Pulp)
.should_receive('set_certs')
.with_args(object, object))
(flexmock(dockpulp.Pulp)
.should_receive('getRepos')
.with_args(list, fields=list)
.and_return([
{"id": "redhat-image-name1"},
{"id": "redhat-namespace-image-name2"}
]))
(flexmock(dockpulp.Pulp)
.should_receive('createRepo'))
(flexmock(dockpulp.Pulp)
.should_receive('copy')
.with_args(unicode, unicode))
(flexmock(dockpulp.Pulp)
.should_receive('updateRepo')
.with_args(unicode, dict))
(flexmock(dockpulp.Pulp)
.should_receive('')
.with_args(object, object)
.and_return([1, 2, 3]))
annotations = {
'worker-builds': {
'x86_64': {
'build': {
'build-name': 'build-1-x64_64',
},
'metadata_fragment': 'configmap/build-1-x86_64-md',
'metadata_fragment_key': 'metadata.json',
},
'ppc64le': {
'build': {
'build-name': 'build-1-ppc64le',
},
'metadata_fragment': 'configmap/build-1-ppc64le-md',
'metadata_fragment_key': 'metadata.json',
}
}
}
if success:
workflow.build_result = BuildResult(image_id='12345')
else:
workflow.build_result = BuildResult(fail_reason="not built", annotations=annotations)
build_info = {}
build_info['x86_64'] = BuildInfo()
build_info['ppc64le'] = BuildInfo()
for platform, v1_image_id in v1_image_ids.items():
build_info[platform] = BuildInfo(v1_image_id)
workflow.plugin_workspace = {
OrchestrateBuildPlugin.key: {
WORKSPACE_KEY_BUILD_INFO: build_info
}
}
mock_docker()
return tasker, workflow
示例2: prepare
# 需要导入模块: from atomic_reactor.inner import DockerBuildWorkflow [as 别名]
# 或者: from atomic_reactor.inner.DockerBuildWorkflow import plugin_workspace [as 别名]
def prepare(v1_image_ids={}):
if MOCK:
mock_docker()
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")])
# 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(0))
(flexmock(dockpulp.Pulp)
.should_receive('set_certs')
.with_args(object, object))
(flexmock(dockpulp.Pulp)
.should_receive('getRepos')
.with_args(list, fields=list)
.and_return([
{"id": "redhat-image-name1"},
{"id": "redhat-prefix-image-name2"}
]))
(flexmock(dockpulp.Pulp)
.should_receive('createRepo'))
(flexmock(dockpulp.Pulp)
.should_receive('upload')
.with_args(unicode)).at_most().once()
(flexmock(dockpulp.Pulp)
.should_receive('copy')
.with_args(unicode, unicode))
(flexmock(dockpulp.Pulp)
.should_receive('updateRepo')
.with_args('redhat-image-name1', {'tag': 'latest:ppc64le_v1_image_id'}))
(flexmock(dockpulp.Pulp)
.should_receive('crane')
.with_args(list, wait=True)
.and_return([2, 3, 4]))
(flexmock(dockpulp.Pulp)
.should_receive('')
.with_args(object, object)
.and_return([1, 2, 3]))
(flexmock(dockpulp.Pulp)
.should_receive('watch_tasks')
.with_args(list))
annotations = {
'worker-builds': {
'x86_64': {
'build': {
'build-name': 'build-1-x64_64',
},
'metadata_fragment': 'configmap/build-1-x86_64-md',
'metadata_fragment_key': 'metadata.json',
},
'ppc64le': {
'build': {
'build-name': 'build-1-ppc64le',
},
'metadata_fragment': 'configmap/build-1-ppc64le-md',
'metadata_fragment_key': 'metadata.json',
}
}
}
workflow.build_result = BuildResult(logs=["docker build log - \u2018 \u2017 \u2019 \n'"],
image_id="id1234", annotations=annotations)
build_info = {}
build_info['x86_64'] = BuildInfo()
build_info['ppc64le'] = BuildInfo()
for platform, v1_image_id in v1_image_ids.items():
build_info[platform] = BuildInfo(v1_image_id)
workflow.plugin_workspace = {
OrchestrateBuildPlugin.key: {
WORKSPACE_KEY_BUILD_INFO: build_info
}
}
mock_docker()
return tasker, workflow