本文整理汇总了Python中atomic_reactor.build.InsideBuilder类的典型用法代码示例。如果您正苦于以下问题:Python InsideBuilder类的具体用法?Python InsideBuilder怎么用?Python InsideBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InsideBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_build_bad_git_commit_dockerfile
def test_build_bad_git_commit_dockerfile(tmpdir, source_params):
provided_image = "test-build:test_tag"
if MOCK:
mock_docker(build_should_fail=True, provided_image_repotags=provided_image)
source_params.update({'tmpdir': str(tmpdir)})
s = get_source_instance_for(source_params)
b = InsideBuilder(s, provided_image)
build_result = b.build()
assert build_result.is_failed()
示例2: test_no_base_image
def test_no_base_image(tmpdir):
if MOCK:
mock_docker()
source = {'provider': 'path', 'uri': 'file://' + DOCKERFILE_OK_PATH, 'tmpdir': str(tmpdir)}
b = InsideBuilder(get_source_instance_for(source), 'built-img')
dfp = df_parser(str(tmpdir))
dfp.content = "# no FROM\nADD spam /eggs"
with pytest.raises(RuntimeError) as exc:
b.set_df_path(str(tmpdir))
assert "no base image specified" in str(exc.value)
示例3: test_pull_base_image_with_registry
def test_pull_base_image_with_registry(tmpdir):
mock_docker()
source_params = {"provider": "path", "uri": "file://%s" % str(tmpdir), "tmpdir": str(tmpdir)}
with open(os.path.join(str(tmpdir), DOCKERFILE_FILENAME), "wt") as fp:
fp.writelines(["FROM %s/namespace/repo:tag\n" % LOCALHOST_REGISTRY])
s = get_source_instance_for(source_params)
t = DockerTasker()
b = InsideBuilder(s, "")
pulled_tags = b.pull_base_image(LOCALHOST_REGISTRY, insecure=True)
assert isinstance(pulled_tags, set)
示例4: test_inspect_base_image
def test_inspect_base_image(tmpdir, source_params):
if MOCK:
mock_docker()
source_params.update({'tmpdir': str(tmpdir)})
s = get_source_instance_for(source_params)
b = InsideBuilder(s, '')
built_inspect = b.inspect_base_image()
assert built_inspect is not None
assert built_inspect["Id"] is not None
示例5: test_get_base_image_info
def test_get_base_image_info(tmpdir, source_params):
if MOCK:
mock_docker(provided_image_repotags='fedora:latest')
source_params.update({'tmpdir': str(tmpdir)})
s = get_source_instance_for(source_params)
b = InsideBuilder(s, '')
built_inspect = b.get_base_image_info()
assert built_inspect is not None
assert built_inspect["Id"] is not None
assert built_inspect["RepoTags"] is not None
示例6: test_inspect_built_image
def test_inspect_built_image(tmpdir, source_params):
provided_image = "test-build:test_tag"
if MOCK:
mock_docker(provided_image_repotags=provided_image)
flexmock(InsideBuilder, ensure_is_built=None)
source_params.update({'tmpdir': str(tmpdir)})
s = get_source_instance_for(source_params)
b = InsideBuilder(s, provided_image)
built_inspect = b.inspect_built_image()
assert built_inspect is not None
assert built_inspect["Id"] is not None
示例7: test_get_image_built_info
def test_get_image_built_info(tmpdir, source_params, image, will_raise):
if MOCK:
mock_docker(provided_image_repotags=image)
source_params.update({'tmpdir': str(tmpdir)})
s = get_source_instance_for(source_params)
b = InsideBuilder(s, image)
if will_raise:
with pytest.raises(Exception):
b.get_built_image_info()
else:
b.get_built_image_info()
示例8: test_build_image
def test_build_image(tmpdir, source_params):
provided_image = "test-build:test_tag"
if MOCK:
mock_docker(provided_image_repotags=provided_image)
source_params.update({'tmpdir': str(tmpdir)})
s = get_source_instance_for(source_params)
t = DockerTasker()
b = InsideBuilder(s, provided_image)
build_result = b.build()
assert t.inspect_image(build_result.image_id)
# clean
t.remove_image(build_result.image_id)
示例9: test_parent_images
def test_parent_images(parents_pulled, tmpdir, source_params):
if MOCK:
mock_docker()
s = get_source_instance_for(source_params)
b = InsideBuilder(s, '')
orig_base = b.base_image
if not b.base_from_scratch:
assert orig_base in b.parent_images
assert b.parent_images[orig_base] is None
b.set_base_image("spam:eggs", parents_pulled=parents_pulled)
assert b.parent_images[orig_base] == ImageName.parse("spam:eggs")
assert b.parents_pulled == parents_pulled
示例10: test_parent_images_to_str
def test_parent_images_to_str(tmpdir, caplog):
if MOCK:
mock_docker()
source = {'provider': 'path', 'uri': 'file://' + DOCKERFILE_OK_PATH, 'tmpdir': str(tmpdir)}
b = InsideBuilder(get_source_instance_for(source), 'built-img')
b.set_base_image("spam")
b.parent_images["bacon"] = None
expected_results = {
"fedora:latest": "spam:latest"
}
assert b.parent_images_to_str() == expected_results
assert "None in: base bacon has parent None" in caplog.text
示例11: test_build_generator_raises
def test_build_generator_raises(tmpdir):
provided_image = "test-build:test_tag"
if MOCK:
mock_docker(provided_image_repotags=provided_image, build_should_fail=True, build_should_fail_generator=True)
source_params = SOURCE.copy()
source_params.update({"tmpdir": str(tmpdir)})
s = get_source_instance_for(source_params)
t = DockerTasker()
b = InsideBuilder(s, provided_image)
build_result = b.build()
assert isinstance(build_result, ExceptionBuildResult)
assert build_result.is_failed()
assert "build generator failure" in build_result.logs
示例12: test_get_base_image_info
def test_get_base_image_info(tmpdir, source_params, image, will_raise):
if MOCK:
mock_docker(provided_image_repotags=image)
source_params.update({'tmpdir': str(tmpdir)})
s = get_source_instance_for(source_params)
b = InsideBuilder(s, image)
if will_raise:
with pytest.raises(Exception):
built_inspect = b.get_base_image_info()
else:
built_inspect = b.get_base_image_info()
assert built_inspect is not None
assert built_inspect["Id"] is not None
assert built_inspect["RepoTags"] is not None
示例13: 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)
示例14: test_pull_base_image
def test_pull_base_image(tmpdir, source_params):
if MOCK:
mock_docker()
source_params.update({"tmpdir": str(tmpdir)})
s = get_source_instance_for(source_params)
t = DockerTasker()
b = InsideBuilder(s, "")
pulled_tags = b.pull_base_image(LOCALHOST_REGISTRY, insecure=True)
assert isinstance(pulled_tags, set)
assert len(pulled_tags) == 2
for reg_img_name in pulled_tags:
reg_img_name = ImageName.parse(reg_img_name)
assert t.inspect_image(reg_img_name) is not None
assert reg_img_name.repo == git_base_image.repo
assert reg_img_name.tag == git_base_image.tag
# clean
t.remove_image(git_base_image)
示例15: test_parent_image_inspect
def test_parent_image_inspect(parents_pulled, tmpdir, source_params):
provided_image = "test-build:test_tag"
if MOCK:
mock_docker(provided_image_repotags=provided_image)
source_params.update({'tmpdir': str(tmpdir)})
s = get_source_instance_for(source_params)
b = InsideBuilder(s, provided_image)
b.parents_pulled = parents_pulled
if not parents_pulled:
(flexmock(atomic_reactor.util)
.should_receive('get_inspect_for_image')
.and_return({'Id': 123}))
built_inspect = b.parent_image_inspect(provided_image)
assert built_inspect is not None
assert built_inspect["Id"] is not None