handler.go ×4

Frontier kind: Code frontier

unlabeled · c_93801c2bcf32

21 tests · 2502 LOC · 116 files · introduces 0 tests · 141 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
7 ranges141 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
384 ranges2502 lines · 116 files · Browse complete extent
All tests (intent)
21 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

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 native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 141 introduced LOC across 7 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/tools/sql/main.go 122 introduced LOC · 3 ranges

Open complete file

21
22 // root handler for all cli commands
23 > func cliHandler(c *cli.Context, handler func(c *cli.Context, logger log.Logger) error, logger log.Logger) { main.go
24 > quiet := c.GlobalBool(schema.CLIOptQuiet)
25 > err := handler(c, logger)
26 > if err != nil && !quiet {
27 os.Exit(1)
28 }
30
31 // BuildCLIOptions builds the options for cli
32 > func BuildCLIOptions() *cli.App { main.go
33 >
34 > app := cli.NewApp()
35 > app.Name = "temporal-sql-tool"
36 > app.Usage = "Command line tool for temporal sql operations"
37 > app.Version = headers.ServerVersion
38 >
39 > logger := log.NewCLILogger()
40 >
41 > app.Flags = []cli.Flag{
42 > cli.StringFlag{
43 > Name: schema.CLIFlagEndpoint,
44 > Value: environment.GetMySQLAddress(),
45 > Usage: "hostname or ip address of sql host to connect to",
46 > EnvVar: "SQL_HOST",
47 > },
48 > cli.IntFlag{
49 > Name: schema.CLIFlagPort,
50 > Value: environment.GetMySQLPort(),
51 > Usage: "port of sql host to connect to",
52 > EnvVar: "SQL_PORT",
53 > },
54 > cli.StringFlag{
55 > Name: schema.CLIFlagUser,
56 > Value: "",
57 > Usage: "user name used for authentication when connecting to sql host",
58 > EnvVar: "SQL_USER",
59 > },
60 > cli.StringFlag{
61 > Name: schema.CLIFlagPassword,
62 > Value: "",
63 > Usage: "password used for authentication when connecting to sql host",
64 > EnvVar: "SQL_PASSWORD",
65 > },
66 > cli.StringFlag{
67 > Name: schema.CLIFlagDatabase,
68 > Value: "temporal",
69 > Usage: "name of the sql database",
70 > EnvVar: "SQL_DATABASE",
71 > },
72 > cli.StringFlag{
73 > Name: schema.CLIFlagPluginName,
74 > Value: mysql.PluginName,
75 > Usage: "name of the sql plugin",
76 > EnvVar: "SQL_PLUGIN",
77 > },
78 > cli.BoolFlag{
79 > Name: schema.CLIFlagQuiet,
80 > Usage: "Don't set exit status to 1 on error",
81 > },
82 > cli.StringFlag{
83 > Name: schema.CLIFlagConnectAttributes,
84 > Usage: "sql connect attributes",
85 > EnvVar: "SQL_CONNECT_ATTRIBUTES",
86 > },
87 > cli.BoolFlag{
88 > Name: schema.CLIFlagEnableTLS,
89 > Usage: "enable TLS over sql connection",
90 > EnvVar: "SQL_TLS",
91 > },
92 > cli.StringFlag{
93 > Name: schema.CLIFlagTLSCertFile,
94 > Usage: "sql tls client cert path (tls must be enabled)",
95 > EnvVar: "SQL_TLS_CERT_FILE",
96 > },
97 > cli.StringFlag{
98 > Name: schema.CLIFlagTLSKeyFile,
99 > Usage: "sql tls client key path (tls must be enabled)",
100 > EnvVar: "SQL_TLS_KEY_FILE",
101 > },
102 > cli.StringFlag{
103 > Name: schema.CLIFlagTLSCaFile,
104 > Usage: "sql tls client ca file (tls must be enabled)",
105 > EnvVar: "SQL_TLS_CA_FILE",
106 > },
107 > cli.StringFlag{
108 > Name: schema.CLIFlagTLSHostName,
109 > Value: "",
110 > Usage: "override for target server name",
111 > EnvVar: "SQL_TLS_SERVER_NAME",
112 > },
113 > cli.BoolFlag{
114 > Name: schema.CLIFlagTLSDisableHostVerification,
115 > Usage: "disable tls host name verification (tls must be enabled)",
116 > EnvVar: "SQL_TLS_DISABLE_HOST_VERIFICATION",
117 > },
118 > }
119 >
120 > app.Commands = []cli.Command{
121 > {
122 > Name: "setup-schema",
123 > Aliases: []string{"setup"},
124 > Usage: "setup initial version of sql schema",
125 > Flags: []cli.Flag{
126 > cli.StringFlag{
127 > Name: schema.CLIFlagVersion,
128 > Usage: "initial version of the schema, cannot be used with disable-versioning",
129 > },
130 > cli.StringFlag{
131 > Name: schema.CLIFlagSchemaFile,
132 > Usage: "path to the .sql schema file; if un-specified, will just setup versioning tables",
133 > },
134 > cli.StringFlag{
135 > Name: schema.CLIFlagSchemaName,
136 > Usage: fmt.Sprintf("name of embedded schema directory with .sql file, one of: %v",
137 > dbschemas.PathsByDB("sql")),
138 > },
139 > cli.BoolFlag{
140 > Name: schema.CLIFlagDisableVersioning,
141 > Usage: "disable setup of schema versioning",
142 > },
143 > cli.BoolFlag{
144 > Name: schema.CLIFlagOverwrite,
145 > Usage: "drop all existing tables before setting up new schema",
146 > },
147 > },
148 > Action: func(c *cli.Context) {
149 cliHandler(c, setupSchema, logger)
150 },
219 }
220
221 > return app main.go
222 }
go.temporal.io/server/tools/sql/handler.go 19 introduced LOC · 4 ranges

Open complete file

115 }
116
117 > func parseConnectConfig(cli *cli.Context) (*config.SQL, error) { handler.go
118 > cfg := new(config.SQL)
119 >
120 > host := cli.GlobalString(schema.CLIOptEndpoint)
121 > port := cli.GlobalInt(schema.CLIOptPort)
122 > cfg.ConnectAddr = fmt.Sprintf("%s:%v", host, port)
123 > cfg.User = cli.GlobalString(schema.CLIOptUser)
124 > cfg.Password = cli.GlobalString(schema.CLIOptPassword)
125 > cfg.DatabaseName = cli.GlobalString(schema.CLIOptDatabase)
126 > cfg.PluginName = cli.GlobalString(schema.CLIOptPluginName)
127 >
128 > if cfg.ConnectAttributes == nil {
129 > cfg.ConnectAttributes = map[string]string{}
130 > }
131 > connectAttributesQueryString := cli.GlobalString(schema.CLIOptConnectAttributes)
132 > if connectAttributesQueryString != "" {
133 values, err := url.ParseQuery(connectAttributesQueryString)
134 if err != nil {
144 }
145
146 > if cli.GlobalBool(schema.CLIFlagEnableTLS) { handler.go
147 cfg.TLS = &auth.TLS{
148 Enabled: true,
155 }
156
157 > if err := ValidateConnectConfig(cfg); err != nil { handler.go
158 return nil, err
159 }
160
161 > return cfg, nil handler.go
162 }
163