9
2
Fork
You've already forked platform
2

Use directory name as default app name during caution init #74

Closed
opened 2026年01月16日 18:39:09 +01:00 by xenushka · 2 comments

Summary

Currently, caution init creates apps with auto-generated names like app-fc8ccd2a. We should derive the app name from the current directory name, similar to how Fly.io's fly launch works.

Current behavior:

cd hello-world-enclave/
caution init
# Creates app named "app-fc8ccd2a"

Expected behavior:

cd hello-world-enclave/
caution init
# Creates app named "hello-world-enclave"

Implementation

The CLI should pass the directory name in the name field when calling POST /api/resources:

// In the init command handler
let dir_name = std::env::current_dir()
 .ok()
 .and_then(|p| p.file_name().map(|s| s.to_string_lossy().to_lowercase()));
let body = json!({
 "cmd": build_command,
 "name": dir_name // e.g., "hello-world-enclave"
});
// POST to /api/resources

API Behavior (already implemented)

The API will:

  1. Validate the name (3-63 chars, lowercase alphanumeric + hyphens, no consecutive hyphens, can't start/end with hyphen)
  2. Check uniqueness within the organization
  3. Fall back to app-{uuid} with a warning if:
    • Name is invalid (e.g., MyApp has uppercase)
    • Name is already taken

Optional Enhancement

Add a --name flag to override the directory name:

caution init --name my-custom-name

References

  • API changes: platform repo, src/api/src/main.rs lines 1124-1154
  • Validation rules: src/api/src/validation.rs validate_app_name()
# Summary Currently, `caution init` creates apps with auto-generated names like `app-fc8ccd2a`. We should derive the app name from the current directory name, similar to how Fly.io's `fly launch` works. Current behavior: ``` cd hello-world-enclave/ caution init # Creates app named "app-fc8ccd2a" ``` Expected behavior: ``` cd hello-world-enclave/ caution init # Creates app named "hello-world-enclave" ``` # Implementation The CLI should pass the directory name in the `name` field when calling `POST /api/resources`: ``` // In the init command handler let dir_name = std::env::current_dir() .ok() .and_then(|p| p.file_name().map(|s| s.to_string_lossy().to_lowercase())); let body = json!({ "cmd": build_command, "name": dir_name // e.g., "hello-world-enclave" }); // POST to /api/resources ``` # API Behavior (already implemented) The API will: 1. Validate the name (3-63 chars, lowercase alphanumeric + hyphens, no consecutive hyphens, can't start/end with hyphen) 2. Check uniqueness within the organization 3. Fall back to app-{uuid} with a warning if: - Name is invalid (e.g., MyApp has uppercase) - Name is already taken ## Optional Enhancement Add a `--name` flag to override the directory name: `caution init --name my-custom-name` # References - API changes: platform repo, `src/api/src/main.rs` lines 1124-1154 - Validation rules: `src/api/src/validation.rs` `validate_app_name()`
Owner
Copy link

This should have been opened in the cli repo, but it's fine

This should have been opened in the [cli](https://codeberg.org/caution/cli) repo, but it's fine
Owner
Copy link
Closed via https://codeberg.org/caution/cli/commit/34482d36843ce0d8c118044844f07d907f306fbb
Sign in to join this conversation.
No Branch/Tag specified
main
anton/feat/multi-user
feat/legal-publish-doc
fix/issue-119-logout-confirmation
fix/paddle-customdata-credit-mint
fix/issue-116-duplicate-ssh-key
fix/issue-265-http-port-private
fix/issue-330-remove-build-binary
feat/paddle-byoc-subscriptions
fix/issue-307-remove-apps
feat/issue-164-account-id
feat/add-tofu-lockfile-cache
feat/webauthn-discoverable-login
docs/issue-339-install-instructions
fix/issue-336-split-qr-login-tokens
fix/verify-app-source-preflight
fix/many-git-push-deploy
fix/issue-334-email-verification-throttle
fix/issue-273-billing-url
fix/issue-333-final-usage-collection
fix/issue-270-low-credit-email
fix/issue-301-remove-auto-topup
fix/issue-320-byoc-auth-first
fix/issue-348-git-progress-checklist
fix/issue-321-byoc-caution-hcl
fix/issue-332-resource-id-suspension
fix/eif-app-mode-normalization
feat/cli-stagex-container
fix/eif-s3-layer-cache
fix/authz-role-checks
fix/cli-hangs-unsupported-ssh-url
feat/print-platform-commit-dashboard
fix/config-domain-validation
anton/support-ssh-destroy-get
fix/cli-config-dir
feat/publish-build-inputs
feat/locksmith-polishing
fix/procfile-run-command-no-split
anton/byoc-require-login
fix/hcl-init-template
feat/egress-default-deny
ryansquared/hcl
quotas
anton/feat/region-routing-resource-unavailable-alert
fix/attestation-502-dashboard
ryansquared/systemdize
fix/verify-git-credential-hang
anton/fix-low-credits-alert
xenushka/rename-byoc
ryansquared/add-download-eif
add-debug-flag
test/pr1-integration-harness
anton/fix/only-pass-required-env-vars
ryansquared/add-database-bucket
No results found.
Labels
Clear labels
Compat/Breaking
Breaking change that won't be backward compatible
Component/Enclave-Builder
This issue affects Enclave Builder (git-push and CLI)
Component/Infrastructure
This issue affects generic Caution hosted infra components
Deploy/BYOC
Relates to Caution Bring-your-own-compute
Deploy/Full-managed
Relates to Caution fully managed cloud
Deploy/Self-hosted
Relates to Caution deployed on self-hosted infra
Interface/API
This issue affects the API
Interface/CLI
This issue affects the command line interface
Interface/Git
This issue affects the Git `push` interface
Interface/Web
This issue affects the web dashboard
Kind/Bug
Something is not working
Kind/Documentation
Documentation changes
Kind/Enhancement
Improve existing functionality
Kind/Feature
New functionality
Kind/Security
This is security issue
Kind/Testing
Issue or pull request related to testing
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
Reviewed
Confirmed
Issue has been confirmed
Reviewed
Duplicate
This issue or pull request already exists
Reviewed
Invalid
Invalid issue
Reviewed
Won't Fix
This issue won't be fixed
Status
Abandoned
Somebody has started to work on this but abandoned work
Status
Blocked
Something is blocking this issue or pull request
Status
Need More Info
Feedback is required to reproduce issue or to continue work
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
caution/platform#74
Reference in a new issue
caution/platform
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?