Skip to content

Commit baeffa3

Browse files
iliakurNouemanKHAL
andauthored
Stop relying on manifest.json to validate spec.yaml (#20398)
* Stop relying on manifest.json to validate spec.yaml * add changelog * adjust tests * Update datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/models.py Co-authored-by: NouemanKHAL <noueman.khalikine@datadoghq.com> * fix import and whitespace --------- Co-authored-by: NouemanKHAL <noueman.khalikine@datadoghq.com>
1 parent 1c92482 commit baeffa3

File tree

5 files changed

+18
-163
lines changed

5 files changed

+18
-163
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stop relying on manifest.json to validate spec.yaml. Also stop checking the 'name' field in spec.yaml.

datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from ...config_validator.validator_errors import SEVERITY_ERROR, SEVERITY_WARNING
1313
from ...configuration import ConfigSpec
1414
from ...configuration.consumers import ExampleConsumer
15+
from ...constants import get_root
1516
from ...manifest_utils import Manifest
1617
from ...testing import process_checks_option
1718
from ...utils import complete_valid_checks, get_config_files, get_data_directory, get_version_string
@@ -67,7 +68,7 @@ def config(ctx, check, sync, verbose):
6768
echo_debug(f"Skipping validation for check: {check}; can't process manifest")
6869
continue
6970

70-
spec_file_path = manifest.get_config_spec()
71+
spec_file_path = path_join(get_root(), check, 'assets', 'configuration', 'spec.yaml')
7172
if not file_exists(spec_file_path):
7273
example_location = get_data_directory(check)
7374

datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/models.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from ...configuration import ConfigSpec
1717
from ...configuration.consumers import ModelConsumer
1818
from ...constants import get_root
19-
from ...manifest_utils import Manifest
2019
from ...testing import process_checks_option
2120
from ...utils import (
2221
CUSTOM_FILES,
@@ -108,12 +107,9 @@ def models(ctx, check, sync, verbose):
108107
source = 'test'
109108
version = '0.0.1'
110109
else:
111-
manifest = Manifest.load_manifest(check)
112-
if not manifest:
113-
echo_debug(f"Skipping validation for check: {check}; can't process manifest")
114-
continue
115-
spec_path = manifest.get_config_spec()
110+
spec_path = path_join(root, check, 'assets', 'configuration', 'spec.yaml')
116111
if not file_exists(spec_path):
112+
echo_debug(f"Skipping validation for check: {check}; 'spec.yaml' file doesn't exist")
117113
continue
118114

119115
source = check

datadog_checks_dev/datadog_checks/dev/tooling/configuration/spec.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ def spec_validator(spec: dict, loader) -> None:
1010
loader.errors.append(f'{loader.source}: Configuration specifications must be a mapping object')
1111
return
1212

13-
if 'name' not in spec:
14-
loader.errors.append(f'{loader.source}: Configuration specifications must contain a top-level `name` attribute')
15-
return
16-
17-
name = spec['name']
18-
if not isinstance(name, str):
19-
loader.errors.append(f'{loader.source}: The top-level `name` attribute must be a string')
20-
return
21-
2213
release_version = spec.setdefault('version', loader.version)
2314
if not release_version:
2415
loader.errors.append(

0 commit comments

Comments
 (0)