-
Notifications
You must be signed in to change notification settings - Fork 1
/
flags.go
86 lines (81 loc) · 2.21 KB
/
flags.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package start
import (
"fmt"
"os"
"github.com/urfave/cli/v2"
)
const (
HostName = "host"
PortNumber = "port"
AuthIssuer = "auth-issuer"
AuthAudience = "auth-audience"
LogAnalyticsWorkspaceId = "log-analytics-workspace-id"
LogAnalyticsLogTable = "log-analytics-log-table"
RadixAPIHost = "radix-api-host"
RadixAPIPath = "radix-api-path"
RadixAPIScheme = "radix-api-scheme"
)
var flags = []cli.Flag{
&cli.StringFlag{
Name: HostName,
Usage: "Host name/ip",
Value: "",
EnvVars: []string{"LOG_API_HOST"},
},
&cli.IntFlag{
Name: PortNumber,
Usage: "Port number",
Value: 8000,
EnvVars: []string{"LOG_API_PORT"},
},
&cli.StringFlag{
Name: AuthIssuer,
Usage: "OIDC issuer",
Required: true,
EnvVars: []string{"LOG_API_AUTH_ISSUER"},
},
&cli.StringFlag{
Name: AuthAudience,
Usage: "Audience",
Required: true,
EnvVars: []string{"LOG_API_AUTH_AUDIENCE"},
},
&cli.StringFlag{
Name: LogAnalyticsLogTable,
Usage: "Log Analytics workspace table to query. ContainerLogV2, ContainerLog or Both. Defaults to ContainerLog",
Required: true,
EnvVars: []string{"LOG_API_LOG_ANALYTICS_LOG_TABLE"},
},
&cli.StringFlag{
Name: LogAnalyticsWorkspaceId,
Usage: "Log Analytics workspace ID",
Required: true,
EnvVars: []string{"LOG_API_LOG_ANALYTICS_WORKSPACE_ID"},
},
&cli.StringFlag{
Name: RadixAPIHost,
Usage: "Radix API host name",
Value: getRadixAPIHostFromEnv(),
Required: false,
EnvVars: []string{"LOG_API_RADIX_API_HOST"},
},
&cli.StringFlag{
Name: RadixAPIPath,
Usage: "Radix API base path",
Value: "/api/v1",
EnvVars: []string{"LOG_API_RADIX_API_PATH"},
},
&cli.StringFlag{
Name: RadixAPIScheme,
Usage: "Radix API scheme",
Value: "https",
EnvVars: []string{"LOG_API_RADIX_API_SCHEME"},
},
}
func getRadixAPIHostFromEnv() string {
envName, clusterName, dnsZone := os.Getenv("RADIX_ENVIRONMENT"), os.Getenv("RADIX_CLUSTERNAME"), os.Getenv("RADIX_DNS_ZONE")
if len(envName) == 0 || len(clusterName) == 0 || len(dnsZone) == 0 {
return ""
}
return fmt.Sprintf("server-radix-api-%s.%s.%s", envName, clusterName, dnsZone)
}