1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
TCP_PROTOCOL = "TCP"
UDP_PROTOCOL = "UDP"
HTTP_APPLICATION_PROTOCOL = "http"
NOT_PROVIDED_APPLICATION_PROTOCOL = ""
NOT_PROVIDED_WAIT = "not-provided-wait"
def new_template_and_data(template, template_data_json):
return struct(template=template, data=template_data_json)
def path_join(*args):
joined_path = "/".join(args)
return joined_path.replace("//", "/")
def path_base(path):
split_path = path.split("/")
return split_path[-1]
def path_dir(path):
split_path = path.split("/")
if len(split_path) <= 1:
return "."
split_path = split_path[:-1]
return "/".join(split_path) or "/"
def new_port_spec(
number,
transport_protocol,
application_protocol=NOT_PROVIDED_APPLICATION_PROTOCOL,
wait=NOT_PROVIDED_WAIT,
):
if wait == NOT_PROVIDED_WAIT:
return PortSpec(
number=number,
transport_protocol=transport_protocol,
application_protocol=application_protocol,
)
return PortSpec(
number=number,
transport_protocol=transport_protocol,
application_protocol=application_protocol,
wait=wait,
)
def read_file_from_service(plan, service_name, filename):
output = plan.exec(
service_name=service_name,
recipe=ExecRecipe(
command=["/bin/sh", "-c", "cat {} | tr -d '\n'".format(filename)]
),
)
return output["output"]
def zfill_custom(value, width):
return ("0" * (width - len(str(value)))) + str(value)
def label_maker(client, client_type, image, connected_client, extra_labels):
labels = {
"ethereum-package.client": client,
"ethereum-package.client-type": client_type,
"ethereum-package.client-image": image.replace("/", "-").replace(":", "-"),
"ethereum-package.connected-client": connected_client,
}
labels.update(extra_labels) # Add extra_labels to the labels dictionary
return labels