# Forgejo Runner in Edge Connect Example

Execute in the projects main directory:

```
go run . apply -f forgejo-runner/EdgeConnectConfig.yaml
```

## Improvement: 'create app instance' with full respone body analysis (feature/parsing_createappinstance)

When we have an errorneous deployment (example: "namespace: gitea" within the manifest) EdgeConnect will reject the deployment at some stage in its creation workflow.
Now we grab the error correctly in the workflow-response-array by parsing the whole response body and don't think the deployment worked just of only reading the first successfull step (which was the creation of the app instance):

```bash
(devbox) stl@ubuntu-vpn:~/git/mms/ipcei-cis/edge-connect-client$ go run . apply -f sdk/examples/forgejo-runner/EdgeConnectConfig.yaml
📄 Loading configuration from: /home/stl/git/mms/ipcei-cis/edge-connect-client/sdk/examples/forgejo-runner/EdgeConnectConfig.yaml
✅ Configuration loaded successfully: forgejo-runner-edge
🔍 Analyzing current state and generating deployment plan...

📋 Deployment Plan:
==================================================
Deployment plan for 'forgejo-runner-edge':
- CREATE application 'forgejo-runner-edge'
  - Create new application
- CREATE 1 instance(s) across 1 cloudlet(s)
Estimated duration: 3m0s
==================================================

This will perform 2 actions. Estimated time: 3m0s
Do you want to proceed? (yes/no): yes

🚀 Starting deployment...
2025/10/16 16:58:08 [ResourceManager] Starting deployment: forgejo-runner-edge
2025/10/16 16:58:08 [ResourceManager] Validating deployment prerequisites for: forgejo-runner-edge
2025/10/16 16:58:08 [ResourceManager] Prerequisites validation passed
2025/10/16 16:58:08 [ResourceManager] Using deployment strategy: recreate
2025/10/16 16:58:08 [ResourceManager] Estimated deployment duration: 8m20s
2025/10/16 16:58:08 [RecreateStrategy] Starting recreate deployment strategy for: forgejo-runner-edge
2025/10/16 16:58:08 [RecreateStrategy] Phase 1: Deleting existing instances
2025/10/16 16:58:08 [RecreateStrategy] No existing instances to delete
2025/10/16 16:58:08 [RecreateStrategy] Phase 2: No app deletion needed (new app)
2025/10/16 16:58:08 [RecreateStrategy] Phase 3: Creating application
2025/10/16 16:58:10 [RecreateStrategy] Successfully created application: edp2/forgejo-runner-edge version 1.0.0
2025/10/16 16:58:10 [RecreateStrategy] Phase 3 complete: app created successfully
2025/10/16 16:58:10 [RecreateStrategy] Phase 4: Creating new instances
2025/10/16 16:58:11 [RecreateStrategy] Failed to create instance forgejo-runner-edge-1.0.0-instance: failed to create instance: ShowAppInstance failed to parse response: API error: {"status_code":400,"code":"400","messages":["Encountered failures: Create App Inst failed: deployments.apps is forbidden: User \"system:serviceaccount:edgexr:crm-telekomop-hamburg\" cannot create resource \"deployments\" in API group \"apps\" in the namespace \"gitea\"","Creating","a service has been configured","your application is accessiable via https://forgejo-runner-test-tcp.apps.edge.platform.mg3.mdb.osc.live","CreateError","Deleting AppInst due to failure","Deleted AppInst successfully"]} (non-retryable error, giving up)
2025/10/16 16:58:11 [ResourceManager] Deployment failed, attempting rollback...
2025/10/16 16:58:11 [ResourceManager] Starting rollback for deployment: forgejo-runner-edge
2025/10/16 16:58:11 [ResourceManager] Successfully rolled back: forgejo-runner-edge
2025/10/16 16:58:11 [ResourceManager] Rollback completed successfully
Error: deployment failed: failed to create instance forgejo-runner-edge-1.0.0-instance: non-retryable error: failed to create instance: ShowAppInstance failed to parse response: API error: {"status_code":400,"code":"400","messages":["Encountered failures: Create App Inst failed: deployments.apps is forbidden: User \"system:serviceaccount:edgexr:crm-telekomop-hamburg\" cannot create resource \"deployments\" in API group \"apps\" in the namespace \"gitea\"","Creating","a service has been configured","your application is accessiable via https://forgejo-runner-test-tcp.apps.edge.platform.mg3.mdb.osc.live","CreateError","Deleting AppInst due to failure","Deleted AppInst successfully"]}
exit status 1
```