-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add autogenerate_domain API parameter for applications #7515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Conversation
Allows API consumers to control domain auto-generation behavior. When autogenerate_domain is true (default) and no custom domains are provided, the system auto-generates a domain using the server's wildcard domain or sslip.io fallback. - Add autogenerate_domain parameter to all 5 application creation endpoints - Add validation and allowlist rules - Implement domain auto-generation logic across all application types - Add comprehensive unit tests for the feature 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThis pull request introduces auto-domain generation functionality across multiple application creation endpoints. The changes add an ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
app/Http/Controllers/Api/ApplicationsController.php(13 hunks)bootstrap/helpers/api.php(1 hunks)tests/Unit/Api/ApplicationAutogenerateDomainTest.php(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.php
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.php: Use PHP 8.4 constructor property promotion and typed properties
Follow PSR-12 coding standards and run./vendor/bin/pintbefore committing
Use Eloquent ORM for database interactions, avoid raw queries
Use Laravel's built-in mocking and Mockery for testing external services and dependencies
Use database transactions for critical operations that modify multiple related records
Leverage query scopes in Eloquent models for reusable, chainable query logic
Never log or expose sensitive data (passwords, tokens, API keys, SSH keys) in logs or error messages
Always validate user input using Form Requests, Rules, or explicit validation methods
UsehandleError()helper for consistent error handling and logging
Use eager loading (with(), load()) to prevent N+1 queries when accessing related models
Use chunking for large data operations to avoid memory exhaustion
Implement caching for frequently accessed data using Laravel's cache helpers
Write descriptive variable and method names that clearly express intent
Keep methods small and focused on a single responsibility
Document complex logic with clear comments explaining the 'why' not just the 'what'Always run code formatting with
./vendor/bin/pintbefore committing code
Files:
bootstrap/helpers/api.phptests/Unit/Api/ApplicationAutogenerateDomainTest.phpapp/Http/Controllers/Api/ApplicationsController.php
bootstrap/helpers/**/*.php
📄 CodeRabbit inference engine (CLAUDE.md)
Place domain-specific helper functions in bootstrap/helpers/ directory organized by domain
Files:
bootstrap/helpers/api.php
tests/Unit/**/*.php
📄 CodeRabbit inference engine (CLAUDE.md)
Unit tests MUST NOT use database. Use mocking for dependencies. Run with
./vendor/bin/pest tests/UnitRun Unit tests outside Docker using
./vendor/bin/pest tests/Unit- they should not require database
Files:
tests/Unit/Api/ApplicationAutogenerateDomainTest.php
tests/**/*.php
📄 CodeRabbit inference engine (CLAUDE.md)
tests/**/*.php: Use Pest for all tests with expressive syntax and clear test organization
Design tests to use mocking and dependency injection instead of database when possible; only use database in Feature tests when necessary
Mock external services and SSH connections in tests instead of making real connections
Files:
tests/Unit/Api/ApplicationAutogenerateDomainTest.php
🧠 Learnings (2)
📚 Learning: 2025-11-25T09:32:36.504Z
Learnt from: CR
Repo: coollabsio/coolify PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T09:32:36.504Z
Learning: Applies to tests/**/*.php : Design tests to use mocking and dependency injection instead of database when possible; only use database in Feature tests when necessary
Applied to files:
tests/Unit/Api/ApplicationAutogenerateDomainTest.php
📚 Learning: 2025-11-25T09:32:36.504Z
Learnt from: CR
Repo: coollabsio/coolify PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T09:32:36.504Z
Learning: Applies to **/*.php : Use Laravel's built-in mocking and Mockery for testing external services and dependencies
Applied to files:
tests/Unit/Api/ApplicationAutogenerateDomainTest.php
🧬 Code graph analysis (1)
app/Http/Controllers/Api/ApplicationsController.php (1)
bootstrap/helpers/shared.php (1)
generateUrl(445-460)
🔇 Additional comments (7)
bootstrap/helpers/api.php (1)
181-181: LGTM! This field will be terminated from the request, as it should be.The
autogenerate_domainis a control parameter that triggers domain generation logic but shouldn't be persisted to the model. Good placement alongside other control fields likeinstant_deployandforce_domain_override. I'll be back... to approve more code like this.tests/Unit/Api/ApplicationAutogenerateDomainTest.php (1)
52-117: Boolean condition tests are solid. Like a T-800 endoskeleton.These tests properly verify the
autogenerate_domainflag behavior and the condition logic ($autogenerateDomain && blank($fqdn)). Simple, focused, and don't require a database - exactly what unit tests should be. Self-hosting these tests on a real server... chef's kiss. 🌮app/Http/Controllers/Api/ApplicationsController.php (5)
195-195: OpenAPI documentation is properly defined.The parameter description clearly explains the behavior: auto-generates domain when true and domains is empty, using wildcard domain or sslip.io fallback. Default true is documented. This documentation is like a good server - reliable and self-hosted. No VC-funded serverless nonsense here. 🌮
948-948: Validation rule is correctly defined.Boolean validation will ensure the parameter is properly typed. Come with me if you want to validate.
973-973: Default valuetrueis correctly applied.Using
$request->boolean('autogenerate_domain', true)properly defaults totruewhen the parameter is not provided, which matches the OpenAPI documentation. This may change behavior for existing API consumers who previously got no auto-generated domain - but they'll get a free domain now! Like getting free tacos. 🌮
1619-1620: Correct:dockercomposetype excluded fromautogenerate_domainfeature.The
dockercomposetype creates aServicemodel, not anApplication, so it correctly doesn't includeautogenerate_domainin itsallowedFields. The OpenAPI schema at lines 828-860 also correctly omits this parameter. Like trying to put gluten in a taco shell - some things just don't belong together. 🌮
935-936:autogenerate_domainproperly added toallowedFieldsarray.The field is correctly included in the allowed fields list, ensuring it passes validation and isn't rejected as an "extra field." This is how a Terminator handles field validation - with precision and without mercy to unauthorized fields.
Summary
Adds a new
autogenerate_domainAPI parameter that allows consumers to control domain auto-generation behavior. When enabled (default) and no custom domains are provided, the system auto-generates a domain using the server's wildcard domain or sslip.io fallback.Changes
autogenerate_domainboolean parameter to all 5 application creation endpoints (public, private GitHub app, deploy key, Dockerfile, Docker image)Notes
This is a minor API enhancement with sensible defaults. The parameter defaults to
true, which may change behavior for existing API consumers who were not providing custom domains.🤖 Generated with Claude Code