diff --git a/cmd/minikube/cmd/config/images.go b/cmd/minikube/cmd/config/images.go index 2ed24814ee96..d1bcb4459a80 100644 --- a/cmd/minikube/cmd/config/images.go +++ b/cmd/minikube/cmd/config/images.go @@ -17,7 +17,10 @@ limitations under the License. package config import ( + "encoding/json" + "fmt" "os" + "strings" "github.com/olekukonko/tablewriter" "github.com/spf13/cobra" @@ -27,6 +30,8 @@ import ( "k8s.io/minikube/pkg/minikube/reason" ) +var addonImagesOutput string + var addonsImagesCmd = &cobra.Command{ Use: "images ADDON_NAME", Short: "List image names the addon w/ADDON_NAME used. For a list of available addons use: minikube addons list", @@ -38,33 +43,65 @@ var addonsImagesCmd = &cobra.Command{ } addon := args[0] - // allows for additional prompting of information when enabling addons - if conf, ok := assets.Addons[addon]; ok { - if conf.Images != nil { - out.Infof("{{.name}} has following images:", out.V{"name": addon}) - - var tData [][]string - table := tablewriter.NewWriter(os.Stdout) - table.SetHeader([]string{"Image Name", "Default Image", "Default Registry"}) - table.SetAutoFormatHeaders(true) - table.SetBorders(tablewriter.Border{Left: true, Top: true, Right: true, Bottom: true}) - table.SetCenterSeparator("|") - - for imageName, defaultImage := range conf.Images { - tData = append(tData, []string{imageName, defaultImage, conf.Registries[imageName]}) - } - - table.AppendBulk(tData) - table.Render() - } else { - out.Infof("{{.name}} doesn't have images.", out.V{"name": addon}) + + switch strings.ToLower(addonImagesOutput) { + case "table": + printAddonImagesTable(addon) + case "json": + printAddonImagesJSON(addon) + default: + exit.Message(reason.Usage, fmt.Sprintf("invalid output format: %s. Valid values: 'table', 'json'", addonImagesOutput)) + } + }, +} + +func printAddonImagesTable(addon string) { + // allows for additional prompting of information when enabling addons + if conf, ok := assets.Addons[addon]; ok { + if conf.Images != nil { + out.Infof("{{.name}} has the following images:", out.V{"name": addon}) + + var tData [][]string + table := tablewriter.NewWriter(os.Stdout) + table.SetHeader([]string{"Image Name", "Default Image", "Default Registry"}) + table.SetAutoFormatHeaders(true) + table.SetBorders(tablewriter.Border{Left: true, Top: true, Right: true, Bottom: true}) + table.SetCenterSeparator("|") + + for imageName, defaultImage := range conf.Images { + tData = append(tData, []string{imageName, defaultImage, conf.Registries[imageName]}) } + + table.AppendBulk(tData) + table.Render() } else { - out.FailureT("No such addon {{.name}}", out.V{"name": addon}) + out.Infof("{{.name}} doesn't have images.", out.V{"name": addon}) } - }, + } else { + out.FailureT("No such addon {{.name}}", out.V{"name": addon}) + } +} + +func printAddonImagesJSON(addon string) { + if conf, ok := assets.Addons[addon]; ok { + if conf.Images != nil { + var data []string + + for imageName, defaultImage := range conf.Images { + data = append(data, conf.Registries[imageName] + "/" + defaultImage) + } + + jsonString, _ := json.Marshal(data) + out.String(string(jsonString)) + } else { + out.String("[]") + } + } else { + out.FailureT("No such addon {{.name}}", out.V{"name": addon}) + } } func init() { + addonsImagesCmd.Flags().StringVarP(&addonImagesOutput, "output", "o", "table", "minikube addons images ADDON_NAME --output OUTPUT. table, json") AddonsCmd.AddCommand(addonsImagesCmd) } diff --git a/site/content/en/docs/commands/addons.md b/site/content/en/docs/commands/addons.md index a850f2e9740d..7fc106349089 100644 --- a/site/content/en/docs/commands/addons.md +++ b/site/content/en/docs/commands/addons.md @@ -219,6 +219,12 @@ minikube addons images ADDON_NAME [flags] minikube addons images ingress ``` +### Options + +``` + -o, --output string minikube addons images ADDON_NAME --output OUTPUT. table, json (default "table") +``` + ### Options inherited from parent commands ``` diff --git a/translations/de.json b/translations/de.json index 9439982084e0..1d18602dbcdb 100644 --- a/translations/de.json +++ b/translations/de.json @@ -1069,6 +1069,7 @@ "list versions of all components included with minikube. (the cluster must be running)": "Liste alle Versionen der Komponenten die in Minikube enthalten sind.", "loading profile": "Lade Profil", "max time to wait per Kubernetes or host to be healthy.": "maximale Zeit die gewartet werden soll, bis Kubernetes oder der Host als funktional angesehen soll.", + "minikube addons images ADDON_NAME --output OUTPUT. table, json": "", "minikube addons list --output OUTPUT. json, list": "", "minikube does not support the BTRFS storage driver yet, there is a workaround, add the following flag to your start command `--feature-gates=\"LocalStorageCapacityIsolation=false\"`": "Minikube unterstützt den BTRFS Storage Treiber noch nicht, aber es existiert eine Workaround, fügen Sie folgenden Flag zu Ihrem Start-Befehl hinzu `--feature-gates=\"LocalStorageCapacityIsolation=false\"`", "minikube does not support the BTRFS storage driver yet, there is a workaround, add the following flag to your start command `--feature-gates=\\\"LocalStorageCapacityIsolation=false\\\"`": "minikube unterstützt den BTRFS Storage Treiber nicht, es gibt einen Workaround, füge den folgenden Paramater zum Start-Befehl hinzu `--feature-gates=\\\"LocalStorageCapacityIsolation=false\\\"`", @@ -1159,6 +1160,7 @@ "{{.name}} doesn't have images.": "{{.name}} hat keine Images.", "{{.name}} has following images:": "{{.name}} hat die folgenden Images:", "{{.name}} has no available configuration options": "{{.name}} hat keine verfügbaren Konfigurations-Optionen", + "{{.name}} has the following images:": "", "{{.name}} is already running": "{{.name}} läuft bereits", "{{.name}} was successfully configured": "{{.name}} wurde erfolgreich konfiguriert", "{{.name}}\" profile does not exist": "Profil \"{{.name}}\" existiert nicht", diff --git a/translations/es.json b/translations/es.json index fe87c3a98276..a9e43045485e 100644 --- a/translations/es.json +++ b/translations/es.json @@ -1028,6 +1028,7 @@ "list versions of all components included with minikube. (the cluster must be running)": "", "loading profile": "", "max time to wait per Kubernetes or host to be healthy.": "", + "minikube addons images ADDON_NAME --output OUTPUT. table, json": "", "minikube addons list --output OUTPUT. json, list": "", "minikube does not support the BTRFS storage driver yet, there is a workaround, add the following flag to your start command `--feature-gates=\"LocalStorageCapacityIsolation=false\"`": "", "minikube is missing files relating to your guest environment. This can be fixed by running 'minikube delete'": "", @@ -1113,8 +1114,8 @@ "{{.driver_name}} has only {{.container_limit}}MB memory but you specified {{.specified_memory}}MB": "", "{{.driver}} only has {{.size}}MiB available, less than the required {{.req}}MiB for Kubernetes": "", "{{.name}} doesn't have images.": "", - "{{.name}} has following images:": "", "{{.name}} has no available configuration options": "", + "{{.name}} has the following images:": "", "{{.name}} is already running": "", "{{.name}} was successfully configured": "", "{{.n}} is nearly out of disk space, which may cause deployments to fail! ({{.p}}% of capacity). You can pass '--force' to skip this check.": "", diff --git a/translations/fr.json b/translations/fr.json index 7355b65880a0..62b9c12f82c8 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -1054,6 +1054,7 @@ "list versions of all components included with minikube. (the cluster must be running)": "répertorier les versions de tous les composants inclus avec minikube. (le cluster doit être en cours d'exécution)", "loading profile": "profil de chargement", "max time to wait per Kubernetes or host to be healthy.": "temps d'attente maximal par Kubernetes ou hôte pour être en bonne santé.", + "minikube addons images ADDON_NAME --output OUTPUT. table, json": "", "minikube addons list --output OUTPUT. json, list": "liste des modules minikube --output OUTPUT. json, liste", "minikube does not support the BTRFS storage driver yet, there is a workaround, add the following flag to your start command `--feature-gates=\"LocalStorageCapacityIsolation=false\"`": "minikube ne prend pas encore en charge le pilote de stockage BTRFS, il existe une solution de contournement, ajoutez l'indicateur suivant à votre commande de démarrage `--feature-gates=\"LocalStorageCapacityIsolation=false\"`", "minikube is missing files relating to your guest environment. This can be fixed by running 'minikube delete'": "minikube manque des fichiers relatifs à votre environnement invité. Cela peut être corrigé en exécutant 'minikube delete'", @@ -1150,6 +1151,7 @@ "{{.name}} doesn't have images.": "{{.name}} n'a pas d'images.", "{{.name}} has following images:": "{{.name}} a les images suivantes :", "{{.name}} has no available configuration options": "{{.name}} n'a pas d'options de configuration disponible", + "{{.name}} has the following images:": "", "{{.name}} is already running": "{{.name}} est déjà en cours d'exécution", "{{.name}} was successfully configured": "{{.name}} a été configuré avec succès", "{{.n}} is nearly out of disk space, which may cause deployments to fail! ({{.p}}% of capacity)": "{{.n}} manque presque d'espace disque, ce qui peut entraîner l'échec des déploiements ! ({{.p}} % de la capacité)", diff --git a/translations/ja.json b/translations/ja.json index f29a183bfe75..97800cd79c0d 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -1005,6 +1005,7 @@ "list versions of all components included with minikube. (the cluster must be running)": "minikube に含まれる全コンポーネントのバージョン一覧を出力します (クラスターが実行中でなければなりません)。", "loading profile": "プロファイルを読み込み中", "max time to wait per Kubernetes or host to be healthy.": "Kubernetes またはホストが正常稼働するまでの最大待機時間", + "minikube addons images ADDON_NAME --output OUTPUT. table, json": "", "minikube addons list --output OUTPUT. json, list": "minikube addons list --output OUTPUT. json, list", "minikube does not support the BTRFS storage driver yet, there is a workaround, add the following flag to your start command `--feature-gates=\"LocalStorageCapacityIsolation=false\"`": "minikube はまだ BTRFS ストレージドライバーに対応していませんが、回避策があります。次のフラグを start コマンドに追加してください: `--feature-gates=\"LocalStorageCapacityIsolation=false\"` ", "minikube is missing files relating to your guest environment. This can be fixed by running 'minikube delete'": "minikube はあなたのゲスト環境に関連するファイルを見失いました。これは 'minikube delete' を実行することで修正できます", @@ -1096,6 +1097,7 @@ "{{.name}} doesn't have images.": "{{.name}} はイメージがありません。", "{{.name}} has following images:": "{{.name}} は次のイメージがあります:", "{{.name}} has no available configuration options": "{{.name}} には利用可能な設定オプションがありません", + "{{.name}} has the following images:": "", "{{.name}} is already running": "{{.name}} はすでに実行中です", "{{.name}} was successfully configured": "{{.name}} は正常に設定されました", "{{.n}} is nearly out of disk space, which may cause deployments to fail! ({{.p}}% of capacity). You can pass '--force' to skip this check.": "{{.n}} はほとんどディスクがいっぱいで、デプロイが失敗する原因になりかねません!(容量の {{.p}}%)。'--force' を指定するとこのチェックをスキップできます。", diff --git a/translations/ko.json b/translations/ko.json index 9eaeb0a50c91..fac638614bfa 100644 --- a/translations/ko.json +++ b/translations/ko.json @@ -1043,6 +1043,7 @@ "logdir set failed": "logdir 설정이 실패하였습니다", "machine '{{.name}}' does not exist. Proceeding ahead with recreating VM.": "머신 '{{.name}}' 이 존재하지 않습니다. 진행하기 앞서 가상 머신을 재생성합니다", "max time to wait per Kubernetes or host to be healthy.": "", + "minikube addons images ADDON_NAME --output OUTPUT. table, json": "", "minikube addons list --output OUTPUT. json, list": "", "minikube does not support the BTRFS storage driver yet, there is a workaround, add the following flag to your start command `--feature-gates=\"LocalStorageCapacityIsolation=false\"`": "", "minikube is missing files relating to your guest environment. This can be fixed by running 'minikube delete'": "", @@ -1133,6 +1134,7 @@ "{{.name}} doesn't have images.": "{{.name}} 이미지가 없습니다.", "{{.name}} has following images:": "{{.name}}에는 다음과 같은 이미지가 있습니다.", "{{.name}} has no available configuration options": "{{.name}} 이 사용 가능한 환경 정보 옵션이 없습니다", + "{{.name}} has the following images:": "", "{{.name}} is already running": "{{.name}} 이 이미 실행 중입니다", "{{.name}} was successfully configured": "{{.name}} 이 성공적으로 설정되었습니다", "{{.n}} is nearly out of disk space, which may cause deployments to fail! ({{.p}}% of capacity). You can pass '--force' to skip this check.": "", diff --git a/translations/pl.json b/translations/pl.json index c945571cc42e..afaf67cc6b59 100644 --- a/translations/pl.json +++ b/translations/pl.json @@ -1039,6 +1039,7 @@ "list versions of all components included with minikube. (the cluster must be running)": "", "loading profile": "Ładowanie profilu", "max time to wait per Kubernetes or host to be healthy.": "", + "minikube addons images ADDON_NAME --output OUTPUT. table, json": "", "minikube addons list --output OUTPUT. json, list": "", "minikube does not support the BTRFS storage driver yet, there is a workaround, add the following flag to your start command `--feature-gates=\"LocalStorageCapacityIsolation=false\"`": "", "minikube is missing files relating to your guest environment. This can be fixed by running 'minikube delete'": "", @@ -1128,6 +1129,7 @@ "{{.name}} doesn't have images.": "{{.name}} nie ma obrazów.", "{{.name}} has following images:": "{{.name}} ma następujące obrazy:", "{{.name}} has no available configuration options": "{{.name}} nie posiada opcji konfiguracji", + "{{.name}} has the following images:": "", "{{.name}} is already running": "{{.name}} został już wcześniej uruchomiony", "{{.name}} was successfully configured": "{{.name}} skonfigurowano pomyślnie", "{{.n}} is nearly out of disk space, which may cause deployments to fail! ({{.p}}% of capacity)": "{{.n}} prawie nie ma wolnej przestrzeni dyskowej, co może powodować, że wdrożenia nie powiodą się ({{.p}}% zużycia przestrzeni dyskowej)", diff --git a/translations/ru.json b/translations/ru.json index bf4fecbe050a..a19fc189b152 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -957,6 +957,7 @@ "list versions of all components included with minikube. (the cluster must be running)": "", "loading profile": "", "max time to wait per Kubernetes or host to be healthy.": "", + "minikube addons images ADDON_NAME --output OUTPUT. table, json": "", "minikube addons list --output OUTPUT. json, list": "", "minikube does not support the BTRFS storage driver yet, there is a workaround, add the following flag to your start command `--feature-gates=\"LocalStorageCapacityIsolation=false\"`": "", "minikube is missing files relating to your guest environment. This can be fixed by running 'minikube delete'": "", @@ -1041,8 +1042,8 @@ "{{.driver_name}} has only {{.container_limit}}MB memory but you specified {{.specified_memory}}MB": "", "{{.driver}} only has {{.size}}MiB available, less than the required {{.req}}MiB for Kubernetes": "", "{{.name}} doesn't have images.": "", - "{{.name}} has following images:": "", "{{.name}} has no available configuration options": "", + "{{.name}} has the following images:": "", "{{.name}} is already running": "", "{{.name}} was successfully configured": "", "{{.n}} is nearly out of disk space, which may cause deployments to fail! ({{.p}}% of capacity)": "В {{.n}} заканчивается место на диске, что может привести к проблемам в работе! ({{.p}}% занято)", diff --git a/translations/strings.txt b/translations/strings.txt index e20082c3e091..44dc2f7f9ca2 100644 --- a/translations/strings.txt +++ b/translations/strings.txt @@ -955,6 +955,7 @@ "list versions of all components included with minikube. (the cluster must be running)": "", "loading profile": "", "max time to wait per Kubernetes or host to be healthy.": "", + "minikube addons images ADDON_NAME --output OUTPUT. table, json": "", "minikube addons list --output OUTPUT. json, list": "", "minikube does not support the BTRFS storage driver yet, there is a workaround, add the following flag to your start command `--feature-gates=\"LocalStorageCapacityIsolation=false\"`": "", "minikube is missing files relating to your guest environment. This can be fixed by running 'minikube delete'": "", @@ -1039,8 +1040,8 @@ "{{.driver_name}} has only {{.container_limit}}MB memory but you specified {{.specified_memory}}MB": "", "{{.driver}} only has {{.size}}MiB available, less than the required {{.req}}MiB for Kubernetes": "", "{{.name}} doesn't have images.": "", - "{{.name}} has following images:": "", "{{.name}} has no available configuration options": "", + "{{.name}} has the following images:": "", "{{.name}} is already running": "", "{{.name}} was successfully configured": "", "{{.n}} is nearly out of disk space, which may cause deployments to fail! ({{.p}}% of capacity). You can pass '--force' to skip this check.": "", diff --git a/translations/zh-CN.json b/translations/zh-CN.json index c641d40f3f75..c1e747b091e7 100644 --- a/translations/zh-CN.json +++ b/translations/zh-CN.json @@ -1177,6 +1177,7 @@ "loading profile": "加载配置文件", "max time to wait per Kubernetes core services to be healthy.": "每个 Kubernetes 核心服务保持健康所需的最长时间。", "max time to wait per Kubernetes or host to be healthy.": "Kubernetes 或主机正常运行前的最大等待时间。", + "minikube addons images ADDON_NAME --output OUTPUT. table, json": "", "minikube addons list --output OUTPUT. json, list": "minikube addons list --output OUTPUT. json, list", "minikube does not support the BTRFS storage driver yet, there is a workaround, add the following flag to your start command `--feature-gates=\"LocalStorageCapacityIsolation=false\"`": "minikube 尚不支持 BTRFS 存储驱动程序,有一个解决方法,将以下标志添加到你的启动命令 `--feature-gates=\"LocalStorageCapacityIsolation=false\"`", "minikube is exiting due to an error. If the above message is not useful, open an issue:": "由于出错 minikube 正在退出。如果以上信息没有帮助,请提交问题反馈:", @@ -1270,6 +1271,7 @@ "{{.name}} doesn't have images.": "{{.name}} 没有镜像", "{{.name}} has following images:": "{{.name}} 有以下镜像", "{{.name}} has no available configuration options": "{{.name}} 没有可用的配置选项", + "{{.name}} has the following images:": "", "{{.name}} is already running": "{{.name}} 已经在运行", "{{.name}} was successfully configured": "{{.name}} 成功配置", "{{.n}} is nearly out of disk space, which may cause deployments to fail! ({{.p}}% of capacity). You can pass '--force' to skip this check.": "{{.n}} 的磁盘空间即将耗尽,可能导致部署失败!(已使用容量的{{.p}}%)。您可以传递 '--force' 参数来跳过此检查。",