mirror of
https://github.com/trailofbits/dropkit
synced 2026-06-21 14:11:54 +00:00
Update default Ubuntu image to 25.10 and extract slug constants (#48)
* Update default Ubuntu image from 25.04 to 25.10 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Extract default region/size/image slugs into constants Replace duplicated hardcoded strings across config.py, main.py, and tests with DEFAULT_REGION, DEFAULT_SIZE, and DEFAULT_IMAGE constants defined in config.py. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
eba4cfcfa3
commit
212306c568
+1
-1
@@ -329,7 +329,7 @@ class DigitalOceanAPI:
|
||||
name: Droplet name
|
||||
region: Region slug (e.g., 'nyc3')
|
||||
size: Size slug (e.g., 's-2vcpu-4gb')
|
||||
image: Image slug (e.g., 'ubuntu-25-04-x64')
|
||||
image: Image slug (e.g., 'ubuntu-25-10-x64')
|
||||
user_data: Cloud-init user data
|
||||
tags: List of tags to apply
|
||||
ssh_keys: List of SSH key IDs for root access (optional)
|
||||
|
||||
+8
-3
@@ -9,6 +9,11 @@ import yaml
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
|
||||
# Default slugs for droplet creation
|
||||
DEFAULT_REGION = "nyc3"
|
||||
DEFAULT_SIZE = "s-2vcpu-4gb"
|
||||
DEFAULT_IMAGE = "ubuntu-25-10-x64"
|
||||
|
||||
|
||||
class DigitalOceanConfig(BaseModel):
|
||||
"""DigitalOcean API configuration."""
|
||||
@@ -296,9 +301,9 @@ class Config:
|
||||
self,
|
||||
token: str,
|
||||
username: str, # noqa: ARG002 - kept for API compatibility, username derived from DO API
|
||||
region: str = "nyc3",
|
||||
size: str = "s-2vcpu-4gb",
|
||||
image: str = "ubuntu-25-04-x64",
|
||||
region: str = DEFAULT_REGION,
|
||||
size: str = DEFAULT_SIZE,
|
||||
image: str = DEFAULT_IMAGE,
|
||||
ssh_keys: list[str] | None = None,
|
||||
ssh_key_ids: list[int] | None = None,
|
||||
extra_tags: list[str] | None = None,
|
||||
|
||||
+7
-7
@@ -18,7 +18,7 @@ from rich.table import Table
|
||||
|
||||
from dropkit.api import DigitalOceanAPI, DigitalOceanAPIError
|
||||
from dropkit.cloudinit import render_cloud_init
|
||||
from dropkit.config import Config, DropkitConfig
|
||||
from dropkit.config import DEFAULT_IMAGE, DEFAULT_REGION, DEFAULT_SIZE, Config, DropkitConfig
|
||||
from dropkit.lock import requires_lock
|
||||
from dropkit.ssh_config import (
|
||||
add_ssh_host,
|
||||
@@ -1686,42 +1686,42 @@ def init(
|
||||
if regions:
|
||||
region = prompt_with_help(
|
||||
"Default region",
|
||||
default="nyc3",
|
||||
default=DEFAULT_REGION,
|
||||
display_func=display_regions,
|
||||
data=regions,
|
||||
)
|
||||
else:
|
||||
region = Prompt.ask(
|
||||
"[cyan]Default region[/cyan]",
|
||||
default="nyc3",
|
||||
default=DEFAULT_REGION,
|
||||
)
|
||||
|
||||
# Prompt for default size
|
||||
if sizes:
|
||||
size = prompt_with_help(
|
||||
"Default droplet size",
|
||||
default="s-2vcpu-4gb",
|
||||
default=DEFAULT_SIZE,
|
||||
display_func=display_sizes,
|
||||
data=sizes,
|
||||
)
|
||||
else:
|
||||
size = Prompt.ask(
|
||||
"[cyan]Default droplet size[/cyan]",
|
||||
default="s-2vcpu-4gb",
|
||||
default=DEFAULT_SIZE,
|
||||
)
|
||||
|
||||
# Prompt for default image
|
||||
if images:
|
||||
image = prompt_with_help(
|
||||
"Default image",
|
||||
default="ubuntu-25-04-x64",
|
||||
default=DEFAULT_IMAGE,
|
||||
display_func=display_images,
|
||||
data=images,
|
||||
)
|
||||
else:
|
||||
image = Prompt.ask(
|
||||
"[cyan]Default image[/cyan]",
|
||||
default="ubuntu-25-04-x64",
|
||||
default=DEFAULT_IMAGE,
|
||||
)
|
||||
|
||||
# Prompt for extra tags
|
||||
|
||||
+30
-27
@@ -6,6 +6,9 @@ import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from dropkit.config import (
|
||||
DEFAULT_IMAGE,
|
||||
DEFAULT_REGION,
|
||||
DEFAULT_SIZE,
|
||||
CloudInitConfig,
|
||||
Config,
|
||||
DefaultsConfig,
|
||||
@@ -32,9 +35,9 @@ def valid_config_dict():
|
||||
"api_base": "https://api.digitalocean.com/v2",
|
||||
},
|
||||
"defaults": {
|
||||
"region": "nyc3",
|
||||
"size": "s-2vcpu-4gb",
|
||||
"image": "ubuntu-25-04-x64",
|
||||
"region": DEFAULT_REGION,
|
||||
"size": DEFAULT_SIZE,
|
||||
"image": DEFAULT_IMAGE,
|
||||
"extra_tags": ["custom-tag"],
|
||||
},
|
||||
"cloudinit": {
|
||||
@@ -96,14 +99,14 @@ class TestDefaultsConfig:
|
||||
def test_valid_config(self):
|
||||
"""Test valid defaults config."""
|
||||
config = DefaultsConfig(
|
||||
region="nyc3",
|
||||
size="s-2vcpu-4gb",
|
||||
image="ubuntu-25-04-x64",
|
||||
region=DEFAULT_REGION,
|
||||
size=DEFAULT_SIZE,
|
||||
image=DEFAULT_IMAGE,
|
||||
extra_tags=["tag1", "tag2"],
|
||||
)
|
||||
assert config.region == "nyc3"
|
||||
assert config.size == "s-2vcpu-4gb"
|
||||
assert config.image == "ubuntu-25-04-x64"
|
||||
assert config.region == DEFAULT_REGION
|
||||
assert config.size == DEFAULT_SIZE
|
||||
assert config.image == DEFAULT_IMAGE
|
||||
assert config.extra_tags == ["tag1", "tag2"]
|
||||
|
||||
def test_empty_region_fails(self):
|
||||
@@ -111,34 +114,34 @@ class TestDefaultsConfig:
|
||||
with pytest.raises(ValidationError):
|
||||
DefaultsConfig(
|
||||
region="",
|
||||
size="s-2vcpu-4gb",
|
||||
image="ubuntu-25-04-x64",
|
||||
size=DEFAULT_SIZE,
|
||||
image=DEFAULT_IMAGE,
|
||||
)
|
||||
|
||||
def test_empty_size_fails(self):
|
||||
"""Test that empty size fails validation."""
|
||||
with pytest.raises(ValidationError):
|
||||
DefaultsConfig(
|
||||
region="nyc3",
|
||||
region=DEFAULT_REGION,
|
||||
size="",
|
||||
image="ubuntu-25-04-x64",
|
||||
image=DEFAULT_IMAGE,
|
||||
)
|
||||
|
||||
def test_empty_image_fails(self):
|
||||
"""Test that empty image fails validation."""
|
||||
with pytest.raises(ValidationError):
|
||||
DefaultsConfig(
|
||||
region="nyc3",
|
||||
size="s-2vcpu-4gb",
|
||||
region=DEFAULT_REGION,
|
||||
size=DEFAULT_SIZE,
|
||||
image="",
|
||||
)
|
||||
|
||||
def test_empty_extra_tags_allowed(self):
|
||||
"""Test that empty extra_tags list is allowed."""
|
||||
config = DefaultsConfig(
|
||||
region="nyc3",
|
||||
size="s-2vcpu-4gb",
|
||||
image="ubuntu-25-04-x64",
|
||||
region=DEFAULT_REGION,
|
||||
size=DEFAULT_SIZE,
|
||||
image=DEFAULT_IMAGE,
|
||||
extra_tags=[],
|
||||
)
|
||||
assert config.extra_tags == []
|
||||
@@ -146,9 +149,9 @@ class TestDefaultsConfig:
|
||||
def test_missing_extra_tags_defaults_to_empty(self):
|
||||
"""Test that missing extra_tags defaults to empty list."""
|
||||
config = DefaultsConfig(
|
||||
region="nyc3",
|
||||
size="s-2vcpu-4gb",
|
||||
image="ubuntu-25-04-x64",
|
||||
region=DEFAULT_REGION,
|
||||
size=DEFAULT_SIZE,
|
||||
image=DEFAULT_IMAGE,
|
||||
)
|
||||
assert config.extra_tags == []
|
||||
|
||||
@@ -236,7 +239,7 @@ class TestDropkitConfig:
|
||||
"""Test valid full configuration."""
|
||||
config = DropkitConfig(**valid_config_dict)
|
||||
assert config.digitalocean.token == "dop_v1_test_token_12345"
|
||||
assert config.defaults.region == "nyc3"
|
||||
assert config.defaults.region == DEFAULT_REGION
|
||||
assert config.cloudinit.ssh_keys[0] == "/home/user/.ssh/id_ed25519.pub"
|
||||
assert config.ssh.auto_update is True
|
||||
|
||||
@@ -295,9 +298,9 @@ class TestConfigManager:
|
||||
config.create_default_config(
|
||||
token="test_token",
|
||||
username="testuser",
|
||||
region="nyc3",
|
||||
size="s-2vcpu-4gb",
|
||||
image="ubuntu-25-04-x64",
|
||||
region=DEFAULT_REGION,
|
||||
size=DEFAULT_SIZE,
|
||||
image=DEFAULT_IMAGE,
|
||||
ssh_keys=["/path/to/key.pub"],
|
||||
ssh_key_ids=[12345],
|
||||
extra_tags=["tag1", "tag2"],
|
||||
@@ -305,7 +308,7 @@ class TestConfigManager:
|
||||
|
||||
# Should be able to access config now
|
||||
assert config.config.digitalocean.token == "test_token"
|
||||
assert config.config.defaults.region == "nyc3"
|
||||
assert config.config.defaults.region == DEFAULT_REGION
|
||||
assert config.config.defaults.extra_tags == ["tag1", "tag2"]
|
||||
assert config.config.cloudinit.ssh_key_ids == [12345]
|
||||
|
||||
@@ -345,7 +348,7 @@ class TestConfigManager:
|
||||
username="testuser",
|
||||
region="sfo3",
|
||||
size="s-1vcpu-1gb",
|
||||
image="ubuntu-25-04-x64",
|
||||
image=DEFAULT_IMAGE,
|
||||
ssh_keys=["/path/to/key.pub"],
|
||||
ssh_key_ids=[98765],
|
||||
extra_tags=["test_tag"],
|
||||
|
||||
Reference in New Issue
Block a user