This Go application generates CSV reports from data retrieved via the EMMA API. The application uses Docker for containerization and is designed to support various types of reports.
- List Files: Retrieve a list of available CSV files generated by the API.
- Generate CSV: Generate CSV reports containing data from the EMMA platform.
- Download File: Download a specific CSV file from the API.
- Docker installed on your machine.
- EMMA API client credentials.
Set the CREDENTIALS environment variable in the format:
export CREDENTIALS="ProjectName1:ClientId1:ClientSecret1,ProjectName2:ClientId2:ClientSecret2"
- Build the Docker image:
docker build -t emma-report-generator .
- Run the Docker container:
docker run -p 8080:8080 -e CREDENTIALS="$CREDENTIALS" emma-report-generator
Once the container is running, you can access the service at:
curl -X POST localhost:8080/v1/generates
curl localhost:8080/v1/files
FILE=$(curl http://localhost:8080/v1/files | jq -r .files[0])
curl localhost:8080/v1/downloads?file=$FILE
To start the service in a Kubernetes cluster apply the k8s.yaml. This starts this service as a pod, makes it available as a K8s services and creates a Cronjob to generate a report every 6 hours.
kubectl apply -f k8s.yaml
To make the service available locally:
kubectl port-forward service/emma-report-service 8080:80 -n reporting
To debug the service from the cluster:
kubectl run -i --tty debug-pod --image=alpine --restart=Never --rm -- /bin/sh -c "apk add --no-cache curl jq && sh"
curl http://emma-report-service.reporting.svc.cluster.local:80/v1/files | jq .files[]
- URL: /v1/files
- Method: GET
- Description: Retrieve a list of available CSV files generated by the API.
- Response: JSON array containing the names of CSV files.
- URL: /v1/generates
- Method: POST
- Description: Generate CSV reports containing VM data from the EMMA platform.
- Response: JSON array containing the names of newly generated CSV files.
- URL: /v1/downloads?file=filename
- Method: GET
- Description: Download a specific CSV file from the API.
- Required Query Parameter: file - Name of the CSV file to download.
- Response: CSV file download.
This project is licensed under the MIT License - see the LICENSE file for details.