forked from elwinar/rambler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.go
More file actions
32 lines (26 loc) · 776 Bytes
/
bootstrap.go
File metadata and controls
32 lines (26 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"fmt"
"github.com/codegangsta/cli"
)
// Bootstrap go the initialization job, and finish by setting the
// `service` global var that will be used by other commands.
func Bootstrap(ctx *cli.Context) error {
return bootstrap(ctx.GlobalString("configuration"), ctx.GlobalString("environment"))
}
func bootstrap(configuration, environment string) error {
cfg, err := Load(configuration)
if err != nil {
return fmt.Errorf("unable to load configuration file: %s", err)
}
env, err := cfg.Env(environment)
if err != nil {
return fmt.Errorf("unable to load requested environment: %s", err)
}
srv, err := NewService(env)
if err != nil {
return fmt.Errorf("unable to initialize the migration service: %s", err)
}
service = srv
return nil
}