mirror of https://github.com/helm/helm.git
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>
This commit is contained in:
parent
25ac62e153
commit
f9e54b6079
|
@ -262,7 +262,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options
|
|||
|
||||
client.Namespace = settings.Namespace()
|
||||
|
||||
// validate dry-run-option flag value is one of the allowed values
|
||||
// Validate DryRunOption member is one of the allowed values
|
||||
if err := validateDryRunOptionFlag(client.DryRunOption); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ func compInstall(args []string, toComplete string, client *action.Install) ([]st
|
|||
}
|
||||
|
||||
func validateDryRunOptionFlag(dryRunOptionFlagValue string) error {
|
||||
// validate dry-run-option flag value with set of allowed value
|
||||
// Validate dry-run flag value with a set of allowed value
|
||||
allowedDryRunValues := []string{"false", "true", "none", "client", "server"}
|
||||
isAllowed := false
|
||||
for _, v := range allowedDryRunValues {
|
||||
|
@ -319,7 +319,7 @@ func validateDryRunOptionFlag(dryRunOptionFlagValue string) error {
|
|||
}
|
||||
}
|
||||
if !isAllowed {
|
||||
return errors.New("Invalid dry-run flag. Flag must one of the following: false, true, none, client, sever")
|
||||
return errors.New("Invalid dry-run flag. Flag must one of the following: false, true, none, client, server")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ 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
|
||||
// Validate dry-run flag value is one of the allowed values
|
||||
if err := validateDryRunOptionFlag(client.DryRunOption); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -120,11 +120,9 @@ func (cfg *Configuration) renderResources(ch *chart.Chart, values chartutil.Valu
|
|||
var files map[string]string
|
||||
var err2 error
|
||||
|
||||
// A `helm template` should not talk to the remote cluster. However, commands
|
||||
// with the flag `--dry-run-option` with the value of false, none, or sever
|
||||
// or with the flag `--dry-run` with the value of false should try to interact with the cluster.
|
||||
// It may break in interesting and exotic ways because other data (e.g. discovery)
|
||||
// is mocked.
|
||||
// A `helm template` should not talk to the remote cluster. However, commands with the flag
|
||||
//`--dry-run` with the value of `false`, `none`, or `server` should try to interact with the cluster.
|
||||
// It may break in interesting and exotic ways because other data (e.g. discovery) is mocked.
|
||||
if interactWithRemote && cfg.RESTClientGetter != nil {
|
||||
restConfig, err := cfg.RESTClientGetter.ToRESTConfig()
|
||||
if err != nil {
|
||||
|
|
|
@ -204,13 +204,12 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// determine dry run behavior
|
||||
// Determine dry run behavior
|
||||
if i.DryRun || i.DryRunOption == "client" || i.DryRunOption == "server" || i.DryRunOption == "true" {
|
||||
i.DryRun = true
|
||||
}
|
||||
|
||||
var interactWithRemote bool
|
||||
// `helm template` is the only command that Install.APIVersions field will not be nil.
|
||||
if !i.DryRun || i.DryRunOption == "server" {
|
||||
interactWithRemote = true
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart.
|
|||
return nil, errors.Errorf("release name is invalid: %s", name)
|
||||
}
|
||||
|
||||
// determine dry run behavior
|
||||
// Determine dry run behavior
|
||||
if u.DryRun || u.DryRunOption == "client" || u.DryRunOption == "server" || u.DryRunOption == "true" {
|
||||
u.DryRun = true
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ func (u *Upgrade) prepareUpgrade(name string, chart *chart.Chart, vals map[strin
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
// determine whether or not to interact with remote
|
||||
// Determine whether or not to interact with remote
|
||||
var interactWithRemote bool
|
||||
if !u.DryRun || u.DryRunOption == "server" {
|
||||
interactWithRemote = true
|
||||
|
|
Loading…
Reference in New Issue