forked from kyma-project/kyma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
executable file
·71 lines (62 loc) · 2.53 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
67
68
69
70
71
package main
import (
"flag"
"fmt"
"os"
)
type options struct {
appName string
externalAPIPort int
internalAPIPort int
namespace string
tokenLength int
tokenExpirationMinutes int
domainName string
connectorServiceHost string
}
type environment struct {
country string
organization string
organizationalUnit string
locality string
province string
}
func parseArgs() *options {
appName := flag.String("appName", "connector-service", "Name of the Certificate Service, used by k8s deployments and services.")
externalAPIPort := flag.Int("externalAPIPort", 8081, "External API port.")
internalAPIPort := flag.Int("internalAPIPort", 8080, "Internal API port.")
namespace := flag.String("namespace", "kyma-integration", "Namespace used by Certificate Service")
tokenLength := flag.Int("tokenLength", 64, "Length of a registration tokens.")
tokenExpirationMinutes := flag.Int("tokenExpirationMinutes", 60, "Time to Live of tokens expressed in minutes.")
domainName := flag.String("domainName", ".wormhole.cluster.kyma.cx", "Domain name used for URL generation.")
connectorServiceHost := flag.String("connectorServiceHost", "cert-service.wormhole.cluster.kyma.cx", "Host at which this service is accessible.")
flag.Parse()
return &options{
appName: *appName,
externalAPIPort: *externalAPIPort,
internalAPIPort: *internalAPIPort,
namespace: *namespace,
tokenLength: *tokenLength,
tokenExpirationMinutes: *tokenExpirationMinutes,
domainName: *domainName,
connectorServiceHost: *connectorServiceHost,
}
}
func (o *options) String() string {
return fmt.Sprintf("--appName=%s --externalAPIPort=%d --internalAPIPort=%d --namespace=%s --tokenLength=%d "+
"--tokenExpirationMinutes=%d --domainName=%s --connectorServiceHost=%s", o.appName, o.externalAPIPort,
o.internalAPIPort, o.namespace, o.tokenLength, o.tokenExpirationMinutes, o.domainName, o.connectorServiceHost)
}
func parseEnv() *environment {
return &environment{
country: os.Getenv("COUNTRY"),
organization: os.Getenv("ORGANIZATION"),
organizationalUnit: os.Getenv("ORGANIZATIONALUNIT"),
locality: os.Getenv("LOCALITY"),
province: os.Getenv("PROVINCE"),
}
}
func (e *environment) String() string {
return fmt.Sprintf("COUNTRY=%s ORGANIZATION=%s ORGANIZATIONALUNIT=%s LOCALITY=%s PROVINCE=%s",
e.country, e.organization, e.organizationalUnit, e.locality, e.province)
}