Skip to content

Commit

Permalink
Generate empty config with comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mugli committed Aug 11, 2019
1 parent 6e61304 commit 6938d1b
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
23 changes: 23 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@


[MySQL]
mysql_host = ""
mysql_port = 3306
mysql_username = ""
mysql_password = ""

# hosted_in_aws_rds: Optional.
#
# Uses "CALL mysql.rds_kill()" instead of "kill" command.
# Useful in RDS databases or replica where
# "mysql_username" may not have privilege to use "kill"
hosted_in_aws_rds = false

# db: Optional.
#
# If provided, filter out long running
# queries from other databases
db = ""

[ssh_tunnel]
Expand All @@ -12,8 +25,18 @@
ssh_port = 22
ssh_username = ""
ssh_password = ""

# ssh_private_key takes priority over ssh_password
# if both are provided
ssh_private_key = ""

# ssh_key_passphrase: Optional.
ssh_key_passphrase = ""

[long_running_query]
# Default is 10 seconds.
# kill-mysql-query will only list running queries
# those are being executed for more than or equal to
# this value.
timeout_second = 10

4 changes: 2 additions & 2 deletions configuration/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ func Generate(file string) error {
}
}

config := setDefault()
f, err := os.Create(filePath)
defer f.Close()
if err != nil {
return err
}

if err := toml.NewEncoder(f).Encode(config); err != nil {
_, err = f.WriteString(baseConfig)
if err != nil {
return err
}

Expand Down
45 changes: 45 additions & 0 deletions configuration/template.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package configuration

var baseConfig =`
[MySQL]
mysql_host = ""
mysql_port = 3306
mysql_username = ""
mysql_password = ""
# hosted_in_aws_rds: Optional.
#
# Uses "CALL mysql.rds_kill()" instead of "kill" command.
# Useful in RDS databases or replica where
# "mysql_username" may not have privilege to use "kill"
hosted_in_aws_rds = false
# db: Optional.
#
# If provided, filter out long running
# queries from other databases
db = ""
[ssh_tunnel]
use_ssh_tunnel = false
ssh_host = ""
ssh_port = 22
ssh_username = ""
ssh_password = ""
# ssh_private_key takes priority over ssh_password
# if both are provided
ssh_private_key = ""
# ssh_key_passphrase: Optional.
ssh_key_passphrase = ""
[long_running_query]
# Default is 10 seconds.
# kill-mysql-query will only list running queries
# those are being executed for more than or equal to
# this value.
timeout_second = 10
`

0 comments on commit 6938d1b

Please sign in to comment.