forked from play-with-docker/play-with-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor bootstrap so it's decoupled from main function
- Loading branch information
1 parent
24a87d4
commit cbe5ede
Showing
2 changed files
with
28 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,34 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
|
||
"github.com/play-with-docker/play-with-docker/config" | ||
"github.com/play-with-docker/play-with-docker/docker" | ||
"github.com/play-with-docker/play-with-docker/event" | ||
"github.com/play-with-docker/play-with-docker/handlers" | ||
"github.com/play-with-docker/play-with-docker/storage" | ||
) | ||
|
||
func main() { | ||
config.ParseFlags() | ||
handlers.Bootstrap() | ||
handlers.Bootstrap(initStorage, initEvent, initFactory) | ||
handlers.Register() | ||
} | ||
|
||
func initStorage() storage.StorageApi { | ||
s, err := storage.NewFileStorage(config.SessionsFile) | ||
if err != nil && !os.IsNotExist(err) { | ||
log.Fatal("Error initializing StorageAPI: ", err) | ||
} | ||
return s | ||
} | ||
|
||
func initEvent() event.EventApi { | ||
return event.NewLocalBroker() | ||
} | ||
|
||
func initFactory(s storage.StorageApi) docker.FactoryApi { | ||
return docker.NewLocalCachedFactory(s) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters