|
1 |
| -# Foundry |
| 1 | +# Catalyst Foundry API |
2 | 2 |
|
3 |
| -Foundry provides the middleware for routing deployments from forge to a GitOps repository. |
| 3 | +This is the API server for the Catalyst Foundry system, providing endpoints for managing releases and deployments. |
4 | 4 |
|
5 |
| -Note that this service is currently incomplete and is a work in progress. |
| 5 | +## API Documentation |
| 6 | + |
| 7 | +The API documentation is generated using Swagger/OpenAPI and is available in two formats: |
| 8 | + |
| 9 | +1. **Interactive Swagger UI**: Available at `/swagger/index.html` when the server is running |
| 10 | +2. **OpenAPI JSON**: Available at `/swagger/doc.json` when the server is running |
| 11 | + |
| 12 | +## Getting Started |
| 13 | + |
| 14 | +### Prerequisites |
| 15 | + |
| 16 | +- Go 1.24.2 or later |
| 17 | +- PostgreSQL database |
| 18 | +- Kubernetes cluster (optional, for deployment features) |
| 19 | + |
| 20 | +### Installation |
| 21 | + |
| 22 | +1. Install dependencies: |
| 23 | + ```bash |
| 24 | + make deps |
| 25 | + ``` |
| 26 | + |
| 27 | +2. Install Swagger tools (one-time setup): |
| 28 | + ```bash |
| 29 | + make swagger-init |
| 30 | + ``` |
| 31 | + |
| 32 | +3. Generate API documentation: |
| 33 | + ```bash |
| 34 | + make swagger-gen |
| 35 | + ``` |
| 36 | + |
| 37 | +4. Build and run the API: |
| 38 | + ```bash |
| 39 | + make run |
| 40 | + ``` |
| 41 | + |
| 42 | +### Development |
| 43 | + |
| 44 | +For development with auto-generated documentation: |
| 45 | + |
| 46 | +```bash |
| 47 | +make dev |
| 48 | +``` |
| 49 | + |
| 50 | +This will generate the documentation and start the server. |
| 51 | + |
| 52 | +## API Endpoints |
| 53 | + |
| 54 | +### Health Check |
| 55 | +- `GET /healthz` - Check API health status |
| 56 | + |
| 57 | +### GitHub Actions Authentication |
| 58 | +- `POST /gha/validate` - Validate GitHub Actions OIDC token |
| 59 | +- `POST /gha/auth` - Create GHA authentication configuration |
| 60 | +- `GET /gha/auth` - List GHA authentication configurations |
| 61 | +- `GET /gha/auth/:id` - Get specific GHA authentication configuration |
| 62 | +- `GET /gha/auth/repository/:repository` - Get GHA auth by repository |
| 63 | +- `PUT /gha/auth/:id` - Update GHA authentication configuration |
| 64 | +- `DELETE /gha/auth/:id` - Delete GHA authentication configuration |
| 65 | + |
| 66 | +### Releases |
| 67 | +- `POST /release` - Create a new release |
| 68 | +- `GET /release/:id` - Get a specific release |
| 69 | +- `PUT /release/:id` - Update a release |
| 70 | +- `GET /releases` - List all releases |
| 71 | + |
| 72 | +### Release Aliases |
| 73 | +- `GET /release/alias/:name` - Get release by alias |
| 74 | +- `POST /release/alias/:name` - Create an alias for a release |
| 75 | +- `DELETE /release/alias/:name` - Delete an alias |
| 76 | +- `GET /release/:id/aliases` - List aliases for a release |
| 77 | + |
| 78 | +### Deployments |
| 79 | +- `POST /release/:id/deploy` - Create a deployment for a release |
| 80 | +- `GET /release/:id/deploy/:deployId` - Get a specific deployment |
| 81 | +- `PUT /release/:id/deploy/:deployId` - Update a deployment |
| 82 | +- `GET /release/:id/deployments` - List deployments for a release |
| 83 | +- `GET /release/:id/deploy/latest` - Get the latest deployment |
| 84 | + |
| 85 | +### Deployment Events |
| 86 | +- `POST /release/:id/deploy/:deployId/events` - Add an event to a deployment |
| 87 | +- `GET /release/:id/deploy/:deployId/events` - Get events for a deployment |
| 88 | + |
| 89 | +## Authentication |
| 90 | + |
| 91 | +The API uses JWT tokens for authentication. Most endpoints require authentication with the following permissions: |
| 92 | + |
| 93 | +- `PermReleaseRead` - Read access to releases |
| 94 | +- `PermReleaseWrite` - Write access to releases |
| 95 | +- `PermDeploymentRead` - Read access to deployments |
| 96 | +- `PermDeploymentWrite` - Write access to deployments |
| 97 | +- `PermDeploymentEventRead` - Read access to deployment events |
| 98 | +- `PermDeploymentEventWrite` - Write access to deployment events |
| 99 | +- `PermGHAAuthRead` - Read access to GHA authentication |
| 100 | +- `PermGHAAuthWrite` - Write access to GHA authentication |
| 101 | + |
| 102 | +## Configuration |
| 103 | + |
| 104 | +The API can be configured using environment variables or command-line flags. See the main application help for details: |
| 105 | + |
| 106 | +```bash |
| 107 | +./bin/foundry-api --help |
| 108 | +``` |
| 109 | + |
| 110 | +## Documentation Generation |
| 111 | + |
| 112 | +To regenerate the API documentation after making changes: |
| 113 | + |
| 114 | +```bash |
| 115 | +make swagger-gen |
| 116 | +``` |
| 117 | + |
| 118 | +This will update the `docs/` directory with the latest API documentation. |
| 119 | + |
| 120 | +## Testing |
| 121 | + |
| 122 | +Run the tests: |
| 123 | + |
| 124 | +```bash |
| 125 | +go test ./... |
| 126 | +``` |
| 127 | + |
| 128 | +## License |
| 129 | + |
| 130 | +This project is licensed under the Apache License 2.0. |
0 commit comments