Skip to content

Commit

Permalink
Add a validator for the manifest version
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentClarret committed Aug 24, 2022
1 parent 2846ea4 commit 333b44f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
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, V2, V2_STRING, V1_STRING


class ValidationResult(object):
Expand Down Expand Up @@ -311,3 +311,10 @@ 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')

0 comments on commit 333b44f

Please sign in to comment.