dgoscn / go-helm-cli

This is just a Golang CLI that receive as input a list of Helm Charts URLs or local and result with different outputs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Helm CLI

Helm CLI is a command-line created in Golang that will take as input a list of Helm Charts GitHub repo url or a local folder. i.e:

path (Ex: https://github.com/epinio/helm-charts/tree/main/chart/epinio or c:/epinio/helm- charts/chart) .

Expected Outputs

The binary should behave in this manner.

1. First Action

Command - add

Result - Adds the helm chart information to the CLI’s internal list and a storage of your choice.

2. Second Action

Command - index

Result – Generates Helm Repo Index file

3. Third Action

Command - install chart

Result - Installs the given helm chart in the current Kubernetes cluster. Installation of the helm chart must happen inside a Kubernetes pod.

4. Fourth Action

Command - images

Result - Provides a list of all the container images used in all the charts added.

Prerequisites

  • Docker: Ensure that Docker is installed and running on your machine. (optional)
  • Kubernetes 1.27
  • Helm 3.7.0
  • Go 1.19

Getting Started

There are two options to run this project.

First One - Local Kubernetes

Run the project on your machine. For that, what you need it is only a Kubernetes minimum version 1.27 and the Helm minimum version 3.7.0.

Clone the repository:

go-helm-cli$ git clone https://github.com/dgoscn/go-helm-cli.git

Navigate through the files and get into the directory and check if the build of the project is in

go-helm-cli$ file helm-cli 

Once validated, execute the following commands:

go-helm-cli$ ./helm-cli <command>

Replace with one of the supported commands: add, index, install, or images. See the Usage section below for more details on each command.

Local Kubernetes Usage

  • Add a Helm Chart:

    go-helm-cli$ ./helm-cli add https://github.com/epinio/helm-charts/tree/main/chart/epinio
  • Generate Repo Index:

    go-helm-cli$ ./helm-cli index
  • Install a Helm Chart:

    go-helm-cli$ ./helm-cli install chart epinio
  • List Container Images:

    go-helm-cli$ ./helm-cli images

    This command provides a list of all the container images used in the charts added.

Second One - Docker

Build the Docker image:

cd helm-cli
docker build -t helm-cli .

Run the Helm CLI commands using Docker:

docker run -it --rm -v ~/.kube/config:/root/.kube/config -v $(pwd)/charts:/app/charts helm-cli <command>

Replace <command> with one of the supported commands: add, index, install, or images. See the Usage section below for more details on each command.

Docker Usage

  • Add a Helm Chart:

    docker run -it --rm -v ~/.kube/config:/root/.kube/config -v $(pwd)/charts:/app/charts helm-cli add <chart-location>

    So, after filled:

    docker run -it --rm -v ~/.kube/config:/root/.kube/config -v $(pwd)/charts:/app/charts helm-cli add https://github.com/epinio/helm-charts/tree/main/chart/epinio

    This command adds the Helm chart information from the specified <chart-location> to the CLI's internal list and stores it in the charts directory.

  • Generate Repo Index:

    docker run -it --rm -v ~/.kube/config:/root/.kube/config -v $(pwd)/charts:/app/charts helm-cli index

    This command generates the Helm repository index file based on the charts added using the add command.

  • Install a Helm Chart:

    docker run -it --rm -v ~/.kube/config:/root/.kube/config -v $(pwd)/charts:/app/charts helm-cli install chart <chart-name>

    In that case, we have the example with epinio address right below

    docker run -it --rm -v ~/.kube/config:/root/.kube/config -v $(pwd)/charts:/app/charts helm-cli install chart epinio
  • List Container Images:

    docker run -it --rm -v ~/.kube/config:/root/.kube/config -v $(pwd)/charts:/app/charts helm-cli images

    This command provides a list of all the container images used in the charts added.

Run the tests

You just need to go to the root file of the project and run the following command:

 /home/go-helm-cli/cmd$ go test
 /home/go-helm-cli/cmd$ go test . -v 
 /home/go-helm-cli/cmd$ go test . -v -coverprofile cover.out

About

This is just a Golang CLI that receive as input a list of Helm Charts URLs or local and result with different outputs.


Languages

Language:Go 90.6%Language:Dockerfile 9.4%