/
options.go
62 lines (56 loc) · 2.82 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
package main
import (
"flag"
"fmt"
)
type options struct {
externalAPIPort int
proxyPort int
minioURL string
namespace string
requestTimeout int
requestLogging bool
specRequestTimeout int
rafterRequestTimeout int
detailedErrorResponse bool
uploadServiceURL string
centralGatewayUrl string
insecureAssetDownload bool
insecureSpecDownload bool
}
func parseArgs() *options {
externalAPIPort := flag.Int("externalAPIPort", 8081, "External API port.")
proxyPort := flag.Int("proxyPort", 8080, "Proxy port.")
namespace := flag.String("namespace", "kyma-integration", "Namespace used by Application Registry")
requestTimeout := flag.Int("requestTimeout", 1, "Timeout for services.")
requestLogging := flag.Bool("requestLogging", false, "Flag for logging incoming requests.")
specRequestTimeout := flag.Int("specRequestTimeout", 20, "Timeout for Spec Service.")
rafterRequestTimeout := flag.Int("rafterRequestTimeout", 20, "Timeout for Rafter Service.")
detailedErrorResponse := flag.Bool("detailedErrorResponse", false, "Flag for showing full internal error response messages.")
uploadServiceURL := flag.String("uploadServiceURL", "http://rafter-upload-service.kyma-system.svc.cluster.local:80", "Upload Service URL.")
centralGatewayUrl := flag.String("centralGatewayUrl", "http://central-application-gateway.kyma-system:8080", "Central Application Gateway URL.")
insecureAssetDownload := flag.Bool("insecureAssetDownload", false, "Flag for skipping certificate verification for asset download.")
insecureSpecDownload := flag.Bool("insecureSpecDownload", false, "Flag for skipping certificate verification for API specification download.")
flag.Parse()
return &options{
externalAPIPort: *externalAPIPort,
proxyPort: *proxyPort,
namespace: *namespace,
requestTimeout: *requestTimeout,
requestLogging: *requestLogging,
specRequestTimeout: *specRequestTimeout,
rafterRequestTimeout: *rafterRequestTimeout,
detailedErrorResponse: *detailedErrorResponse,
uploadServiceURL: *uploadServiceURL,
centralGatewayUrl: *centralGatewayUrl,
insecureAssetDownload: *insecureAssetDownload,
insecureSpecDownload: *insecureSpecDownload,
}
}
func (o *options) String() string {
return fmt.Sprintf("--externalAPIPort=%d --proxyPort=%d --uploadServiceURL=%s --centralGatewayUrl=%s "+
"--namespace=%s --requestTimeout=%d --requestLogging=%t --specRequestTimeout=%d "+
"--rafterRequestTimeout=%d --detailedErrorResponse=%t --insecureAssetDownload=%t --insecureSpecDownload=%t",
o.externalAPIPort, o.proxyPort, o.uploadServiceURL, o.centralGatewayUrl,
o.namespace, o.requestTimeout, o.requestLogging, o.specRequestTimeout, o.rafterRequestTimeout, o.detailedErrorResponse, o.insecureAssetDownload, o.insecureSpecDownload)
}