# 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
1. **Endpoint**: `POST /api/cf/deploy`
   - Accepts multipart form data with three parts:
     - `request`: JSON object containing CF credentials and target info
     - `jarFile`: The fat JAR file to deploy
     - `manifest`: The manifest.yml file for CF deployment

2. **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

3. **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 push` command
   - Logout from CF
   - Return deployment status and output

### Request Model Fields
- `apiEndpoint`: CF API URL
- `username`: CF username
- `password`: CF password
- `organization`: Target CF org
- `space`: Target CF space
- `appName`: Application name
- `skipSslValidation`: Boolean flag for SSL validation

### Response Model Fields
- `success`: Boolean deployment status
- `message`: Human-readable message
- `deploymentId`: Unique deployment identifier (UUID)
- `output`: CF CLI output
- `error`: Error details if failed

## Implementation Details

### Required Components
1. **Models**:
   - `CfDeployRequest` - Request DTO with validation annotations
   - `CfDeployResponse` - Response DTO with deployment details

2. **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

3. **Controller Layer**:
   - `CfDeployController` - REST endpoint controller
   - File validation (JAR and YAML extensions)
   - Request validation using Bean Validation

4. **Configuration**:
   - `application.yml` - Configure multipart file size (500MB), timeouts
   - `GlobalExceptionHandler` - Handle validation and file size exceptions

5. **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
```yaml
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:
1. `build.gradle` - with CF CLI download task and Gradle 8.14 wrapper
2. `CfDeployRequest.java` - Request model with Lombok
3. `CfDeployResponse.java` - Response model with Lombok
4. `CfCliService.java` - CF CLI execution service
5. `CfDeployController.java` - REST controller
6. `GlobalExceptionHandler.java` - Exception handling
7. `application.yml` - Application configuration

Do NOT provide:
- Complete project structure/directory tree
- Application main class
- Test classes
- Deployment manifests
- README or documentation files