Mirror of https://github.com/roostorg/osprey github.com/roostorg/osprey
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: remove unused webhook config (#71)

authored by

Elijah Seed-Arita and committed by
GitHub
0af44034 f9920283

-71
-24
osprey_worker/src/osprey/engine/stdlib/configs/tests/test_webhook_config.py
··· 1 - import pytest 2 - from osprey.engine.stdlib.configs.webhook_config import ( 3 - WebhookConfig, 4 - ) 5 - 6 - 7 - def test_outgoing_labels_features_to_include_golden_path() -> None: 8 - WebhookConfig.parse_obj( 9 - { 10 - 'outgoing_labels': {'some_label': 'url://'}, 11 - 'outgoing_labels_features_to_include': {'some_label': ['SomeFeature']}, 12 - }, 13 - ) 14 - 15 - 16 - def test_outgoing_labels_features_to_include_error() -> None: 17 - with pytest.raises(ValueError) as e: 18 - WebhookConfig.parse_obj( 19 - { 20 - 'outgoing_labels': {'some_label': 'url://'}, 21 - 'outgoing_labels_features_to_include': {'some_label_that_doesnt_exist': ['SomeFeature']}, 22 - }, 23 - ) 24 - assert e.match('`some_label_that_doesnt_exist` is not defined in the `outgoing_labels` webhook config')
-47
osprey_worker/src/osprey/engine/stdlib/configs/webhook_config.py
··· 1 - from typing import Any, Dict, List, Mapping, Optional, Set, Union 2 - 3 - from pydantic import HttpUrl, validator 4 - from pydantic.main import BaseModel 5 - 6 - from .._registry import register_config_subkey 7 - 8 - 9 - class BulkLabelWebhookConfig(BaseModel): 10 - """Config related to bulk label notifications.""" 11 - 12 - osprey_webhook_url: Optional[HttpUrl] = None 13 - min_bulk_size: int = 100 14 - """The minimum size of a bulk label to notify for.""" 15 - 16 - 17 - # TODO: OutgoingLabelsConfig should live outside of osprey_stdlib 18 - # webhooks and are not open-sourceable. 19 - class OutgoingLabelsConfig(BaseModel): 20 - url: Union[str, List[str]] = '' 21 - message_content: str = '' 22 - 23 - 24 - @register_config_subkey('webhooks') 25 - class WebhookConfig(BaseModel): 26 - osprey_webhooks_url: str = '' 27 - outgoing_labels: Dict[str, Union[str, List[str], OutgoingLabelsConfig]] = {} 28 - """ 29 - This target receives a POST request when the label changes on a given entity. 30 - This can be an `https://` endpoint. 31 - """ 32 - 33 - outgoing_labels_features_to_include: Mapping[str, Set[str]] = {} 34 - bulk_label: BulkLabelWebhookConfig = BulkLabelWebhookConfig() 35 - 36 - @validator('outgoing_labels_features_to_include', pre=False) 37 - def validate_outgoing_labels_features_to_include( 38 - cls, outgoing_labels_features_to_include: Mapping[str, Set[str]], values: Mapping[str, Any] 39 - ) -> Mapping[str, Set[str]]: 40 - outgoing_labels = values.get('outgoing_labels', {}) 41 - outgoing_labels_set = set(outgoing_labels.keys()) 42 - 43 - for label_name in outgoing_labels_features_to_include.keys(): 44 - if label_name not in outgoing_labels_set: 45 - raise ValueError(f'`{label_name}` is not defined in the `outgoing_labels` webhook config') 46 - 47 - return outgoing_labels_features_to_include