2323from ...ecosystem_tests_cli import ecosystem_tests
2424
2525exit_codes = []
26- plugin_yamls = [ 'plugin.yaml' , 'plugin_1_4.yaml' ]
26+ PLUGIN_YAML = 'plugin.yaml'
2727content = {
28- 'plugin.yaml' : {},
29- 'v2_plugin.yaml' : {}
28+ 'plugin.yaml' : {}
3029}
31- V2_KEYS = ['labels' , 'blueprint_labels' , 'resource_tags' ]
3230TAG_PLUGINS = set ('aws' )
3331
3432
@@ -39,18 +37,14 @@ def validate_plugin_yamls(directory):
3937 directory = directory or os .path .join (
4038 os .path .abspath (os .path .join (os .path .dirname (__file__ ), os .pardir )))
4139
42- logger .info (f'Checking for YAMLs in { directory } ' )
43- for plugin_yaml in plugin_yamls :
44- check_required_plugin_yaml (directory , plugin_yaml )
45-
46- check_content_rules (directory )
47-
40+ logger .info (f'Checking for plugin.yaml in { directory } ' )
41+ check_required_plugin_yaml (directory , PLUGIN_YAML )
4842 if any (exit_codes ):
4943 sys .exit (1 )
5044
5145
5246def check_required_plugin_yaml (directory , filename ):
53- """Check that we have all plugin yamls that are expected. """
47+ """Check that we have plugin yaml that are expected. """
5448 fullpath = os .path .join (directory , filename )
5549 if not os .path .exists (fullpath ):
5650 logger .info ('The file {} does not exist.' .format (filename ))
@@ -59,54 +53,6 @@ def check_required_plugin_yaml(directory, filename):
5953 content [filename ] = safe_load (open (fullpath )) or {}
6054
6155
62- def check_content_rules (directory ):
63- check_v1_plugin_yaml_no_forbidden_keys ()
64- check_v2_plugin_yaml_required_keys ()
65- compare_v2_v1_plugin_yaml (directory )
66-
67-
68- def check_v1_plugin_yaml_no_forbidden_keys ():
69- """Check that plugin.yaml does not contain any incompatible keys."""
70- v1_plugin_yaml_keys = content ['plugin.yaml' ].keys ()
71- for forbidden in V2_KEYS :
72- if forbidden in v1_plugin_yaml_keys :
73- logger .error ('plugin.yaml '
74- 'contains forbidden key {}' .format (forbidden ))
75- exit_codes .append (1 )
76-
77-
78- def check_v2_plugin_yaml_required_keys ():
79- """Make sure that v2_plugin.yaml has expected keys."""
80- if not content ['v2_plugin.yaml' ]:
81- return
82- plugins = set (content ['v2_plugin.yaml' ]['plugins' ])
83- v2_plugin_yaml_keys = content ['v2_plugin.yaml' ].keys ()
84- for expected in V2_KEYS :
85- if expected == 'resource_tags' and not plugins .issubset (TAG_PLUGINS ):
86- continue
87- if expected not in v2_plugin_yaml_keys :
88- logger .error ('v2_plugin.yaml '
89- 'does not contain expected key {}' .format (expected ))
90- exit_codes .append (1 )
91-
92-
93- def compare_v2_v1_plugin_yaml (directory ):
94- """Make sure that plugin.yaml and v2_plugin.yaml are the same core."""
95- if not content ['v2_plugin.yaml' ]:
96- return
97- cp_v2_plugin_yaml = deepcopy (content ['v2_plugin.yaml' ])
98- for expected in V2_KEYS :
99- if expected in cp_v2_plugin_yaml :
100- del cp_v2_plugin_yaml [expected ]
101- if not cp_v2_plugin_yaml == content ['plugin.yaml' ]:
102- if not ignore_plugin_yaml_differences (content ['plugin.yaml' ],
103- cp_v2_plugin_yaml ,
104- directory ):
105- logger .error ('plugin.yaml and v2_plugin.yaml '
106- 'are not equivalent after removing v2 features.' )
107- exit_codes .append (1 )
108-
109-
11056def ignore_plugin_yaml_differences (v1 , v2 , directory ):
11157 str_diff = ''
11258 path = os .path .join (directory , 'ignore_plugin_yaml_differences' )
0 commit comments