(cfg *action.Configuration, out io.Writer)
| 83 | ` |
| 84 | |
| 85 | func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { |
| 86 | client := action.NewUpgrade(cfg) |
| 87 | valueOpts := &values.Options{} |
| 88 | var outfmt output.Format |
| 89 | var createNamespace bool |
| 90 | |
| 91 | cmd := &cobra.Command{ |
| 92 | Use: "upgrade [RELEASE] [CHART]", |
| 93 | Short: "upgrade a release", |
| 94 | Long: upgradeDesc, |
| 95 | Args: require.ExactArgs(2), |
| 96 | ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 97 | if len(args) == 0 { |
| 98 | return compListReleases(toComplete, args, cfg) |
| 99 | } |
| 100 | if len(args) == 1 { |
| 101 | return compListCharts(toComplete, true) |
| 102 | } |
| 103 | return noMoreArgsComp() |
| 104 | }, |
| 105 | RunE: func(cmd *cobra.Command, args []string) error { |
| 106 | client.Namespace = settings.Namespace() |
| 107 | |
| 108 | registryClient, err := newRegistryClient(out, client.CertFile, client.KeyFile, client.CaFile, |
| 109 | client.InsecureSkipTLSVerify, client.PlainHTTP, client.Username, client.Password) |
| 110 | if err != nil { |
| 111 | return fmt.Errorf("missing registry client: %w", err) |
| 112 | } |
| 113 | client.SetRegistryClient(registryClient) |
| 114 | |
| 115 | dryRunStrategy, err := cmdGetDryRunFlagStrategy(cmd, false) |
| 116 | if err != nil { |
| 117 | return err |
| 118 | } |
| 119 | client.DryRunStrategy = dryRunStrategy |
| 120 | |
| 121 | // Fixes #7002 - Support reading values from STDIN for `upgrade` command |
| 122 | // Must load values AFTER determining if we have to call install so that values loaded from stdin are not read twice |
| 123 | if client.Install { |
| 124 | // If a release does not exist, install it. |
| 125 | histClient := action.NewHistory(cfg) |
| 126 | histClient.Max = 1 |
| 127 | versions, err := histClient.Run(args[0]) |
| 128 | if errors.Is(err, driver.ErrReleaseNotFound) || isReleaseUninstalled(versions) { |
| 129 | // Only print this to stdout for table output |
| 130 | if outfmt == output.Table { |
| 131 | fmt.Fprintf(out, "Release %q does not exist. Installing it now.\n", args[0]) |
| 132 | } |
| 133 | instClient := action.NewInstall(cfg) |
| 134 | instClient.CreateNamespace = createNamespace |
| 135 | instClient.ChartPathOptions = client.ChartPathOptions |
| 136 | instClient.ForceReplace = client.ForceReplace |
| 137 | instClient.DryRunStrategy = client.DryRunStrategy |
| 138 | instClient.DisableHooks = client.DisableHooks |
| 139 | instClient.SkipCRDs = client.SkipCRDs |
| 140 | instClient.Timeout = client.Timeout |
| 141 | instClient.WaitStrategy = client.WaitStrategy |
| 142 | instClient.WaitForJobs = client.WaitForJobs |
no test coverage detected
searching dependent graphs…