-
Notifications
You must be signed in to change notification settings - Fork 6
/
local.go
45 lines (36 loc) · 1.33 KB
/
local.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
// SPDX-License-Identifier: ice License 1.0
package main
import (
"flag"
"github.com/ice-blockchain/santa/tasks/fixture"
"github.com/ice-blockchain/santa/tasks/seeding"
serverauthfixture "github.com/ice-blockchain/wintr/auth/fixture"
"github.com/ice-blockchain/wintr/log"
)
//nolint:gochecknoglobals // Because those are flags
var (
generateAuth = flag.String("generateAuth", "", "generate a new auth for a random user, with the specified role")
startSeeding = flag.Bool("startSeeding", false, "whether to start seeding a remote database or not")
startLocalType = flag.String("type", "all", "the strategy to use to spin up the local environment")
)
func main() {
flag.Parse()
if generateAuth != nil && *generateAuth != "" {
userID, token := testingAuthorization(*generateAuth)
log.Info("UserID")
log.Info("=================================================================================")
log.Info(userID)
log.Info("Authorization Bearer Token")
log.Info("=================================================================================")
log.Info(token)
return
}
if *startSeeding {
seeding.StartSeeding()
return
}
fixture.StartLocalTestEnvironment(fixture.StartLocalTestEnvironmentType(*startLocalType))
}
func testingAuthorization(role string) (userID, token string) {
return serverauthfixture.CreateUser(role)
}