Skip to content

Commit

Permalink
Code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskim06 committed Jun 7, 2020
1 parent b7689de commit 3855b27
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cmd/krew/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func preRun(cmd *cobra.Command, _ []string) error {

if _, ok := os.LookupEnv(constants.EnableMultiIndexSwitch); ok {
if err := indexmigration.Migrate(paths); err != nil {
return errors.Wrap(err, "failed to automatically migrate index")
return err
}
}

Expand Down
17 changes: 1 addition & 16 deletions integration_test/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,7 @@ func TestKrewIndexAutoMigration(t *testing.T) {
// any command here should cause the index migration to occur
test.Krew("index", "list").RunOrFail()
if !isIndexMigrated(test) {
t.Error("output should include the default index after migration")
}
}

func TestKrewMigrationSkippedWithNoCommand(t *testing.T) {
skipShort(t)

test, cleanup := NewTest(t)
defer cleanup()

test.WithEnv(constants.EnableMultiIndexSwitch, 1).WithDefaultIndex()
prepareOldIndexLayout(test)

test.Krew().RunOrFail()
if isIndexMigrated(test) {
t.Error("output should not include the migration message")
t.Error("index should have been auto-migrated")
}
}

Expand Down
6 changes: 3 additions & 3 deletions internal/indexmigration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ func Migrate(paths environment.Paths) error {
return errors.Wrap(err, "failed to check if index migration is complete")
}
if isMigrated {
klog.V(2).Infoln("already migrated")
klog.V(2).Infoln("Already migrated.")
return nil
}

klog.Info("migrating krew index layout")
klog.Info("Migrating krew index layout.")
indexPath := paths.IndexBase()
tmpPath := filepath.Join(paths.BasePath(), "tmp_index_migration")
newPath := filepath.Join(paths.IndexBase(), "default")
Expand All @@ -62,6 +62,6 @@ func Migrate(paths environment.Paths) error {
return errors.Wrapf(err, "could not move temporary index directory %q to new location %q", tmpPath, newPath)
}

klog.Info("migration completed successfully")
klog.Info("Migration completed successfully.")
return nil
}

0 comments on commit 3855b27

Please sign in to comment.