Skip to content

Commit 3d8b647

Browse files
committed
Update platform URL
1 parent d39a9f5 commit 3d8b647

File tree

6 files changed

+32
-8
lines changed

6 files changed

+32
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ dreadnode login
103103
Authenticate to a specific server:
104104

105105
```bash
106-
dreadnode login --server https://dev-crucible.dreadnode.io
106+
dreadnode login --server https://local-platform.dreadnode.io
107107
```
108108

109109
Manage server profiles with:

dreadnode_cli/agent/tests/test_docker.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,16 @@ def test_get_registry() -> None:
124124
config = _create_test_server_config("https://staging-crucible.dreadnode.io")
125125
assert docker.get_registry(config) == "staging-registry.dreadnode.io"
126126

127+
config = _create_test_server_config("https://staging-platform.dreadnode.io")
128+
assert docker.get_registry(config) == "staging-registry.dreadnode.io"
129+
127130
# Test dev registry
128131
config = _create_test_server_config("https://dev-crucible.dreadnode.io")
129132
assert docker.get_registry(config) == "dev-registry.dreadnode.io"
130133

134+
config = _create_test_server_config("https://dev-platform.dreadnode.io")
135+
assert docker.get_registry(config) == "dev-registry.dreadnode.io"
136+
131137
# Test localhost registry
132138
config = _create_test_server_config("http://localhost:8000")
133139
assert docker.get_registry(config) == "localhost:5005"

dreadnode_cli/config.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ def _update_active(self) -> None:
2828
if self.active not in self.servers:
2929
self.active = next(iter(self.servers)) if self.servers else None
3030

31+
def _update_urls(self) -> bool:
32+
updated = False
33+
for search, replace in {
34+
"//staging-crucible.dreadnode.io": "//staging-platform.dreadnode.io",
35+
"//dev-crucible.dreadnode.io": "//dev-platform.dreadnode.io",
36+
"//crucible.dreadnode.io": "//platform.dreadnode.io",
37+
}.items():
38+
for server in self.servers.values():
39+
if search in server.url:
40+
server.url = server.url.replace(search, replace)
41+
updated = True
42+
return updated
43+
3144
@classmethod
3245
def read(cls) -> "UserConfig":
3346
"""Read the user configuration from the file system or return an empty instance."""
@@ -36,7 +49,12 @@ def read(cls) -> "UserConfig":
3649
return cls()
3750

3851
with USER_CONFIG_PATH.open("r") as f:
39-
return cls.model_validate(YAML().load(f))
52+
self = cls.model_validate(YAML().load(f))
53+
54+
if self._update_urls():
55+
self.write()
56+
57+
return self
4058

4159
def write(self) -> None:
4260
"""Write the user configuration to the file system."""

dreadnode_cli/defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# default platform domain
1212
PLATFORM_BASE_DOMAIN = "dreadnode.io"
1313
# default server URL
14-
PLATFORM_BASE_URL = os.getenv("DREADNODE_SERVER", f"https://crucible.{PLATFORM_BASE_DOMAIN}")
14+
PLATFORM_BASE_URL = os.getenv("DREADNODE_SERVER", f"https://platform.{PLATFORM_BASE_DOMAIN}")
1515
# default docker registry subdomain
1616
DOCKER_REGISTRY_SUBDOMAIN = "registry"
1717
# default docker registry local port

dreadnode_cli/tests/test_api_create_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def _create_test_config(monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path,
2626
# Create test config
2727
config = UserConfig()
2828
server_config = ServerConfig(
29-
url="https://crucible.dreadnode.io",
29+
url="https://platform.dreadnode.io",
3030
3131
username="test",
3232
api_key="test123",
@@ -53,7 +53,7 @@ def test_create_client_with_valid_token(monkeypatch: pytest.MonkeyPatch, tmp_pat
5353

5454
client = api.create_client()
5555

56-
assert client._base_url == "https://crucible.dreadnode.io"
56+
assert client._base_url == "https://platform.dreadnode.io"
5757
assert client._client.cookies["access_token"] == token
5858
assert client._client.cookies["refresh_token"] == token
5959

dreadnode_cli/tests/test_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
def test_server_config() -> None:
1212
# Test valid server config
1313
config = ServerConfig(
14-
url="https://crucible.dreadnode.io",
14+
url="https://platform.dreadnode.io",
1515
1616
username="test",
1717
api_key="test123",
1818
access_token="token123",
1919
refresh_token="refresh123",
2020
)
21-
assert config.url == "https://crucible.dreadnode.io"
21+
assert config.url == "https://platform.dreadnode.io"
2222
assert config.email == "[email protected]"
2323
assert config.username == "test"
2424
assert config.api_key == "test123"
@@ -42,7 +42,7 @@ def test_user_config(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
4242

4343
# Test adding server config
4444
server_config = ServerConfig(
45-
url="https://crucible.dreadnode.io",
45+
url="https://platform.dreadnode.io",
4646
4747
username="test",
4848
api_key="test123",

0 commit comments

Comments
 (0)