Skip to content

Commit b680fa3

Browse files
authored
config, api: rename configs and command arguments for traffic replay (#739)
1 parent acbb0eb commit b680fa3

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

lib/cli/traffic.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func GetTrafficCaptureCmd(ctx *Context) *cobra.Command {
2929
}
3030
output := captureCmd.PersistentFlags().String("output", "", "output directory for traffic files")
3131
duration := captureCmd.PersistentFlags().String("duration", "", "the duration of traffic capture")
32-
encrypt := captureCmd.PersistentFlags().String("encrypt-method", "", "the encryption method used for encrypting traffic files")
32+
encrypt := captureCmd.PersistentFlags().String("encryption-method", "", "the encryption method used for encrypting traffic files")
3333
compress := captureCmd.PersistentFlags().Bool("compress", true, "whether compress the traffic files")
3434
captureCmd.RunE = func(cmd *cobra.Command, args []string) error {
3535
reader := GetFormReader(map[string]string{
@@ -58,7 +58,7 @@ func GetTrafficReplayCmd(ctx *Context) *cobra.Command {
5858
speed := replayCmd.PersistentFlags().Float64("speed", 1, "replay speed")
5959
username := replayCmd.PersistentFlags().String("username", "", "the username to connect to TiDB for replay")
6060
password := replayCmd.PersistentFlags().String("password", "", "the password to connect to TiDB for replay")
61-
readonly := replayCmd.PersistentFlags().Bool("readonly", false, "only replay read-only queries, default is false")
61+
readonly := replayCmd.PersistentFlags().Bool("read-only", false, "only replay read-only queries, default is false")
6262
replayCmd.RunE = func(cmd *cobra.Command, args []string) error {
6363
reader := GetFormReader(map[string]string{
6464
"input": *input,

lib/config/security.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,10 @@ func (c TLSConfig) HasCA() bool {
2424
}
2525

2626
type Security struct {
27-
ServerSQLTLS TLSConfig `yaml:"server-tls,omitempty" toml:"server-tls,omitempty" json:"server-tls,omitempty"`
28-
ServerHTTPTLS TLSConfig `yaml:"server-http-tls,omitempty" toml:"server-http-tls,omitempty" json:"server-http-tls,omitempty"`
29-
ClusterTLS TLSConfig `yaml:"cluster-tls,omitempty" toml:"cluster-tls,omitempty" json:"cluster-tls,omitempty"`
30-
SQLTLS TLSConfig `yaml:"sql-tls,omitempty" toml:"sql-tls,omitempty" json:"sql-tls,omitempty"`
31-
Encryption Encryption `yaml:"encryption,omitempty" toml:"encryption,omitempty" json:"encryption,omitempty"`
32-
RequireBackendTLS bool `yaml:"require-backend-tls,omitempty" toml:"require-backend-tls,omitempty" json:"require-backend-tls,omitempty"`
33-
}
34-
35-
type Encryption struct {
36-
KeyPath string `yaml:"key-path,omitempty" toml:"key-path,omitempty" json:"key-path,omitempty"`
27+
ServerSQLTLS TLSConfig `yaml:"server-tls,omitempty" toml:"server-tls,omitempty" json:"server-tls,omitempty"`
28+
ServerHTTPTLS TLSConfig `yaml:"server-http-tls,omitempty" toml:"server-http-tls,omitempty" json:"server-http-tls,omitempty"`
29+
ClusterTLS TLSConfig `yaml:"cluster-tls,omitempty" toml:"cluster-tls,omitempty" json:"cluster-tls,omitempty"`
30+
SQLTLS TLSConfig `yaml:"sql-tls,omitempty" toml:"sql-tls,omitempty" json:"sql-tls,omitempty"`
31+
EncryptionKeyPath string `yaml:"encryption-key-path,omitempty" toml:"encryption-key-path,omitempty" json:"encryption-key-path,omitempty"`
32+
RequireBackendTLS bool `yaml:"require-backend-tls,omitempty" toml:"require-backend-tls,omitempty" json:"require-backend-tls,omitempty"`
3733
}

pkg/server/api/traffic.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (h *Server) TrafficCapture(c *gin.Context) {
5050
}
5151
}
5252
cfg.Compress = compress
53-
cfg.KeyFile = globalCfg.Security.Encryption.KeyPath
53+
cfg.KeyFile = globalCfg.Security.EncryptionKeyPath
5454
if startTimeStr := c.PostForm("start-time"); startTimeStr != "" {
5555
startTime, err := time.Parse(time.RFC3339, startTimeStr)
5656
if err != nil {
@@ -99,7 +99,7 @@ func (h *Server) TrafficReplay(c *gin.Context) {
9999
cfg.Username = c.PostForm("username")
100100
cfg.Password = c.PostForm("password")
101101
cfg.ReadOnly = strings.EqualFold(c.PostForm("readonly"), "true")
102-
cfg.KeyFile = globalCfg.Security.Encryption.KeyPath
102+
cfg.KeyFile = globalCfg.Security.EncryptionKeyPath
103103

104104
if err := h.mgr.ReplayJobMgr.StartReplay(cfg); err != nil {
105105
c.String(http.StatusInternalServerError, err.Error())

0 commit comments

Comments
 (0)