@@ -110,15 +110,14 @@ def config(ctx, check, sync, verbose):
110
110
version = get_version_string (check )
111
111
112
112
spec_file_content = read_file (spec_file_path )
113
- default_temp = validate_default_template (spec_file_content )
114
- spec = ConfigSpec (spec_file_content , source = source , version = version )
115
- spec .load ()
116
113
117
- if not default_temp :
114
+ if not validate_default_template ( spec_file_content ) :
118
115
message = "Missing default template in init_config or instances section"
119
116
check_display_queue .append (lambda message = message , ** kwargs : echo_failure (message , ** kwargs ))
120
117
annotate_error (spec_file_path , message )
121
118
119
+ spec = ConfigSpec (spec_file_content , source = source , version = version )
120
+ spec .load ()
122
121
if spec .errors :
123
122
files_failed [spec_file_path ] = True
124
123
for error in spec .errors :
@@ -184,19 +183,14 @@ def config(ctx, check, sync, verbose):
184
183
185
184
186
185
def validate_default_template (spec_file ):
187
- init_config_default = False
188
- instances_default = False
189
186
if 'template: init_config' not in spec_file or 'template: instances' not in spec_file :
190
187
# This config spec does not have init_config or instances
191
188
return True
192
-
193
189
for line in spec_file .split ('\n ' ):
194
- if any ("init_config/{}" .format (template ) in line for template in TEMPLATES ):
195
- init_config_default = True
196
- if any ("instances/{}" .format (template ) in line for template in TEMPLATES ):
197
- instances_default = True
198
-
199
- if instances_default and init_config_default :
190
+ has_default_templates = any ("init_config/{}" .format (template ) in line for template in TEMPLATES ) and any (
191
+ "instances/{}" .format (template ) in line for template in TEMPLATES
192
+ )
193
+ if has_default_templates :
200
194
return True
201
195
return False
202
196
0 commit comments