Skip to content

Conversation

mgarabed
Copy link
Member

What does this PR do?

Adds support for validating Manifest v2 files.

For v2, we have the actual schema validation taking place on the Datadog app side via a new endpoint that's been created. This runs through a JSONSchema serializer, then applies basic validations against the payload. Since we will also be doing this validation within the app, it seemed like a better choice to avoid the schema duplication across different repos and projects with the risk of things getting out of sync.

Motivation

Add support for new manifest versions.

Additional Notes

A valid API and APP key will need to be added to the ddev config when validating the new manifests.

Tests continue to pass for v1, but additional tests are needed for v2.

To test manually, create a folder named testmanifest and add the following file:

manifest.json
{
    "app_id": "datadog-oracle",
    "assets": {
        "dashboards": {
            "oracle": "https://app.datadoghq.com/screen/integration/240/oracle-database---overview"
        },
        "integration": {
            "configuration": {
                "spec": "assets/configuration/spec.yaml"
            },
            "events": {
                "creates_events": true
            },
            "id": "testmanifest",
            "metrics": {
                "auto_install": true,
                "check": "oracle.session_count",
                "metadata_path": "metrics_metadata.csv",
                "prefix": "oracle."
            },
            "service_checks": {
                "metadata_path": "assets/service_checks.json"
            },
            "source_type_name": "Oracle Database"
        },
        "ui extension": {}
    },
    "author": {
        "homepage": "https://www.datadoghq.com",
        "name": "Datadog",
        "sales_email": "help@datadoghq.com",
        "support_email": "help@datadoghq.com"
    },
    "display_on_public_website": true,
    "legal_terms": {},
    "manifest_version": "2.0.0",
    "oauth": {},
    "pricing": [
        {
            "billing_type": "free"
        }
    ],
    "tile": {
        "changelog": "CHANGELOG.md",
        "classifier_tags": [
            "Category::Marketplace",
            "Category::Cloud",
            "Supported OS::Windows",
            "Supported OS::Mac OS",
            "Offering::Integration",
            "Offering::UI Extension"
        ],
        "configuration": "README.md#Setup",
        "description": "Oracle relational database system designed for enterprise grid computing",
        "media": [],
        "overview": "README.md#Overview",
        "title": "Oracle"
    }
}

To test the server side validation, try changing the classifier tag Offering::UI Extension to Offering::UI-Extension or some nonsense name.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have changelog/ and integration/ labels attached

@mgarabed mgarabed requested a review from a team as a code owner August 24, 2021 13:21
@mgarabed mgarabed requested a review from nmuesch August 24, 2021 13:22
@mgarabed mgarabed force-pushed the mg/manifest-v2-validation branch from 9d75b63 to 3c576ab Compare August 24, 2021 13:36
@codecov
Copy link

codecov bot commented Aug 24, 2021

Codecov Report

Merging #9968 (0f6021d) into master (7ae23bb) will decrease coverage by 0.05%.
The diff coverage is 45.19%.

Flag Coverage Δ
datadog_checks_dev 78.73% <45.19%> (-0.69%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Contributor

@nmuesch nmuesch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!!! I left some inline questions/suggestions but nothing major.

Comment on lines +64 to +66
echo_info(f'Skipping validation {validator} since errors have already been found.')
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 on continuing to list all validations that would be skipped instead of quickly aborting.


FIELDS_NOT_ALLOWED_TO_CHANGE = {
"v1": ("integration_id", "display_name", "guid"),
"v2": ("id", "source_type_name", "app_id"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these v2 versions need to be assets/integration/id, ``assets/integration/source_type_name, and app_id`

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content_changed function below just returns git blocks which are what are being tested - so we wouldn't be able to fully trace a path like assets/integration/id. It does mean we could end up catching other id fields in this case though ..

@mgarabed mgarabed requested review from ofek and nmuesch September 3, 2021 15:42
nmuesch
nmuesch previously approved these changes Sep 3, 2021
Copy link
Contributor

@nmuesch nmuesch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this LGTM

Copy link
Contributor

@ofek ofek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@@ -89,3 +89,52 @@ def __exit__(self, exc_type, exc_value, traceback):
self._cleanup(self.directory)
else:
self._cleanup(self.directory)


class JSONDict(dict):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this under tooling/ instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, and since we are under that tooling dir, added back the jsonpointer dependency to the cli extras 😝

Copy link
Contributor

@ofek ofek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this under tooling/ instead
Done, and since we are under that tooling dir, added back the jsonpointer dependency to the cli extras 😝

Oh wait, can we still not do that? It's quite unnecessary

@mgarabed mgarabed merged commit bacc2e1 into master Sep 8, 2021
@mgarabed mgarabed deleted the mg/manifest-v2-validation branch September 8, 2021 17:21
@ChristineTChen ChristineTChen changed the title Add support for manifest v2 validations Add support for manifest V2 validations Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants