From 441adb7fe6c5d914cafe07e1ef1535a8084ebf47 Mon Sep 17 00:00:00 2001 From: ccoVeille <3875889+ccoVeille@users.noreply.github.com> Date: Tue, 27 May 2025 10:40:15 +0200 Subject: [PATCH 1/2] fix: error message when trying to migrate a migrated config. The check was done in the wrong place, so it was not triggered when the config was already migrated. Another error message was reported about jsonschema validation issues. Because a v2 config file does not validate against the v1 schema. That was misleading. --- pkg/commands/migrate.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/commands/migrate.go b/pkg/commands/migrate.go index 7c73209ed180..ef981f55fb50 100644 --- a/pkg/commands/migrate.go +++ b/pkg/commands/migrate.go @@ -81,10 +81,6 @@ func newMigrateCommand(log logutils.Log, info BuildInfo) *migrateCommand { } func (c *migrateCommand) execute(_ *cobra.Command, _ []string) error { - if c.cfg.Version != "" { - return fmt.Errorf("configuration version is already set: %s", c.cfg.Version) - } - srcPath := c.viper.ConfigFileUsed() if srcPath == "" { c.log.Warnf("No config file detected") @@ -151,6 +147,10 @@ func (c *migrateCommand) preRunE(cmd *cobra.Command, _ []string) error { os.Exit(exitcodes.NoConfigFileDetected) } + if c.cfg.Version != "" { + return fmt.Errorf("configuration version is already set: %s", c.cfg.Version) + } + c.log.Infof("Validating v1 configuration file: %s", usedConfigFile) err := validateConfiguration("https://golangci-lint.run/jsonschema/golangci.v1.jsonschema.json", usedConfigFile) From 3bd1d3f447b3281cef7f2dd22dc1f3335f8d5180 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 27 May 2025 11:40:46 +0200 Subject: [PATCH 2/2] review --- pkg/commands/migrate.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/commands/migrate.go b/pkg/commands/migrate.go index ef981f55fb50..78e7842bed04 100644 --- a/pkg/commands/migrate.go +++ b/pkg/commands/migrate.go @@ -137,6 +137,10 @@ func (c *migrateCommand) preRunE(cmd *cobra.Command, _ []string) error { return fmt.Errorf("unsupported format: %s", c.opts.format) } + if c.cfg.Version != "" { + return fmt.Errorf("configuration version is already set: %s", c.cfg.Version) + } + if c.opts.skipValidation { return nil } @@ -147,10 +151,6 @@ func (c *migrateCommand) preRunE(cmd *cobra.Command, _ []string) error { os.Exit(exitcodes.NoConfigFileDetected) } - if c.cfg.Version != "" { - return fmt.Errorf("configuration version is already set: %s", c.cfg.Version) - } - c.log.Infof("Validating v1 configuration file: %s", usedConfigFile) err := validateConfiguration("https://golangci-lint.run/jsonschema/golangci.v1.jsonschema.json", usedConfigFile)