4.0 KiB
4.0 KiB
CF Deployer Spring Boot Application - Implementation Request
Overview
Create a Spring Boot 3+ application with Gradle 8.14 that exposes a REST API endpoint for deploying Java applications to Cloud Foundry/Tanzu environments. The application itself will be deployed on Tanzu but must allow users to deploy to different Tanzu environments.
Technical Requirements
Build Configuration
- Gradle Version: 8.14
- Spring Boot Version: 3.2.0 or higher
- Java Version: 17+
- Key Dependencies:
- Spring Boot Starter Web
- Spring Boot Starter Validation
- Apache Commons IO
- Lombok (for clean code)
Core Functionality
-
Endpoint:
POST /api/cf/deploy- Accepts multipart form data with three parts:
request: JSON object containing CF credentials and target infojarFile: The fat JAR file to deploymanifest: The manifest.yml file for CF deployment
- Accepts multipart form data with three parts:
-
CF CLI Integration:
- Package CF CLI binary with the application JAR
- Download CF CLI during build process (Gradle task)
- Support Linux, macOS, and Windows
- Execute CF commands programmatically
-
Deployment Flow:
- Accept user credentials, API endpoint, org, space
- Accept JAR file and manifest.yml
- Login to CF using provided credentials
- Push application using
cf pushcommand - Logout from CF
- Return deployment status and output
Request Model Fields
apiEndpoint: CF API URLusername: CF usernamepassword: CF passwordorganization: Target CF orgspace: Target CF spaceappName: Application nameskipSslValidation: Boolean flag for SSL validation
Response Model Fields
success: Boolean deployment statusmessage: Human-readable messagedeploymentId: Unique deployment identifier (UUID)output: CF CLI outputerror: Error details if failed
Implementation Details
Required Components
-
Models:
CfDeployRequest- Request DTO with validation annotationsCfDeployResponse- Response DTO with deployment details
-
Service Layer:
CfCliService- Service to handle CF CLI execution- Methods:
deployApplication(),login(),pushApplication(),logout() - Use temp directories for file operations
- Implement proper cleanup after deployment
-
Controller Layer:
CfDeployController- REST endpoint controller- File validation (JAR and YAML extensions)
- Request validation using Bean Validation
-
Configuration:
application.yml- Configure multipart file size (500MB), timeoutsGlobalExceptionHandler- Handle validation and file size exceptions
-
Build Configuration:
- Gradle task to download CF CLI during build
- Extract and package CF CLI in application resources
- Detect OS and download appropriate CF CLI binary
Security & Best Practices
- Clean up temporary files after deployment
- Secure password handling (don't log passwords)
- Command timeout configuration
- Process output streaming
- Proper error handling and logging
Configuration Properties
spring.servlet.multipart.max-file-size: 500MB
spring.servlet.multipart.max-request-size: 500MB
cf.cli.timeout: 600 # seconds
cf.cli.path: # optional explicit path
Code Style Requirements
- Use Lombok annotations (@Data, @Builder, @Slf4j, @RequiredArgsConstructor)
- Follow Spring Boot best practices
- Proper logging at INFO and DEBUG levels
- Clean, maintainable code structure
Expected Deliverables
Provide only the essential Java classes and configuration files:
build.gradle- with CF CLI download task and Gradle 8.14 wrapperCfDeployRequest.java- Request model with LombokCfDeployResponse.java- Response model with LombokCfCliService.java- CF CLI execution serviceCfDeployController.java- REST controllerGlobalExceptionHandler.java- Exception handlingapplication.yml- Application configuration
Do NOT provide:
- Complete project structure/directory tree
- Application main class
- Test classes
- Deployment manifests
- README or documentation files