feat(helm): add ability for --dry-run to do lookup functions

When a helm command is run with the --dry-run flag, it will try to connect to the cluster
if the value is 'server' to be able to render lookup functions.
Closes #8137

Signed-off-by: Tapas Kapadia <tapaskapadia10@gmail.com>
pull/9426/head
Tapas Kapadia 3 years ago
parent 51281c195a
commit 4d67dfabaa

@ -263,7 +263,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options
client.Namespace = settings.Namespace()
// validate dry-run flag value is one of the allowed values
if err := validateDryRunFlag(client); err != nil {
if err := validateDryRunFlag(client.DryRun); err != nil {
return nil, err
}
@ -308,12 +308,12 @@ func compInstall(args []string, toComplete string, client *action.Install) ([]st
return nil, cobra.ShellCompDirectiveNoFileComp
}
func validateDryRunFlag(client *action.Install) error {
func validateDryRunFlag(dryRunFlagValue string) error {
// validate dry-run flag value with set of allowed value
allowedDryRunValues := []string{"false", "true", "none", "client", "server"}
isAllowed := false
for _, v := range allowedDryRunValues {
if client.DryRun == v {
if dryRunFlagValue == v {
isAllowed = true
break
}

@ -120,11 +120,6 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
instClient.Description = client.Description
instClient.DependencyUpdate = client.DependencyUpdate
// validate dry-run flag value is one of the allowed values
if err := validateDryRunFlag(instClient); err != nil {
return err
}
rel, err := runInstall(args, instClient, valueOpts, out)
if err != nil {
return err
@ -144,6 +139,10 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
if err != nil {
return err
}
// validate dry-run flag value is one of the allowed values
if err := validateDryRunFlag(client.DryRun); err != nil {
return err
}
p := getter.All(settings)
vals, err := valueOpts.MergeValues(p)

Loading…
Cancel
Save