Skip to content

Commit

Permalink
migrate config file for cp users (#1040)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianstrauch committed Oct 25, 2021
1 parent a853066 commit 9511e57
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/pkg/config/v1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,16 @@ func (c *Config) Load() error {
if c.Ver.Compare(currentVersion) < 0 {
return errors.Errorf(errors.ConfigNotUpToDateErrorMsg, c.Ver, currentVersion)
} else if c.Ver.Compare(Version) > 0 {
return errors.Errorf(errors.InvalidConfigVersionErrorMsg, c.Ver)
if c.Ver.Equal(version.Must(version.NewVersion("3.0.0"))) {
// The user is a CP user who downloaded the v2 CLI instead of running `confluent update --major`,
// so their config files weren't merged and migrated. Migrate this config to avoid an error.
c.Ver = config.Version{Version: version.Must(version.NewVersion("1.0.0"))}
for name := range c.Contexts {
c.Contexts[name].NetrcMachineName = name
}
} else {
return errors.Errorf(errors.InvalidConfigVersionErrorMsg, c.Ver)
}
}
if err != nil {
return errors.Wrapf(err, errors.ParseConfigErrorMsg, filename)
Expand Down

0 comments on commit 9511e57

Please sign in to comment.