Skip to content

Commit 07adbbe

Browse files
committed
Modify enum values to avoid having a second mapping
1 parent 1894ec9 commit 07adbbe

File tree

5 files changed

+11
-18
lines changed

5 files changed

+11
-18
lines changed

datadog_checks_dev/datadog_checks/dev/tooling/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
'-x': 'here',
2828
}
2929

30+
# If we add or remove a new repo choice, make sure to keep the
31+
# enum in ddev/src/ddev/utils/metadata.py in sync.
3032
REPO_CHOICES = {
3133
'core': 'integrations-core',
3234
'extras': 'integrations-extras',

ddev/src/ddev/cli/config/override.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,11 @@ def repo_to_override(app: Application) -> str:
2020
pyproject_metadata,
2121
)
2222

23-
repos_map = {
24-
ValidRepo.CORE: "core",
25-
ValidRepo.EXTRAS: "extras",
26-
ValidRepo.INTERNAL: "internal",
27-
ValidRepo.AGENT: "agent",
28-
ValidRepo.MARKETPLACE: "marketplace",
29-
ValidRepo.INTEGRATIONS_INTERNAL_CORE: "integrations-internal-core",
30-
}
31-
3223
try:
3324
metadata = pyproject_metadata()
3425
if metadata is None:
3526
raise RepoNotFoundError()
36-
repo = repos_map[metadata.repo]
27+
repo = metadata.repo.value
3728
except (PyProjectNotFoundError, RepoNotFoundError):
3829
app.display_error(
3930
"The current repo could not be inferred. Either this is not a repository or the root of "
@@ -42,7 +33,7 @@ def repo_to_override(app: Application) -> str:
4233

4334
repo = app.prompt(
4435
"What repo are you trying to override? ",
45-
type=click.Choice(list(repos_map.values())),
36+
type=click.Choice([item.value for item in ValidRepo]),
4637
show_choices=True,
4738
)
4839
except InvalidMetadataError as e:

ddev/src/ddev/utils/metadata.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111

1212
class ValidRepo(Enum):
13-
CORE = "integrations-core"
14-
EXTRAS = "integrations-extras"
15-
INTERNAL = "integrations-internal"
16-
AGENT = "datadog-agent"
13+
CORE = "core"
14+
EXTRAS = "extras"
15+
INTERNAL = "internal"
16+
AGENT = "agent"
1717
MARKETPLACE = "marketplace"
1818
INTEGRATIONS_INTERNAL_CORE = "integrations-internal-core"
1919

ddev/tests/cli/config/test_override.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
def repo_with_ddev_tool_config(repository_as_cwd: ClonedRepo) -> Generator[ClonedRepo, None, None]:
1717
pyproject_path = repository_as_cwd.path / "pyproject.toml"
1818
pyproject = load_toml_file(pyproject_path)
19-
pyproject["tool"]["ddev"] = {"repo": "integrations-core"}
19+
pyproject["tool"]["ddev"] = {"repo": "core"}
2020
dump_toml_data(pyproject, pyproject_path)
2121

2222
yield repository_as_cwd
@@ -162,4 +162,4 @@ def test_misconfigured_pyproject_fails(
162162
result = ddev("config", "override")
163163
assert result.exit_code == 1
164164
assert "Invalid ddev metadata found in pyproject.toml" in result.output
165-
assert "[tool.ddev.repo] is 'wrong-repo': Input should be 'integrations-core'" in result.output
165+
assert "[tool.ddev.repo] is 'wrong-repo': Input should be 'core'" in result.output

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ ban-relative-imports = "all"
110110
"tests/models/config_models/deprecations.py" = ["E501"]
111111

112112
[tool.ddev]
113-
repo = "integrations-core"
113+
repo = "core"
114114

115115
[project]
116116
name = "integrations-core"

0 commit comments

Comments
 (0)