Skip to content

Commit eb95ee2

Browse files
committed
Fix metadata.csv integration name behavior with overrides
1 parent 3458c29 commit eb95ee2

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed

.ddev/config.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,15 @@ unsorted = [
156156
'otel',
157157
]
158158

159+
# Use this to validate the name of the integration that must appear in each row of the metadata.csv file
160+
# This integrations for historical reasons do not have a name in metadata that aligns with their
161+
# display name.
162+
[overrides.validate.metadata.integration]
163+
ecs_fargate = "amazon_fargate"
164+
kube_scheduler = "kube_scheduler"
165+
nginx_ingress_controller = "nginx_ingress_controller"
166+
167+
159168
[overrides.dep.updates]
160169
exclude = [
161170
'pyasn1', # https://github.com/pyasn1/pyasn1/issues/52

ddev/changelog.d/21696.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add a way for historical snowflake to overide their integration name for the metadata file

ddev/src/ddev/cli/validate/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def metadata(app: Application, integrations: tuple[str, ...], check_duplicates:
210210

211211
# integration header
212212
integration = row['integration']
213-
normalized_integration = current_check.normalized_display_name
213+
normalized_integration = current_check.metadata_integration_name
214214
if integration != normalized_integration and normalized_integration not in excluded:
215215
errors = True
216216

ddev/src/ddev/integration/core.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ def normalized_display_name(self) -> str:
100100
normalized_integration = normalized_integration.strip("_")
101101
return normalized_integration.lower()
102102

103+
@cached_property
104+
def metadata_integration_name(self) -> str:
105+
if name := cast(str, self.repo_config.get(f'/overrides/validate/metadata/integration/{self.name}', None)):
106+
return name
107+
108+
return self.normalized_display_name
109+
103110
@cached_property
104111
def project_file(self) -> Path:
105112
return self.path / 'pyproject.toml'

ddev/tests/cli/validate/test_metrics.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,41 @@ def test_integration_header(ddev, repository, helpers):
322322
)
323323

324324

325+
def test_integration_header_with_override(ddev, repository, helpers):
326+
helpers.write_file(
327+
repository.path / 'apache',
328+
'metadata.csv',
329+
helpers.dedent(
330+
"""
331+
metric_name,metric_type,interval,unit_name,per_unit_name,description,orientation,integration,short_name,curated_metric
332+
apache.conns_total,gauge,,connection,,The number of connections.,0,apache___,,
333+
"""
334+
),
335+
)
336+
337+
helpers.write_file(
338+
repository.path / ".ddev",
339+
"config.toml",
340+
helpers.dedent(
341+
"""
342+
[overrides.validate.metadata.integration]
343+
apache = "apache___"
344+
"""
345+
),
346+
)
347+
348+
result = ddev("validate", "metadata", 'apache')
349+
350+
assert result.exit_code == 0, result.output
351+
assert helpers.remove_trailing_spaces(result.output) == helpers.dedent(
352+
"""
353+
Metrics validation
354+
355+
Passed: 1
356+
"""
357+
)
358+
359+
325360
def test_invalid_orientation(ddev, repository, helpers):
326361
metrics_file = repository.path / 'apache' / 'metadata.csv'
327362
outfile = os.path.join('apache', 'metadata.csv')

0 commit comments

Comments
 (0)