Skip to content

feat: [#208] Add provider configuration to EnvironmentCreationConfig#211

Merged
josecelano merged 1 commit intomainfrom
208-update-environment-creation-config
Dec 2, 2025
Merged

feat: [#208] Add provider configuration to EnvironmentCreationConfig#211
josecelano merged 1 commit intomainfrom
208-update-environment-creation-config

Conversation

@josecelano
Copy link
Copy Markdown
Member

Summary

This PR implements issue #208 from the Hetzner Provider Support epic (#205).

Changes

Core Configuration Updates

  • Add provider field to EnvironmentCreationConfig (uses ProviderSection for JSON parsing)
  • Add instance_name optional field to EnvironmentSection (auto-generated as torrust-tracker-vm-{env_name} if not provided)
  • Update to_environment_params() to return (EnvironmentName, InstanceName, ProviderConfig, SshCredentials, port)

Error Handling

  • Add InvalidInstanceName error variant with actionable help message

CLI Updates

  • Add clap::ValueEnum derive to Provider enum for CLI argument parsing
  • Add --provider/-p required argument to create template command
  • Generate provider-specific templates:
    • LXD: Includes profile_name placeholder
    • Hetzner: Includes api_token, server_type, location placeholders

Documentation

  • Update docs/user-guide/commands/create.md with new configuration format
  • Update help messages to show both LXD and Hetzner template generation commands

Tests

  • Update all tests to include provider configuration in JSON fixtures

Breaking Changes

⚠️ Environment JSON files now require a provider section

⚠️ create template command now requires --provider argument

Example Configurations

LXD Provider

{
  "environment": {
    "name": "dev",
    "instance_name": "torrust-tracker-vm-dev"
  },
  "ssh_credentials": {
    "private_key_path": "fixtures/testing_rsa",
    "public_key_path": "fixtures/testing_rsa.pub",
    "username": "torrust",
    "port": 22
  },
  "provider": {
    "provider": "lxd",
    "profile_name": "torrust-profile-dev"
  }
}

Hetzner Provider

{
  "environment": {
    "name": "prod",
    "instance_name": "torrust-tracker-demo"
  },
  "ssh_credentials": {
    "private_key_path": "~/.ssh/id_rsa",
    "public_key_path": "~/.ssh/id_rsa.pub",
    "username": "torrust",
    "port": 22
  },
  "provider": {
    "provider": "hetzner",
    "api_token": "your-hetzner-api-token",
    "server_type": "cx22",
    "location": "nbg1"
  }
}

Testing

  • All 1228 library tests pass
  • All 300 doc tests pass
  • E2E provision and destroy tests pass
  • E2E configuration tests pass
  • E2E full test passes
  • Pre-commit checks pass

Related Issues

This commit implements issue #208 from the Hetzner Provider Support epic (#205).

Changes:
- Add 'provider' field to EnvironmentCreationConfig (ProviderSection for JSON parsing)
- Add 'instance_name' optional field to EnvironmentSection (auto-generated if not provided)
- Update to_environment_params() to return (EnvironmentName, InstanceName, ProviderConfig, SshCredentials, port)
- Add InvalidInstanceName error variant with actionable help message
- Add clap::ValueEnum derive to Provider enum for CLI argument parsing
- Add --provider/-p required argument to 'create template' command
- Generate provider-specific templates (LXD with profile_name, Hetzner with api_token)
- Update JSON configuration format to include provider section
- Update documentation and help messages to reflect new configuration format
- Update all tests to include provider configuration

Breaking Change:
- Environment JSON files now require a 'provider' section
- 'create template' command now requires --provider argument

Example LXD configuration:
{
  "environment": { "name": "dev" },
  "ssh_credentials": { ... },
  "provider": {
    "provider": "lxd",
    "profile_name": "torrust-profile-dev"
  }
}

Example Hetzner configuration:
{
  "environment": { "name": "prod" },
  "ssh_credentials": { ... },
  "provider": {
    "provider": "hetzner",
    "api_token": "your-token",
    "server_type": "cx22",
    "location": "nbg1"
  }
}
@josecelano josecelano self-assigned this Dec 2, 2025
@josecelano
Copy link
Copy Markdown
Member Author

ACK 792e69d

@josecelano josecelano merged commit 177e76b into main Dec 2, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update EnvironmentCreationConfig DTO

1 participant