本文整理汇总了Python中common.Common.docker_build方法的典型用法代码示例。如果您正苦于以下问题:Python Common.docker_build方法的具体用法?Python Common.docker_build怎么用?Python Common.docker_build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.Common
的用法示例。
在下文中一共展示了Common.docker_build方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import docker_build [as 别名]
def __init__(self, path, host_path, pipeline=None, start_location=None):
self.path = path
self.host_path = host_path
if pipeline:
self.pipeline = pipeline
else:
Common.message("host_path: "+host_path)
self.pipeline = Common.load_yaml(path)
if start_location:
self.location = start_location
elif '__location__' in self.pipeline:
self.location = self.pipeline['__location__']
else:
os.path.basename(self.path)+":1"
self.steps = []
self.tests = {}
for step in self.pipeline['pipeline']:
if isinstance(step, str):
if step == "exit":
self.steps.append({ 'exit': { 'location': self.location.split(':',1)[0] }})
else:
Common.message("WARNING: unknown instruction found: '"+step+"' (skipping!)")
continue
step_line = [key for key in list(step.keys()) if not key.startswith('_')]
step_line = None if len(step_line) == 0 else step_line[0]
if 'image' in step:
image = { 'location': str(step['__location__']), 'name': step['image'], 'id': step['image'] }
if 'command' in step:
image['command'] = step['command']
self.steps.append({ 'image': image })
elif 'dockerfile' in step:
image_id = Common.docker_build(os.path.dirname(path)+"/"+step['dockerfile']+"/")
image = { 'location': str(step['__location__']), 'name': step['dockerfile'], 'id': image_id }
if 'command' in step:
image['command'] = step['command']
self.steps.append({ 'image': image })
elif 'unfold' in step:
self.steps.append({'unfold':{'location': str(step['__location__']), 'name':'unfold', 'depth':step['unfold']}})
elif 'test' in step:
test_input = '*' if not 'input' in step['test'] else step['test']['input']
test = { 'location': str(step['__location__']), 'name': test_input }
for key in ['input', 'expect', 'status', 'focus', 'context']:
if key in step['test']:
test[key] = step['test'][key]
if not test_input in self.tests:
self.tests[test_input] = {}
self.tests[test_input][str(len(self.steps))] = test
self.steps.append({ 'test': test })
elif 'assert' in step:
assertion = { 'test': { 'location': str(step['__location__']), 'name': '*', 'input': '*', 'status': step['assert'] if not step['assert'] == None else "" }}
if not '*' in self.tests:
self.tests['*'] = {}
self.tests['*'][str(len(self.steps))] = assertion['test']
self.steps.append(assertion)
elif step_line.startswith('if'):
test = step_line[2:].split(":",1)[0].strip()
subpipeline_name = 'pipeline' if not 'name' in self.pipeline['pipeline'] else self.pipeline['pipeline']['name']
subpipeline_if = Pipeline(
self.path,
self.host_path,
pipeline={
'name': subpipeline_name,
'pipeline': step[step_line]
},
start_location=step['__location__']
)
subpipeline_else = Pipeline(
self.path,
self.host_path,
pipeline={
'name': subpipeline_name,
'pipeline': []
},
start_location=step['__location__']
)
for test_input in subpipeline_if.tests:
if not test_input in self.tests:
self.tests[test_input] = {}
for subtest_id in subpipeline_if.tests[test_input]:
self.tests[test_input][str(len(self.steps))+'.'+subtest_id] = subpipeline_if.tests[test_input][subtest_id]
self.steps.append({ 'choose':
{ 'location': str(step['__location__']),
'choices': [
{ 'when': {
'location': str(step['__location__']),
'test': test,
'pipeline': subpipeline_if
}},
{ 'otherwise': {
'location': str(step['__location__']),
'pipeline': subpipeline_else
}}
#.........这里部分代码省略.........