go.temporal.io/server/tools/elasticsearch/main.go

213 LOC · 109 covered · 104 uncovered · 5 ranges · 3 concepts · 3 introducers · 2 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 package elasticsearch
2
3 import (
4 "os"
5
6 "github.com/urfave/cli"
7 "go.temporal.io/server/common/log"
8 commonschema "go.temporal.io/server/tools/common/schema"
9 )
10
11 const (
12 CLIOptVisibilityIndex = "index"
13 CLIOptAWSCredentials = "aws-credentials"
14 CLIOptAWSToken = "aws-session-token"
15 CLIOptFailSilently = "fail"
16 CLIOptSkipClusterSettings = "skip-cluster-settings"
17
18 CLIFlagVisibilityIndex = CLIOptVisibilityIndex + ", i"
19 CLIFlagAWSToken = CLIOptAWSToken
20 CLIFlagAWSCredentials = CLIOptAWSCredentials + ", aws"
21 CLIFlagFailSilently = CLIOptFailSilently
22 CLIFlagSkipClusterSettings = CLIOptSkipClusterSettings
23 )
24
25 // RunTool runs the temporal-elasticsearch-tool command line tool
26 func RunTool(args []string) error {
27 app := BuildCLIOptions()
28 return app.Run(args)
29 }
30
31 var osExit = os.Exit
32
33 // root handler for all cli commands
34 > func cliHandler(c *cli.Context, handler func(c *cli.Context, logger log.Logger) error, logger log.Logger) { client_v7.go ×10
35 > quiet := c.GlobalBool(commonschema.CLIOptQuiet)
36 > err := handler(c, logger)
37 > if err != nil && !quiet {
38 > osExit(1)
39 > }
40 }
41
42 // BuildCLIOptions builds the options for cli
43 > func BuildCLIOptions() *cli.App { client_v7.go ×10
44 >
45 > app := cli.NewApp()
46 > app.Name = "temporal-elasticsearch-tool"
47 > app.Usage = "Command line tool for temporal elasticsearch operations (EXPERIMENTAL)"
48 > app.Version = "0.0.1"
49 >
50 > logger := log.NewCLILogger()
51 >
52 > app.Flags = []cli.Flag{
53 > cli.StringFlag{
54 > Name: commonschema.CLIFlagEndpoint,
55 > Value: "http://127.0.0.1:9200",
56 > Usage: "hostname or ip address of elasticsearch server",
57 > EnvVar: "ES_SERVER",
58 > },
59 > cli.StringFlag{
60 > Name: commonschema.CLIFlagUser,
61 > Value: "",
62 > Usage: "username for elasticsearch or aws_access_key_id if using static aws credentials",
63 > EnvVar: "ES_USER",
64 > },
65 > cli.StringFlag{
66 > Name: commonschema.CLIFlagPassword,
67 > Value: "",
68 > Usage: "password for elasticsearch or aws_secret_access_key if using static aws credentials",
69 > EnvVar: "ES_PWD",
70 > },
71 > cli.StringFlag{
72 > Name: CLIFlagAWSCredentials,
73 > Value: "",
74 > Usage: "AWS credentials provider (supported ['static', 'environment', 'aws-sdk-default'])",
75 > EnvVar: "AWS_CREDENTIALS",
76 > },
77 > cli.StringFlag{
78 > Name: CLIFlagAWSToken,
79 > Value: "",
80 > Usage: "AWS sessiontoken for use with 'static' AWS credentials provider",
81 > EnvVar: "AWS_SESSION_TOKEN",
82 > },
83 > cli.BoolFlag{
84 > Name: commonschema.CLIOptQuiet,
85 > Usage: "don't log errors to stderr",
86 > },
87 > cli.BoolFlag{
88 > Name: commonschema.CLIFlagEnableTLS,
89 > Usage: "enable TLS for elasticsearch connection",
90 > EnvVar: "ES_TLS",
91 > },
92 > cli.StringFlag{
93 > Name: commonschema.CLIFlagTLSCertFile,
94 > Value: "",
95 > Usage: "path to TLS certificate file (tls must be enabled)",
96 > EnvVar: "ES_TLS_CERT_FILE",
97 > },
98 > cli.StringFlag{
99 > Name: commonschema.CLIFlagTLSKeyFile,
100 > Value: "",
101 > Usage: "path to TLS key file (tls must be enabled)",
102 > EnvVar: "ES_TLS_KEY_FILE",
103 > },
104 > cli.StringFlag{
105 > Name: commonschema.CLIFlagTLSCaFile,
106 > Value: "",
107 > Usage: "path to TLS CA certificate file (tls must be enabled)",
108 > EnvVar: "ES_TLS_CA_FILE",
109 > },
110 > cli.BoolFlag{
111 > Name: commonschema.CLIFlagTLSDisableHostVerification,
112 > Usage: "disable TLS host name verification (tls must be enabled)",
113 > EnvVar: "ES_TLS_DISABLE_HOST_VERIFICATION",
114 > },
115 > cli.StringFlag{
116 > Name: commonschema.CLIFlagTLSHostName,
117 > Value: "",
118 > Usage: "TLS server name for host name verification (tls must be enabled)",
119 > EnvVar: "ES_TLS_SERVER_NAME",
120 > },
121 > }
122 >
123 > app.Commands = []cli.Command{
124 > {
125 > Name: "setup-schema",
126 > Usage: "setup elasticsearch cluster settings and index template",
127 > Flags: []cli.Flag{
128 > cli.BoolFlag{
129 > Name: CLIFlagFailSilently,
130 > Usage: "fail silently on HTTP errors",
131 > },
132 > cli.BoolFlag{
133 > Name: CLIFlagSkipClusterSettings,
134 > Usage: "skip setting up cluster settings",
135 > },
136 > },
137 > Action: func(c *cli.Context) error {
138 > cliHandler(c, setupSchema, logger) handler.go ×4
139 > return nil
140 > },
141 },
142 {
143 Name: "update-schema",
144 Usage: "update elasticsearch index template, and index mappings if --index is specified",
145 Flags: []cli.Flag{
146 cli.StringFlag{
147 Name: CLIFlagVisibilityIndex,
148 Usage: "name of the visibility index to update mappings for (optional)",
149 EnvVar: "ES_VISIBILITY_INDEX",
150 },
151 cli.BoolFlag{
152 Name: CLIFlagFailSilently,
153 Usage: "fail silently on HTTP errors",
154 },
155 },
156 Action: func(c *cli.Context) error {
157 cliHandler(c, updateSchema, logger)
158 return nil
159 },
160 },
161 {
162 Name: "create-index",
163 Usage: "create elasticsearch visibility index",
164 Flags: []cli.Flag{
165 cli.StringFlag{
166 Name: CLIFlagVisibilityIndex,
167 Usage: "name of the visibility index to create",
168 Required: true,
169 EnvVar: "ES_VISIBILITY_INDEX",
170 },
171 cli.BoolFlag{
172 Name: CLIFlagFailSilently,
173 Usage: "fail silently on HTTP errors",
174 },
175 },
176 Action: func(c *cli.Context) error {
177 cliHandler(c, createIndex, logger)
178 return nil
179 },
180 },
181 {
182 Name: "drop-index",
183 Usage: "delete elasticsearch visibility index",
184 Flags: []cli.Flag{
185 cli.StringFlag{
186 Name: CLIFlagVisibilityIndex,
187 Usage: "name of the visibility index to delete",
188 Required: true,
189 EnvVar: "ES_VISIBILITY_INDEX",
190 },
191 cli.BoolFlag{
192 Name: CLIFlagFailSilently,
193 Usage: "fail silently on HTTP errors",
194 },
195 },
196 Action: func(c *cli.Context) error {
197 cliHandler(c, dropIndex, logger)
198 return nil
199 },
200 },
201 {
202 Name: "ping",
203 Usage: "pings the elasticsearch host",
204 Flags: []cli.Flag{},
205 > Action: func(c *cli.Context) error { handler.go ×2
206 > cliHandler(c, ping, logger)
207 > return nil
208 > },
209 },
210 }
211
212 > return app client_v7.go ×10
213 }