Refactoring: use CollectionFactory instead of manual collection creation.

This commit is contained in:
Andrey Smirnov
2014-03-25 14:59:26 +04:00
parent a0497058ee
commit 1a60ac6aa0
24 changed files with 101 additions and 165 deletions
+3 -6
View File
@@ -4,7 +4,6 @@ import (
"fmt"
"github.com/gonuts/commander"
"github.com/gonuts/flag"
"github.com/smira/aptly/debian"
)
func aptlyMirrorDrop(cmd *commander.Command, args []string) error {
@@ -16,16 +15,14 @@ func aptlyMirrorDrop(cmd *commander.Command, args []string) error {
name := args[0]
repoCollection := debian.NewRemoteRepoCollection(context.database)
repo, err := repoCollection.ByName(name)
repo, err := context.collectionFactory.RemoteRepoCollection().ByName(name)
if err != nil {
return fmt.Errorf("unable to drop: %s", err)
}
force := cmd.Flag.Lookup("force").Value.Get().(bool)
if !force {
snapshotCollection := debian.NewSnapshotCollection(context.database)
snapshots := snapshotCollection.ByRemoteRepoSource(repo)
snapshots := context.collectionFactory.SnapshotCollection().ByRemoteRepoSource(repo)
if len(snapshots) > 0 {
fmt.Printf("Mirror `%s` was used to create following snapshots:\n", repo.Name)
@@ -37,7 +34,7 @@ func aptlyMirrorDrop(cmd *commander.Command, args []string) error {
}
}
err = repoCollection.Drop(repo)
err = context.collectionFactory.RemoteRepoCollection().Drop(repo)
if err != nil {
return fmt.Errorf("unable to drop: %s", err)
}