forked from kyma-project/kyma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
66 lines (59 loc) · 2.66 KB
/
options.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"flag"
"fmt"
)
type options struct {
externalAPIPort int
proxyPort int
eventsTargetURL string
remoteEnvironment string
namespace string
requestTimeout int
skipVerify bool
proxyTimeout int
sourceNamespace string
sourceType string
sourceEnvironment string
requestLogging bool
proxyCacheTTL int
}
func parseArgs() *options {
externalAPIPort := flag.Int("externalAPIPort", 8081, "External API port.")
proxyPort := flag.Int("proxyPort", 8080, "Proxy port.")
eventsTargetURL := flag.String("eventsTargetURL", "http://localhost:9001/events", "Target URL for events to be sent.")
remoteEnvironment := flag.String("remoteEnvironment", "default-ec", "Remote environment name for reading and updating services.")
namespace := flag.String("namespace", "kyma-system", "Namespace used by Gateway")
requestTimeout := flag.Int("requestTimeout", 1, "Timeout for services.")
skipVerify := flag.Bool("skipVerify", false, "Flag for skipping certificate verification for proxy target.")
proxyTimeout := flag.Int("proxyTimeout", 10, "Timeout for proxy call.")
requestLogging := flag.Bool("requestLogging", false, "Flag for logging incoming requests.")
proxyCacheTTL := flag.Int("proxyCacheTTL", 120, "TTL, in seconds, for proxy cache of Remote API information")
sourceNamespace := flag.String("sourceNamespace", "local.kyma.commerce", "The organization publishing the event.")
sourceType := flag.String("sourceType", "commerce", "The type of the event source.")
sourceEnvironment := flag.String("sourceEnvironment", "stage", "The name of the event source environment.")
flag.Parse()
return &options{
externalAPIPort: *externalAPIPort,
proxyPort: *proxyPort,
eventsTargetURL: *eventsTargetURL,
remoteEnvironment: *remoteEnvironment,
namespace: *namespace,
requestTimeout: *requestTimeout,
skipVerify: *skipVerify,
proxyTimeout: *proxyTimeout,
requestLogging: *requestLogging,
proxyCacheTTL: *proxyCacheTTL,
sourceNamespace: *sourceNamespace,
sourceType: *sourceType,
sourceEnvironment: *sourceEnvironment,
}
}
func (o *options) String() string {
return fmt.Sprintf("--externalAPIPort=%d --proxyPort=%d --eventsTargetURL=%s"+
" --remoteEnvironment=%s --namespace=%s --requestTimeout=%d --skipVerify=%v --proxyTimeout=%d"+
" --sourceNamespace=%s --sourceType=%s --sourceEnvironment=%s --requestLogging=%t --proxyCacheTTL=%d",
o.externalAPIPort, o.proxyPort, o.eventsTargetURL,
o.remoteEnvironment, o.namespace, o.requestTimeout, o.skipVerify, o.proxyTimeout,
o.sourceNamespace, o.sourceType, o.sourceEnvironment, o.requestLogging, o.proxyCacheTTL)
}