Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a validator for the manifest version #12788

Merged
merged 2 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ...constants import get_root
from ...datastructures import JSONDict
from ...manifest_validator import get_all_validators
from ...manifest_validator.constants import V1_STRING, V2_STRING
from ...manifest_validator.constants import V2_STRING
from ...testing import process_checks_option
from ...utils import complete_valid_checks
from ..console import (
Expand Down Expand Up @@ -75,10 +75,6 @@ def manifest(ctx, check, fix):
continue

version = decoded.get('manifest_version', V2_STRING)
if version == V1_STRING:
file_failures += 1
display_queue.append((echo_failure, 'Manifest version must be >= 2.0.0'))

all_validators = get_all_validators(ctx, version, is_extras, is_marketplace)

for validator in all_validators:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# (C) Datadog, Inc. 2021-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from .common.validator import VersionValidator
from .constants import V2_STRING
from .v2.validator import get_v2_validators


def get_all_validators(ctx, version_string, is_extras=False, is_marketplace=False):
return get_v2_validators(ctx, is_extras, is_marketplace)
validators = [VersionValidator()]

if version_string == V2_STRING:
validators.extend(get_v2_validators(ctx, is_extras, is_marketplace))

return validators
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ...datastructures import JSONDict
from ...git import git_show_file
from ...utils import get_metadata_file, has_logs, is_metric_in_metadata_file, read_metadata_rows
from ..constants import V1, V2
from ..constants import V1, V1_STRING, V2, V2_STRING


class ValidationResult(object):
Expand Down Expand Up @@ -311,3 +311,9 @@ def validate(self, check_name, decoded, fix):
+ ' or define the logs properly'
)
self.fail(output)


class VersionValidator(BaseManifestValidator):
def validate(self, check_name, decoded, fix):
if decoded.get('manifest_version', V2_STRING) == V1_STRING:
self.fail('Manifest version must be >= 2.0.0')