From 841c5406dc4d70b0fb207ab67433d25835ca7f52 Mon Sep 17 00:00:00 2001 From: Jacob LeGrone Date: Tue, 12 Mar 2019 11:40:52 -0400 Subject: [PATCH] Explicitly disable upgrade when not install Signed-off-by: Jacob LeGrone --- pkg/config/config.go | 7 ++++++- pkg/config/config_test.go | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 9a22bfcb..8d8bbade 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -98,6 +98,9 @@ func LoadConfiguration(cfgFile string, cmd *cobra.Command, printConfig bool) (*C } } + isLint := strings.Contains(cmd.Use, "lint") + isInstall := strings.Contains(cmd.Use, "install") + cfg := &Configuration{} if err := v.Unmarshal(cfg); err != nil { return nil, errors.Wrap(err, "Error unmarshaling configuration") @@ -111,11 +114,13 @@ func LoadConfiguration(cfgFile string, cmd *cobra.Command, printConfig bool) (*C return nil, errors.New("specifying '--namespace' without '--release-label' is not allowed") } + // Disable upgrade (this does some expensive dependency building on previous revisions) + // when neither "install" nor "lint-and-install" have not been specified. + cfg.Upgrade = isInstall && cfg.Upgrade if (cfg.TargetBranch == "" || cfg.Remote == "") && cfg.Upgrade { return nil, errors.New("specifying '--upgrade=true' without '--target-branch' or '--remote', is not allowed") } - isLint := strings.Contains(cmd.Use, "lint") chartYamlSchemaPath := cfg.ChartYamlSchema if chartYamlSchemaPath == "" { var err error diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 1ca621c5..2c7a2ff5 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -30,7 +30,9 @@ func TestUnmarshalJson(t *testing.T) { } func loadAndAssertConfigFromFile(t *testing.T, configFile string) { - cfg, _ := LoadConfiguration(configFile, &cobra.Command{}, true) + cfg, _ := LoadConfiguration(configFile, &cobra.Command{ + Use: "install", + }, true) require.Equal(t, "origin", cfg.Remote) require.Equal(t, "master", cfg.TargetBranch)