From b8d4f368ff95a5e933550d4d8dd7a86dcb71c192 Mon Sep 17 00:00:00 2001 From: Christophe VILA Date: Sat, 20 Jun 2020 10:58:37 +0200 Subject: [PATCH] final version (oh yeah) --- README.md | 10 ++++++---- cmd/list.go | 19 ++++++++++++++++--- plugin.yaml | 2 +- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3d47083..660e352 100644 --- a/README.md +++ b/README.md @@ -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 - - \ No newline at end of file diff --git a/cmd/list.go b/cmd/list.go index 0ac987c..2c3047c 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -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" @@ -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) @@ -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) @@ -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 } diff --git a/plugin.yaml b/plugin.yaml index 0a64c4a..b111618 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -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"