earthly:badges

badges is a web application written in go that exposes a REST API to:
- create and store a badge
- Retrieve it by ID
PUT /badges/[badgeId]
Creates or updates a badge.
Request
- Content-type: application/json
- Authorization: Bearer token required
- Body structure:
label: The label of the badge (first text over gray background)
message: The message of the badge (following text over colored background)
color: Background color of the message
Response
- Content-type: application/json
- Body structure:
GET /badges/{badgeId}
Retrieves the badge image, ready to embed in documentation.
Request
- Content-type: N/A
- Authorization: Not required
Response
- Content-type: image/svg+xml
Data storage
Current implementation only supports local Sqlite db, so a persistent filesystem is required.
Authorization
PUT requests require a bearer token.
Current implementation only accepts a single token value, that is passed as an environment entry.
Configuration
Configuration is done through environment entries.
Local test
Set up your bearer token secret:
export SECRET=<your-bearer-token>
Use earthly to start up a local docker compose stack.
earthly +dev-up
Create a new badge:
curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SECRET" \
-d '{"label":"lunar", "message":"passing 22/22", "color":"#97ca00"}' \
http://127.0.0.1:8081/badges/foo
And fetch it!
http://127.0.0.1:8081/badges/foo

Finally, tear the stack down via:
earthly +dev-down
Creating/pushing image
earthly [--push] +badges-image --NAME=<image-name> --VERSION=<image-tag>