-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
44 lines (36 loc) · 927 Bytes
/
main.go
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
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2020 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package main
import (
"os"
corecmd "github.com/juju/cmd/v3"
"github.com/juju/loggo"
"github.com/juju/juju-restore/backup"
"github.com/juju/juju-restore/cmd"
"github.com/juju/juju-restore/db"
"github.com/juju/juju-restore/machine"
)
var logger = loggo.GetLogger("juju-restore")
func main() {
_, err := loggo.ReplaceDefaultWriter(NewColorWriter(os.Stderr))
if err != nil {
panic(err)
}
os.Exit(Run(os.Args))
}
// Run creates and runs the restore command.
func Run(args []string) int {
ctx, err := corecmd.DefaultContext()
if err != nil {
logger.Errorf("%v", err)
return 2
}
restorer := cmd.NewRestoreCommand(
db.Dial,
backup.Open,
machine.ControllerNodeForReplicaSetMember,
cmd.ReadCredsFromAgentConf,
os.Getenv("JUJU_RESTORE_DEV_MODE") == "on",
)
return corecmd.Main(restorer, ctx, args[1:])
}