diff --git a/apply/apply_test.go b/apply/apply_test.go index 336586f92..114e769bf 100644 --- a/apply/apply_test.go +++ b/apply/apply_test.go @@ -271,8 +271,9 @@ func TestApplySmokeTest(t *testing.T) { c2, e := config.UpgradeConfigVersion(c) r.NoError(e) - e = c2.Validate() + w, e := c2.Validate() r.NoError(e) + r.Len(w, 1) e = Apply(fs, c2, templates.Templates, false) r.NoError(e) diff --git a/apply/golden_file_test.go b/apply/golden_file_test.go index c2fd41010..e78bf2135 100644 --- a/apply/golden_file_test.go +++ b/apply/golden_file_test.go @@ -54,8 +54,9 @@ func TestIntegration(t *testing.T) { a.NoError(e) fmt.Printf("conf %#v\n", conf) - e = conf.Validate() + w, e := conf.Validate() a.NoError(e) + a.Len(w, 0) e = apply.Apply(testdataFs, conf, templates.Templates, true) a.NoError(e) @@ -75,8 +76,9 @@ func TestIntegration(t *testing.T) { a.NoError(e) fmt.Printf("conf %#v\n", conf) - e = conf.Validate() + w, e := conf.Validate() a.NoError(e) + a.Len(w, 0) e = apply.Apply(fs, conf, templates.Templates, true) a.NoError(e) diff --git a/cmd/apply.go b/cmd/apply.go index 80691951b..c23416127 100644 --- a/cmd/apply.go +++ b/cmd/apply.go @@ -41,7 +41,8 @@ var applyCmd = &cobra.Command{ // check that we are at root of initialized git repo openGitOrExit(fs) - config, err := readAndValidateConfig(fs, configFile) + config, warnings, err := readAndValidateConfig(fs, configFile) + printWarnings(warnings) e = mergeConfigValidationErrors(err) if e != nil { diff --git a/cmd/plan.go b/cmd/plan.go index c3fb5112c..864331125 100644 --- a/cmd/plan.go +++ b/cmd/plan.go @@ -39,7 +39,8 @@ var planCmd = &cobra.Command{ // check that we are at root of initialized git repo openGitOrExit(fs) - config, err := readAndValidateConfig(fs, configFile) + config, warnings, err := readAndValidateConfig(fs, configFile) + printWarnings(warnings) e = mergeConfigValidationErrors(err) if e != nil { @@ -50,6 +51,7 @@ var planCmd = &cobra.Command{ if e != nil { return e } + return plan.Print(p) }, } diff --git a/cmd/util.go b/cmd/util.go index cc0f632c9..2419cf0f0 100644 --- a/cmd/util.go +++ b/cmd/util.go @@ -26,15 +26,16 @@ func openGitOrExit(fs afero.Fs) { } } -func readAndValidateConfig(fs afero.Fs, configFile string) (*v2.Config, error) { +func readAndValidateConfig(fs afero.Fs, configFile string) (*v2.Config, []string, error) { conf, err := config.FindAndReadConfig(fs, configFile) if err != nil { - return nil, errs.WrapUser(err, "unable to read config file") + return nil, nil, errs.WrapUser(err, "unable to read config file") } logrus.Debug("CONFIG") logrus.Debugf("%s\n=====", pretty.Sprint(conf)) - return conf, conf.Validate() + warnings, e := conf.Validate() + return conf, warnings, e } func mergeConfigValidationErrors(err error) error { @@ -90,7 +91,7 @@ func bootstrapCmd(cmd *cobra.Command, debug bool) (afero.Fs, *v2.Config, error) return nil, nil, err } - config, err := readAndValidateConfig(fs, configFile) + config, _, err := readAndValidateConfig(fs, configFile) err = mergeConfigValidationErrors(err) if err != nil { @@ -99,3 +100,9 @@ func bootstrapCmd(cmd *cobra.Command, debug bool) (afero.Fs, *v2.Config, error) return fs, config, nil } + +func printWarnings(warnings []string) { + for _, w := range warnings { + logrus.Warn(w) + } +} diff --git a/config/v2/config_test.go b/config/v2/config_test.go index d2b7e6e2f..2603aa0f2 100644 --- a/config/v2/config_test.go +++ b/config/v2/config_test.go @@ -16,8 +16,9 @@ func TestReadConfig(t *testing.T) { c, e := ReadConfig(b) a.NoError(e) - e = c.Validate() + w, e := c.Validate() a.Error(e) + a.Len(w, 0) b2, e := util.TestFile("v2_minimal_valid") a.NoError(e) @@ -25,9 +26,9 @@ func TestReadConfig(t *testing.T) { c, e = ReadConfig(b2) a.NoError(e) - e = c.Validate() + w, e = c.Validate() a.NoError(e) - + a.Len(w, 0) } func TestReadSnowflakeProvider(t *testing.T) { @@ -41,8 +42,9 @@ func TestReadSnowflakeProvider(t *testing.T) { r.NoError(e) r.NotNil(c) - e = c.Validate() + w, e := c.Validate() r.NoError(e) + r.Len(w, 0) r.NotNil(c.Defaults.Providers) r.NotNil(c.Defaults.Providers.Snowflake) diff --git a/config/v2/validation.go b/config/v2/validation.go index e9f8d89df..70856d7a8 100644 --- a/config/v2/validation.go +++ b/config/v2/validation.go @@ -12,11 +12,13 @@ import ( ) // Validate validates the config -func (c *Config) Validate() error { +func (c *Config) Validate() ([]string, error) { if c == nil { - return errs.NewInternal("config is nil") + return nil, errs.NewInternal("config is nil") } + var errs *multierror.Error + var warnings []string v := validator.New() // This func gives us the ability to get the full path for a field deeply @@ -45,7 +47,11 @@ func (c *Config) Validate() error { errs = multierror.Append(errs, c.ValidateSnowflakeProviders()) errs = multierror.Append(errs, c.validateModules()) - return errs.ErrorOrNil() + if c.Docker { + warnings = append(warnings, "Docker support is deprecated and will be removed in a future version of fogg.") + } + + return warnings, errs.ErrorOrNil() } func ValidateAWSProvider(p *AWSProvider, component string) error { diff --git a/plan/plan_quick_test.go b/plan/plan_quick_test.go index ad5d65f3a..4437c4500 100644 --- a/plan/plan_quick_test.go +++ b/plan/plan_quick_test.go @@ -16,7 +16,7 @@ func TestValidConfigNoPanic(t *testing.T) { assertion := func(conf *v2.Config) bool { // fmt.Printf("GOT %#v\n\n", pretty.Sprint(conf)) // validate our configuration - err := conf.Validate() + _, err := conf.Validate() // if config is valid, there should be no panic if err == nil { diff --git a/plan/plan_test.go b/plan/plan_test.go index 0616dbf8d..f07aade26 100644 --- a/plan/plan_test.go +++ b/plan/plan_test.go @@ -108,8 +108,9 @@ func TestPlanBasicV2(t *testing.T) { c2, err := v2.ReadConfig(b) assert.Nil(t, err) - err = c2.Validate() + w, err := c2.Validate() a.NoError(err) + a.Len(w, 0) plan, e := Eval(c2) assert.Nil(t, e) diff --git a/plan/travisci_test.go b/plan/travisci_test.go index a57ff5fa9..147f68639 100644 --- a/plan/travisci_test.go +++ b/plan/travisci_test.go @@ -70,8 +70,9 @@ func Test_buildTravisCI_Profiles(t *testing.T) { }}, } - err := c.Validate() + w, err := c.Validate() a.NoError(err) + a.Len(w, 0) p := &Plan{} p.Accounts = p.buildAccounts(c) @@ -121,8 +122,9 @@ func Test_buildTravisCI_TestBuckets(t *testing.T) { }}, } - err := c.Validate() + w, err := c.Validate() a.NoError(err) + a.Len(w, 0) p := &Plan{} p.Accounts = p.buildAccounts(c)