You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both across docker_links and needed_services.
needed_services multiple instances are allowed if they define the same
NeededServiceSerializer (same service_name, same env, etc..).
Goal:
guarantee that each different docker container has a unique link
name, while allowing multiple services linking to the same docker
container (thus without ambiguity).
Rules:
- docker_links: no duplicate link_name
- needed_services: can duplicate link_name iff NeededServices are
equivalent (same service_name, same env_exports, but env_exports and
other attributes can be different)
- same link_name cannot be reused between docker_links and
needed_services
How: compare kind and object:
- NeededServices has a specialized __eq__() testing the previously
defined equivalence
- DockerLink has the standard __eq__() testing object instance
equality
Unit tests:
test various combinations of DockerLink and NeededService creations.
Fix tests:
- prefix all link_names with `test-`, like we did for service name
- update test-resources accordingly
TODO later: isolate by app name, but it's not the first time I broke
that.
Copy file name to clipboardExpand all lines: dmake/deepobuild.py
+39Lines changed: 39 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -431,6 +431,13 @@ class DockerLinkSerializer(YAML2PipelineSerializer):
431
431
env=FieldSerializer("dict", child="string", default= {}, example= {'REDIS_URL': '${REDIS_URL}'}, help_text="Additional environment variables defined when running this image.")
432
432
env_exports=FieldSerializer("dict", child="string", default= {}, help_text="A set of environment variables that will be exported in services that use this link when testing.")
# link_name to (kind[needed_link|needed_service], object, file)
1104
+
link_names=dict()
1105
+
1106
+
@staticmethod
1107
+
defreset():
1108
+
LinkNames.link_names=dict()
1109
+
1110
+
@staticmethod
1111
+
defcheck_duplicate_link_name(kind, link, file):
1112
+
"""
1113
+
Goal: guarantee that each different docker container has a unique link name, while allowing multiple services linking to the same docker container (thus without ambiguity)
1114
+
Rules:
1115
+
- docker_links: no duplicate link_name
1116
+
- needed_services: can duplicate link_name iff NeededServices are equivalent (same service_name, same env_exports, but env_exports and other attributes can be different)
1117
+
- same link_name cannot be reused between docker_links and needed_services
1118
+
How: compare kind and object:
1119
+
- NeededServices has a specialized __eq__() testing the previously defined equivalence
1120
+
- DockerLink has the standard __eq__() testing object instance equality
raiseValidationError("Duplicate link name '{link_name}' with different definitions: '{kind}' in '{file}', was previously defined as '{other_kind}' in '{other_file}'".format(link_name=link_name, kind=kind, file=file, other_kind=other_kind, other_file=other_file))
0 commit comments