Skip to content

An API to accept a link to a helm chart, search for container images. Download docker images from their respective repositories and return a response of the list of images, their size and no. of layers in each image.

Notifications You must be signed in to change notification settings

robinmuhia/helm-charts

Repository files navigation

Helm Chart Image Processor

Lint and Tests Coverage Status

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.


Features

  • 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.

Prerequisites

  • 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.

Installation

  1. Clone the repository:

     git clone https://github.com/robinmuhia/helm-charts.git
     cd helm-charts
  2. Install dependencies

    go mod tidy
  3. Run the project (Populate environemnt variables from env.example)

    go run server.go

Usage

API Endpoint

POST /api/v1/helm-link
Content-Type: application/json

Request Example (cURL)

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
    }
   ]
  1. In case of an error

    {
     "error": "failed to download Helm chart: received status code 404"
    }

Linting and Testing

  1. To lint
   golangci-lint run -c .golangci.yaml
  1. To run tests
   go test ./...
   go test -coverprofile=coverage.out ./...
   go tool cover -html=coverage.out

Deployment

  1. You can build the binary and run it as follows;
go build -o helm-chart-processor
./helm-chart-processor
  1. Optionally, used docker
docker build -t helm-chart-processor:latest .
docker-compose up --build

Observability

View traces on

http://localhost:16686

About

An API to accept a link to a helm chart, search for container images. Download docker images from their respective repositories and return a response of the list of images, their size and no. of layers in each image.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published