From dc723084fd8e429fdb5b87abd8f22ad27db901c0 Mon Sep 17 00:00:00 2001 From: Nicholas Muesch Date: Fri, 6 Dec 2024 16:32:46 -0500 Subject: [PATCH] Remove manifest validation call that calls deprecated endpoint (#19208) * Remove manifest validation call that calls deprecated endpoint * Add changelog entry * Remove associated tests --- ddev/changelog.d/19208.removed | 1 + ddev/src/ddev/cli/validate/__init__.py | 2 - ddev/src/ddev/cli/validate/manifest.py | 49 ------------ ddev/tests/cli/validate/test_manifest.py | 97 ------------------------ 4 files changed, 1 insertion(+), 148 deletions(-) create mode 100644 ddev/changelog.d/19208.removed delete mode 100644 ddev/src/ddev/cli/validate/manifest.py delete mode 100644 ddev/tests/cli/validate/test_manifest.py diff --git a/ddev/changelog.d/19208.removed b/ddev/changelog.d/19208.removed new file mode 100644 index 0000000000000..18049160fec2f --- /dev/null +++ b/ddev/changelog.d/19208.removed @@ -0,0 +1 @@ +Remove manifest validation call that calls deprecated endpoint diff --git a/ddev/src/ddev/cli/validate/__init__.py b/ddev/src/ddev/cli/validate/__init__.py index 95b2afaa0f721..5865a9ba66c7b 100644 --- a/ddev/src/ddev/cli/validate/__init__.py +++ b/ddev/src/ddev/cli/validate/__init__.py @@ -25,7 +25,6 @@ from ddev.cli.validate.http import http from ddev.cli.validate.labeler import labeler from ddev.cli.validate.licenses import licenses -from ddev.cli.validate.manifest import manifest from ddev.cli.validate.metadata import metadata from ddev.cli.validate.openmetrics import openmetrics from ddev.cli.validate.version import version @@ -54,7 +53,6 @@ def validate(): validate.add_command(legacy_signature) validate.add_command(license_headers) validate.add_command(licenses) -validate.add_command(manifest) validate.add_command(metadata) validate.add_command(models) validate.add_command(openmetrics) diff --git a/ddev/src/ddev/cli/validate/manifest.py b/ddev/src/ddev/cli/validate/manifest.py deleted file mode 100644 index cf8acdae216dc..0000000000000 --- a/ddev/src/ddev/cli/validate/manifest.py +++ /dev/null @@ -1,49 +0,0 @@ -# (C) Datadog, Inc. 2022-present -# All rights reserved -# Licensed under a 3-clause BSD style license (see LICENSE) -from __future__ import annotations - -from typing import TYPE_CHECKING - -import click - -if TYPE_CHECKING: - from ddev.cli.application import Application - - -@click.command(short_help='Validate integration manifests') -@click.argument('integrations', nargs=-1) -@click.pass_context -def manifest(ctx: click.Context, integrations: tuple[str, ...]): - """Validate integration manifests.""" - import httpx - - app: Application = ctx.obj - validation_tracker = app.create_validation_tracker('Manifests') - - dd_url = app.config.org.config.get('dd_url', '') - if not dd_url: - app.abort(f'No `dd_url` has been set for org `{app.config.org.name}`') - - validation_endpoint = f'{dd_url}/api/beta/apps/manifest/validate' - - for integration in app.repo.integrations.iter(integrations): - payload = {'data': {'type': 'app_manifest', 'attributes': integration.manifest.get('')}} - - try: - response = httpx.post(validation_endpoint, json=payload) - - if response.status_code == 400: - for error in response.json()['errors']: - validation_tracker.error((integration.display_name, 'manifest.json'), message=error) - else: - response.raise_for_status() - validation_tracker.success() - except Exception as e: - validation_tracker.error((integration.display_name, 'manifest.json'), message=str(e)) - - if validation_tracker.errors: - validation_tracker.display() - app.abort() - - validation_tracker.display() diff --git a/ddev/tests/cli/validate/test_manifest.py b/ddev/tests/cli/validate/test_manifest.py deleted file mode 100644 index 5f5eb2084bc36..0000000000000 --- a/ddev/tests/cli/validate/test_manifest.py +++ /dev/null @@ -1,97 +0,0 @@ -# (C) Datadog, Inc. 2022-present -# All rights reserved -# Licensed under a 3-clause BSD style license (see LICENSE) -import json - -import pytest - -from ddev.utils.structures import EnvVars - - -@pytest.fixture(scope='module', autouse=True) -def terminal_width(): - with EnvVars({'COLUMNS': '200'}): - yield - - -def test_no_dd_url(ddev, helpers, config_file): - config_file.model.orgs['default']['dd_url'] = '' - config_file.save() - - result = ddev('validate', 'manifest', 'disk') - - assert result.exit_code == 1, result.output - assert result.output == helpers.dedent( - """ - No `dd_url` has been set for org `default` - """ - ) - - -def test_error_single_integration(ddev, repository, helpers, network_replay): - network_replay('manifest/missing_app_uuid.yaml', record_mode='none') - - check = 'mongo' - manifest_file = repository.path / check / 'manifest.json' - manifest = json.loads(manifest_file.read_text()) - del manifest['app_uuid'] - manifest_file.write_text(json.dumps(manifest)) - - result = ddev('validate', 'manifest', check) - - assert result.exit_code == 1, result.output - assert helpers.remove_trailing_spaces(result.output) == helpers.dedent( - """ - Manifests - └── MongoDB - └── manifest.json - - API input validation failed: {'app_uuid': [u'Missing data for required field.']} - - Errors: 1 - """ - ) - - -def test_error_multiple_integrations(ddev, repository, helpers, network_replay): - network_replay('manifest/missing_app_uuid.yaml', record_mode='none') - - for check in ('mongo', 'vsphere'): - manifest_file = repository.path / check / 'manifest.json' - manifest = json.loads(manifest_file.read_text()) - del manifest['app_uuid'] - manifest_file.write_text(json.dumps(manifest)) - - result = ddev('validate', 'manifest') - - assert result.exit_code == 1, result.output - assert helpers.remove_trailing_spaces(result.output) == helpers.dedent( - """ - Manifests - ├── MongoDB - │ └── manifest.json - │ - │ API input validation failed: {'app_uuid': [u'Missing data for required field.']} - └── vSphere - └── manifest.json - - API input validation failed: {'app_uuid': [u'Missing data for required field.']} - - Errors: 2 - """ - ) - - -def test_passing(ddev, helpers, network_replay): - network_replay('manifest/success.yaml', record_mode='none') - - result = ddev('validate', 'manifest', 'postgres') - - assert result.exit_code == 0, result.output - assert helpers.remove_trailing_spaces(result.output) == helpers.dedent( - """ - Manifests - - Passed: 1 - """ - )