From dc2d9fa1bb09aef0fc08e7c54c13c1146f294bf6 Mon Sep 17 00:00:00 2001 From: saireddyzepto Date: Fri, 13 Dec 2024 03:50:40 +0530 Subject: [PATCH] Add --print-file-path flag to helm install command --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/helm/helm?shareId=XXXX-XXXX-XXXX-XXXX). --- cmd/helm/install.go | 6 ++++++ cmd/helm/install_test.go | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/cmd/helm/install.go b/cmd/helm/install.go index c5f9e5022..f0b597caf 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -172,6 +172,7 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { // it is added separately f := cmd.Flags() f.BoolVar(&client.HideSecret, "hide-secret", false, "hide Kubernetes Secrets when also using the --dry-run flag") + f.BoolVar(&client.PrintFilePath, "print-file-path", false, "print the file path specified by the --print-file-path flag") bindOutputFlag(cmd, &outfmt) bindPostRenderFlag(cmd, &client.PostRenderer) @@ -244,6 +245,11 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options debug("CHART PATH: %s\n", cp) + if client.PrintFilePath { + fmt.Println(cp) + return nil, nil + } + p := getter.All(settings) vals, err := valueOpts.MergeValues(p) if err != nil { diff --git a/cmd/helm/install_test.go b/cmd/helm/install_test.go index 682b25164..7aace3cbb 100644 --- a/cmd/helm/install_test.go +++ b/cmd/helm/install_test.go @@ -274,6 +274,11 @@ func TestInstall(t *testing.T) { wantError: true, golden: "output/install-hide-secret.txt", }, + { + name: "install with print-file-path", + cmd: "install printpath testdata/testcharts/alpine --print-file-path", + golden: "output/install-print-file-path.txt", + }, } runTestCmd(t, tests)