This project provides an API that processes a Helm chart to extract container image details. The API accepts a Helm chart path, identifies all container images, downloads metadata from their respective registries, and returns the image size and number of layers.
- Helm Chart Parsing: Processes a Helm chart using
helm template
. - Image Extraction: Extracts container image references from Kubernetes manifests.
- Image Metadata Retrieval: Fetches size and layer details for each image using Docker registries.
- REST API: Exposes functionality through a simple HTTP POST API.
- Helm CLI: Install the Helm CLI from Helm Installation Guide.
- Go: Install Go (1.20 or later).
- Docker Registry Access: Ensure the machine running the code has internet access to query Docker registries.
-
Clone the repository:
git clone https://github.com/robinmuhia/helm-charts.git cd helm-charts
-
Install dependencies
go mod tidy
-
Run the project (Populate environemnt variables from env.example)
go run server.go
POST /api/v1/helm-link
Content-Type: application/json
curl -X POST http://localhost:8080/api/v1/helm-link \
-H "Content-Type: application/json" \
-d '{
"url_link": "https://github.com/helm/examples/releases/download/hello-world-0.1.0/hello-world-0.1.0.tgz"
}'
2. Expected Response
```bash
[
{
"image": "nginx:1.16.0",
"size": 44815103,
"layers": 3
}
]
-
In case of an error
{ "error": "failed to download Helm chart: received status code 404" }
- To lint
golangci-lint run -c .golangci.yaml
- To run tests
go test ./...
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
- You can build the binary and run it as follows;
go build -o helm-chart-processor
./helm-chart-processor
- Optionally, used docker
docker build -t helm-chart-processor:latest .
docker-compose up --build
View traces on
http://localhost:16686