forked from Symcryptosis/chainlink
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
52 lines (47 loc) · 2.02 KB
/
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
45
46
47
48
49
50
51
52
package main
import (
"os"
"github.com/pkg/errors"
"github.com/smartcontractkit/chainlink/core/cmd"
"github.com/smartcontractkit/chainlink/core/logger"
"github.com/smartcontractkit/chainlink/core/store/models"
"github.com/smartcontractkit/chainlink/core/store/orm"
)
func main() {
Run(NewProductionClient(), os.Args...)
}
// Run runs the CLI, providing further command instructions by default.
func Run(client *cmd.Client, args ...string) {
app := cmd.NewApp(client)
logger.WarnIf(app.Run(args))
}
// NewProductionClient configures an instance of the CLI to be used
// in production.
func NewProductionClient() *cmd.Client {
config := orm.NewConfig()
prompter := cmd.NewTerminalPrompter()
cookieAuth := cmd.NewSessionCookieAuthenticator(config, cmd.DiskCookieStore{Config: config})
sr := models.SessionRequest{}
sessionRequestBuilder := cmd.NewFileSessionRequestBuilder()
if credentialsFile := config.AdminCredentialsFile(); credentialsFile != "" {
var err error
sr, err = sessionRequestBuilder.Build(credentialsFile)
if err != nil && errors.Cause(err) != cmd.ErrNoCredentialFile && !os.IsNotExist(err) {
logger.Fatalw("Error loading API credentials", "error", err, "credentialsFile", credentialsFile)
}
}
return &cmd.Client{
Renderer: cmd.RendererTable{Writer: os.Stdout},
Config: config,
AppFactory: cmd.ChainlinkAppFactory{},
KeyStoreAuthenticator: cmd.TerminalKeyStoreAuthenticator{Prompter: prompter},
FallbackAPIInitializer: cmd.NewPromptingAPIInitializer(prompter),
Runner: cmd.ChainlinkRunner{},
HTTP: cmd.NewAuthenticatedHTTPClient(config, cookieAuth, sr),
CookieAuthenticator: cookieAuth,
FileSessionRequestBuilder: sessionRequestBuilder,
PromptingSessionRequestBuilder: cmd.NewPromptingSessionRequestBuilder(prompter),
ChangePasswordPrompter: cmd.NewChangePasswordPrompter(),
PasswordPrompter: cmd.NewPasswordPrompter(),
}
}