Skip to content

Commit

Permalink
final version (oh yeah)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christophe VILA committed Jun 20, 2020
1 parent cae8590 commit b8d4f36
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ Saving all images in prometheus-operator.tar...
Successfully saved all images in prometheus-operator.tar
```

You can specify values just like standard helm commands with `--values`, `--set`, `--set-string` and `--set-file` flags

## How does it work ?

To list the images, a dry-run helm installation is actually performed, then all generated manifests are parsed in a temporary directory to find all container templates for all deployments and statefulsets
- To list the images, a dry-run helm installation is actually performed, then all generated manifests are parsed in a temporary directory to find all container templates for all deployments, statefulsets and jobs following Kubernetes APIs (`k8s.io/apis/apps/v1` and `k8s.io/apis/batch/v1`)

helm-image support the `weight` attribute introduced in [helm-spray](https://github.com/thalesgroup/helm-spray) to run up to 4 dry-run installations in parallel from the lowest to the highest weight of sub-charts (helm is mono-threaded)

To save the images, a containerd server is launched in background, with a client pulling all the images, then exporting them in a file
- To save the images, a containerd server is launched in background, with a client pulling all the images, then exporting them in a file

## Known bugs and limitations

This plugin has only been tested on Windows so far


19 changes: 16 additions & 3 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
cliValues "helm.sh/helm/v3/pkg/cli/values"
"io"
"io/ioutil"
v1 "k8s.io/api/apps/v1"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
"k8s.io/client-go/kubernetes/scheme"
"log"
"os"
Expand Down Expand Up @@ -158,7 +159,7 @@ func addContainerImages(images *imagesList, path string, debug bool) error {
}
return nil
}
deployment, ok := manifest.(*v1.Deployment)
deployment, ok := manifest.(*appsv1.Deployment)
if ok {
if debug {
log.Printf("Searching for deployment images in %s...\n", path)
Expand All @@ -170,7 +171,7 @@ func addContainerImages(images *imagesList, path string, debug bool) error {
images.add(container.Image)
}
}
statefulSet, ok := manifest.(*v1.StatefulSet)
statefulSet, ok := manifest.(*appsv1.StatefulSet)
if ok {
if debug {
log.Printf("Searching for statefulset images in %s...\n", path)
Expand All @@ -182,6 +183,18 @@ func addContainerImages(images *imagesList, path string, debug bool) error {
images.add(container.Image)
}
}
jobs, ok := manifest.(*batchv1.Job)
if ok {
if debug {
log.Printf("Searching for job images in %s...\n", path)
}
for _, container := range jobs.Spec.Template.Spec.Containers {
images.add(container.Image)
}
for _, container := range jobs.Spec.Template.Spec.InitContainers {
images.add(container.Image)
}
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "image"
version: "1.0.0-rc.8"
version: "1.0.0"
usage: "get docker images from a chart"
description: "Helm plugin for getting docker images from a chart"
command: "$HELM_PLUGIN_DIR/bin/helm-image"
Expand Down

0 comments on commit b8d4f36

Please sign in to comment.