@@ -34,15 +34,15 @@ var all = &struct { //nolint:gochecknoglobals // Config is global anyway.
34
34
MySQLAuthLogin appcfg.NotEmptyString `env:"MYSQL_AUTH_LOGIN"`
35
35
MySQLAuthPass appcfg.String `env:"MYSQL_AUTH_PASS"`
36
36
MySQLDBName appcfg.NotEmptyString `env:"MYSQL_DB"`
37
- MySQLGooseDir appcfg.NotEmptyString
37
+ GooseMySQLDir appcfg.NotEmptyString
38
38
}{ // Defaults, if any:
39
39
AddrHost : appcfg .MustNotEmptyString (def .Hostname ),
40
40
AddrPort : appcfg .MustPort ("8000" ),
41
41
MetricsAddrPort : appcfg .MustPort ("9000" ),
42
42
MySQLAddrPort : appcfg .MustPort ("3306" ),
43
43
MySQLAuthLogin : appcfg .MustNotEmptyString (def .ProgName ),
44
44
MySQLDBName : appcfg .MustNotEmptyString (def .ProgName ),
45
- MySQLGooseDir : appcfg .MustNotEmptyString ("internal/migrations/mysql" ),
45
+ GooseMySQLDir : appcfg .MustNotEmptyString ("internal/migrations/mysql" ),
46
46
}
47
47
48
48
// FlagSets for all CLI subcommands which use flags to set config values.
@@ -65,31 +65,31 @@ func Init(flagsets FlagSets) error {
65
65
return err
66
66
}
67
67
68
- appcfg .AddPFlag (fs .Serve , & all .AddrHost , "host" , "host to serve OpenAPI" )
69
- appcfg .AddPFlag (fs .Serve , & all .AddrPort , "port" , "port to serve OpenAPI" )
70
- appcfg .AddPFlag (fs .Serve , & all .MetricsAddrPort , "metrics.port" , "port to serve Prometheus metrics" )
71
- appcfg .AddPFlag (fs .Serve , & all .MySQLAddrHost , "mysql.host" , "host to connect to MySQL" )
72
- appcfg .AddPFlag (fs .Serve , & all .MySQLAddrPort , "mysql.port" , "port to connect to MySQL" )
73
- appcfg .AddPFlag (fs .Serve , & all .MySQLAuthLogin , "mysql.user" , "MySQL username" )
74
- appcfg .AddPFlag (fs .Serve , & all .MySQLAuthPass , "mysql.pass" , "MySQL password" )
75
- appcfg .AddPFlag (fs .Serve , & all .MySQLDBName , "mysql.dbname" , "MySQL database name" )
76
-
77
68
appcfg .AddPFlag (fs .GooseMySQL , & all .MySQLAddrHost , "mysql.host" , "host to connect to MySQL" )
78
69
appcfg .AddPFlag (fs .GooseMySQL , & all .MySQLAddrPort , "mysql.port" , "port to connect to MySQL" )
70
+ appcfg .AddPFlag (fs .GooseMySQL , & all .MySQLDBName , "mysql.dbname" , "MySQL database name" )
79
71
appcfg .AddPFlag (fs .GooseMySQL , & all .MySQLAuthLogin , "mysql.user" , "MySQL username" )
80
72
appcfg .AddPFlag (fs .GooseMySQL , & all .MySQLAuthPass , "mysql.pass" , "MySQL password" )
81
- appcfg .AddPFlag (fs .GooseMySQL , & all .MySQLDBName , "mysql.dbname" , "MySQL database name" )
73
+
74
+ appcfg .AddPFlag (fs .Serve , & all .MySQLAddrHost , "mysql.host" , "host to connect to MySQL" )
75
+ appcfg .AddPFlag (fs .Serve , & all .MySQLAddrPort , "mysql.port" , "port to connect to MySQL" )
76
+ appcfg .AddPFlag (fs .Serve , & all .MySQLDBName , "mysql.dbname" , "MySQL database name" )
77
+ appcfg .AddPFlag (fs .Serve , & all .MySQLAuthLogin , "mysql.user" , "MySQL username" )
78
+ appcfg .AddPFlag (fs .Serve , & all .MySQLAuthPass , "mysql.pass" , "MySQL password" )
79
+ appcfg .AddPFlag (fs .Serve , & all .AddrHost , "host" , "host to serve OpenAPI" )
80
+ appcfg .AddPFlag (fs .Serve , & all .AddrPort , "port" , "port to serve OpenAPI" )
81
+ appcfg .AddPFlag (fs .Serve , & all .MetricsAddrPort , "metrics.port" , "port to serve Prometheus metrics" )
82
82
83
83
return nil
84
84
}
85
85
86
86
// ServeConfig contains configuration for subcommand.
87
87
type ServeConfig struct {
88
- MySQL * mysql.Config
89
- MySQLGooseDir string
90
- Addr netx.Addr
91
- MetricsAddr netx.Addr
92
- APIKeyAdmin string
88
+ MySQL * mysql.Config
89
+ GooseMySQLDir string
90
+ BindAddr netx.Addr
91
+ BindMetricsAddr netx.Addr
92
+ APIKeyAdmin string
93
93
}
94
94
95
95
// GetServe validates and returns configuration for subcommand.
@@ -98,15 +98,15 @@ func GetServe() (c *ServeConfig, err error) {
98
98
99
99
c = & ServeConfig {
100
100
MySQL : def .NewMySQLConfig (def.MySQLConfig {
101
- Addr : netx .NewAddr (all .MySQLAddrHost .Value (& err ), all .MySQLAddrPort .Value (& err )),
102
- User : all .MySQLAuthLogin .Value (& err ),
103
- Pass : all .MySQLAuthPass .Value (& err ),
104
- DB : all .MySQLDBName .Value (& err ),
101
+ Addr : netx .NewAddr (all .MySQLAddrHost .Value (& err ), all .MySQLAddrPort .Value (& err )),
102
+ DBName : all .MySQLDBName .Value (& err ),
103
+ User : all .MySQLAuthLogin .Value (& err ),
104
+ Pass : all .MySQLAuthPass .Value (& err ),
105
105
}),
106
- MySQLGooseDir : all .MySQLGooseDir .Value (& err ),
107
- Addr : netx .NewAddr (all .AddrHost .Value (& err ), all .AddrPort .Value (& err )),
108
- MetricsAddr : netx .NewAddr (all .AddrHost .Value (& err ), all .MetricsAddrPort .Value (& err )),
109
- APIKeyAdmin : all .APIKeyAdmin .Value (& err ),
106
+ GooseMySQLDir : all .GooseMySQLDir .Value (& err ),
107
+ BindAddr : netx .NewAddr (all .AddrHost .Value (& err ), all .AddrPort .Value (& err )),
108
+ BindMetricsAddr : netx .NewAddr (all .AddrHost .Value (& err ), all .MetricsAddrPort .Value (& err )),
109
+ APIKeyAdmin : all .APIKeyAdmin .Value (& err ),
110
110
}
111
111
if err != nil {
112
112
return nil , appcfg .WrapPErr (err , fs .Serve , all )
@@ -119,12 +119,12 @@ func GetGooseMySQL() (c *cobrax.GooseMySQLConfig, err error) {
119
119
120
120
c = & cobrax.GooseMySQLConfig {
121
121
MySQL : def .NewMySQLConfig (def.MySQLConfig {
122
- Addr : netx .NewAddr (all .MySQLAddrHost .Value (& err ), all .MySQLAddrPort .Value (& err )),
123
- User : all .MySQLAuthLogin .Value (& err ),
124
- Pass : all .MySQLAuthPass .Value (& err ),
125
- DB : all .MySQLDBName .Value (& err ),
122
+ Addr : netx .NewAddr (all .MySQLAddrHost .Value (& err ), all .MySQLAddrPort .Value (& err )),
123
+ DBName : all .MySQLDBName .Value (& err ),
124
+ User : all .MySQLAuthLogin .Value (& err ),
125
+ Pass : all .MySQLAuthPass .Value (& err ),
126
126
}),
127
- MySQLGooseDir : all .MySQLGooseDir .Value (& err ),
127
+ GooseMySQLDir : all .GooseMySQLDir .Value (& err ),
128
128
}
129
129
if err != nil {
130
130
return nil , appcfg .WrapPErr (err , fs .GooseMySQL , all )
0 commit comments