Skip to content

Commit

Permalink
Spinnaker Data Models Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
yogesh-s-modak committed Nov 26, 2024
1 parent 1cd918d commit d318b3e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# ddev -x validate config -s <INTEGRATION_NAME>
# ddev -x validate models -s <INTEGRATION_NAME>


from .instance import InstanceConfig
from .shared import SharedConfig

Expand Down
4 changes: 4 additions & 0 deletions spinnaker/datadog_checks/spinnaker/config_models/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
# ddev -x validate models -s <INTEGRATION_NAME>


def instance_disable_generic_tags():
return False


def instance_empty_default_hostname():
return False

Expand Down
12 changes: 11 additions & 1 deletion spinnaker/datadog_checks/spinnaker/config_models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# ddev -x validate config -s <INTEGRATION_NAME>
# ddev -x validate models -s <INTEGRATION_NAME>


from __future__ import annotations

from typing import Optional
Expand All @@ -20,13 +19,24 @@
from . import defaults, validators


class MetricPatterns(BaseModel):
model_config = ConfigDict(
arbitrary_types_allowed=True,
frozen=True,
)
exclude: Optional[tuple[str, ...]] = None
include: Optional[tuple[str, ...]] = None


class InstanceConfig(BaseModel):
model_config = ConfigDict(
validate_default=True,
arbitrary_types_allowed=True,
frozen=True,
)
disable_generic_tags: Optional[bool] = None
empty_default_hostname: Optional[bool] = None
metric_patterns: Optional[MetricPatterns] = None
min_collection_interval: Optional[float] = None
service: Optional[str] = None
tags: Optional[tuple[str, ...]] = None
Expand Down
5 changes: 1 addition & 4 deletions spinnaker/datadog_checks/spinnaker/config_models/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# ddev -x validate config -s <INTEGRATION_NAME>
# ddev -x validate models -s <INTEGRATION_NAME>


from __future__ import annotations

from typing import Optional
Expand All @@ -17,7 +16,7 @@
from datadog_checks.base.utils.functions import identity
from datadog_checks.base.utils.models import validation

from . import defaults, validators
from . import validators


class SharedConfig(BaseModel):
Expand All @@ -38,8 +37,6 @@ def _validate(cls, value, info):
field_name = field.alias or info.field_name
if field_name in info.context['configured_fields']:
value = getattr(validators, f'shared_{info.field_name}', identity)(value, field=field)
else:
value = getattr(defaults, f'shared_{info.field_name}', lambda: value)()

return validation.utils.make_immutable(value)

Expand Down
10 changes: 10 additions & 0 deletions spinnaker/datadog_checks/spinnaker/config_models/validators.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# (C) Datadog, Inc. 2024-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)

# Here you can include additional config validators or transformers
#
# def initialize_instance(values, **kwargs):
# if 'my_option' not in values and 'my_legacy_option' in values:
# values['my_option'] = values['my_legacy_option']
# if values.get('my_number') > 10:
# raise ValueError('my_number max value is 10, got %s' % str(values.get('my_number')))
#
# return values

0 comments on commit d318b3e

Please sign in to comment.