소스 검색

Config now catches undefined service links
Fixes issue #2922
Signed-off-by: John Harris <[email protected]>

johnharris85 9 년 전
부모
커밋
68272b0216
2개의 변경된 파일10개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      compose/config/config.py
  2. 8 0
      compose/config/validation.py

+ 2 - 0
compose/config/config.py

@@ -37,6 +37,7 @@ from .validation import validate_against_config_schema
 from .validation import validate_config_section
 from .validation import validate_depends_on
 from .validation import validate_extends_file_path
+from .validation import validate_links
 from .validation import validate_network_mode
 from .validation import validate_service_constraints
 from .validation import validate_top_level_object
@@ -580,6 +581,7 @@ def validate_service(service_config, service_names, version):
     validate_ulimits(service_config)
     validate_network_mode(service_config, service_names)
     validate_depends_on(service_config, service_names)
+    validate_links(service_config, service_names)
 
     if not service_dict.get('image') and has_uppercase(service_name):
         raise ConfigurationError(

+ 8 - 0
compose/config/validation.py

@@ -171,6 +171,14 @@ def validate_network_mode(service_config, service_names):
             "is undefined.".format(s=service_config, dep=dependency))
 
 
+def validate_links(service_config, service_names):
+    for dependency in service_config.config.get('links', []):
+        if dependency not in service_names:
+            raise ConfigurationError(
+                "Service '{s.name}' has a link to service '{dep}' which is "
+                "undefined.".format(s=service_config, dep=dependency))
+
+
 def validate_depends_on(service_config, service_names):
     for dependency in service_config.config.get('depends_on', []):
         if dependency not in service_names: