mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
server/embed: address golangci var-naming issues
Addresses issues in ListenPeerUrls, ListenClientUrls, ListenClientHttpUrls, AdvertisePeerUrls, AdvertiseClientUrls. Signed-off-by: Ivan Valdes <ivan@vald.es>
This commit is contained in:
parent
e246bb8d4d
commit
2e5188f618
@ -216,12 +216,15 @@ type Config struct {
|
||||
// streams that each client can open at a time.
|
||||
MaxConcurrentStreams uint32 `json:"max-concurrent-streams"`
|
||||
|
||||
//revive:disable:var-naming
|
||||
ListenPeerUrls, ListenClientUrls, ListenClientHttpUrls []url.URL
|
||||
AdvertisePeerUrls, AdvertiseClientUrls []url.URL
|
||||
ClientTLSInfo transport.TLSInfo
|
||||
ClientAutoTLS bool
|
||||
PeerTLSInfo transport.TLSInfo
|
||||
PeerAutoTLS bool
|
||||
//revive:enable:var-naming
|
||||
|
||||
ClientTLSInfo transport.TLSInfo
|
||||
ClientAutoTLS bool
|
||||
PeerTLSInfo transport.TLSInfo
|
||||
PeerAutoTLS bool
|
||||
// SelfSignedCertValidity specifies the validity period of the client and peer certificates
|
||||
// that are automatically generated by etcd when you specify ClientAutoTLS and PeerAutoTLS,
|
||||
// the unit is year, and the default is 1
|
||||
@ -449,11 +452,11 @@ type configYAML struct {
|
||||
|
||||
// configJSON has file options that are translated into Config options
|
||||
type configJSON struct {
|
||||
ListenPeerUrls string `json:"listen-peer-urls"`
|
||||
ListenClientUrls string `json:"listen-client-urls"`
|
||||
ListenClientHttpUrls string `json:"listen-client-http-urls"`
|
||||
AdvertisePeerUrls string `json:"initial-advertise-peer-urls"`
|
||||
AdvertiseClientUrls string `json:"advertise-client-urls"`
|
||||
ListenPeerURLs string `json:"listen-peer-urls"`
|
||||
ListenClientURLs string `json:"listen-client-urls"`
|
||||
ListenClientHTTPURLs string `json:"listen-client-http-urls"`
|
||||
AdvertisePeerURLs string `json:"initial-advertise-peer-urls"`
|
||||
AdvertiseClientURLs string `json:"advertise-client-urls"`
|
||||
|
||||
CORSJSON string `json:"cors"`
|
||||
HostWhitelistJSON string `json:"host-whitelist"`
|
||||
@ -765,8 +768,8 @@ func (cfg *configYAML) configFromFile(path string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if cfg.configJSON.ListenPeerUrls != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.configJSON.ListenPeerUrls, ","))
|
||||
if cfg.configJSON.ListenPeerURLs != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.configJSON.ListenPeerURLs, ","))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "unexpected error setting up listen-peer-urls: %v\n", err)
|
||||
os.Exit(1)
|
||||
@ -774,8 +777,8 @@ func (cfg *configYAML) configFromFile(path string) error {
|
||||
cfg.Config.ListenPeerUrls = u
|
||||
}
|
||||
|
||||
if cfg.configJSON.ListenClientUrls != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.configJSON.ListenClientUrls, ","))
|
||||
if cfg.configJSON.ListenClientURLs != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.configJSON.ListenClientURLs, ","))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "unexpected error setting up listen-client-urls: %v\n", err)
|
||||
os.Exit(1)
|
||||
@ -783,8 +786,8 @@ func (cfg *configYAML) configFromFile(path string) error {
|
||||
cfg.Config.ListenClientUrls = u
|
||||
}
|
||||
|
||||
if cfg.configJSON.ListenClientHttpUrls != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.configJSON.ListenClientHttpUrls, ","))
|
||||
if cfg.configJSON.ListenClientHTTPURLs != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.configJSON.ListenClientHTTPURLs, ","))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "unexpected error setting up listen-client-http-urls: %v\n", err)
|
||||
os.Exit(1)
|
||||
@ -792,8 +795,8 @@ func (cfg *configYAML) configFromFile(path string) error {
|
||||
cfg.Config.ListenClientHttpUrls = u
|
||||
}
|
||||
|
||||
if cfg.configJSON.AdvertisePeerUrls != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.configJSON.AdvertisePeerUrls, ","))
|
||||
if cfg.configJSON.AdvertisePeerURLs != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.configJSON.AdvertisePeerURLs, ","))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "unexpected error setting up initial-advertise-peer-urls: %v\n", err)
|
||||
os.Exit(1)
|
||||
@ -801,8 +804,8 @@ func (cfg *configYAML) configFromFile(path string) error {
|
||||
cfg.Config.AdvertisePeerUrls = u
|
||||
}
|
||||
|
||||
if cfg.configJSON.AdvertiseClientUrls != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.configJSON.AdvertiseClientUrls, ","))
|
||||
if cfg.configJSON.AdvertiseClientURLs != "" {
|
||||
u, err := types.NewURLs(strings.Split(cfg.configJSON.AdvertiseClientURLs, ","))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "unexpected error setting up advertise-peer-urls: %v\n", err)
|
||||
os.Exit(1)
|
||||
@ -901,11 +904,11 @@ func (cfg *Config) Validate() error {
|
||||
return err
|
||||
}
|
||||
if err := checkHostURLs(cfg.AdvertisePeerUrls); err != nil {
|
||||
addrs := cfg.getAdvertisePeerUrls()
|
||||
addrs := cfg.getAdvertisePeerURLs()
|
||||
return fmt.Errorf(`--initial-advertise-peer-urls %q must be "host:port" (%v)`, strings.Join(addrs, ","), err)
|
||||
}
|
||||
if err := checkHostURLs(cfg.AdvertiseClientUrls); err != nil {
|
||||
addrs := cfg.getAdvertiseClientUrls()
|
||||
addrs := cfg.getAdvertiseClientURLs()
|
||||
return fmt.Errorf(`--advertise-client-urls %q must be "host:port" (%v)`, strings.Join(addrs, ","), err)
|
||||
}
|
||||
// Check if conflicting flags are passed.
|
||||
@ -1104,7 +1107,7 @@ func (cfg *Config) GetDNSClusterNames() ([]string, error) {
|
||||
zap.String("service-name", "etcd-server-ssl"+serviceNameSuffix),
|
||||
zap.String("server-name", cfg.Name),
|
||||
zap.String("discovery-srv", cfg.DNSCluster),
|
||||
zap.Strings("advertise-peer-urls", cfg.getAdvertisePeerUrls()),
|
||||
zap.Strings("advertise-peer-urls", cfg.getAdvertisePeerURLs()),
|
||||
zap.Strings("found-cluster", clusterStrs),
|
||||
zap.Error(cerr),
|
||||
)
|
||||
@ -1119,7 +1122,7 @@ func (cfg *Config) GetDNSClusterNames() ([]string, error) {
|
||||
zap.String("service-name", "etcd-server"+serviceNameSuffix),
|
||||
zap.String("server-name", cfg.Name),
|
||||
zap.String("discovery-srv", cfg.DNSCluster),
|
||||
zap.Strings("advertise-peer-urls", cfg.getAdvertisePeerUrls()),
|
||||
zap.Strings("advertise-peer-urls", cfg.getAdvertisePeerURLs()),
|
||||
zap.Strings("found-cluster", clusterStrs),
|
||||
zap.Error(httpCerr),
|
||||
)
|
||||
@ -1275,7 +1278,7 @@ func checkHostURLs(urls []url.URL) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cfg *Config) getAdvertisePeerUrls() (ss []string) {
|
||||
func (cfg *Config) getAdvertisePeerURLs() (ss []string) {
|
||||
ss = make([]string, len(cfg.AdvertisePeerUrls))
|
||||
for i := range cfg.AdvertisePeerUrls {
|
||||
ss[i] = cfg.AdvertisePeerUrls[i].String()
|
||||
@ -1283,7 +1286,7 @@ func (cfg *Config) getAdvertisePeerUrls() (ss []string) {
|
||||
return ss
|
||||
}
|
||||
|
||||
func (cfg *Config) getListenPeerUrls() (ss []string) {
|
||||
func (cfg *Config) getListenPeerURLs() (ss []string) {
|
||||
ss = make([]string, len(cfg.ListenPeerUrls))
|
||||
for i := range cfg.ListenPeerUrls {
|
||||
ss[i] = cfg.ListenPeerUrls[i].String()
|
||||
@ -1291,7 +1294,7 @@ func (cfg *Config) getListenPeerUrls() (ss []string) {
|
||||
return ss
|
||||
}
|
||||
|
||||
func (cfg *Config) getAdvertiseClientUrls() (ss []string) {
|
||||
func (cfg *Config) getAdvertiseClientURLs() (ss []string) {
|
||||
ss = make([]string, len(cfg.AdvertiseClientUrls))
|
||||
for i := range cfg.AdvertiseClientUrls {
|
||||
ss[i] = cfg.AdvertiseClientUrls[i].String()
|
||||
@ -1299,7 +1302,7 @@ func (cfg *Config) getAdvertiseClientUrls() (ss []string) {
|
||||
return ss
|
||||
}
|
||||
|
||||
func (cfg *Config) getListenClientUrls() (ss []string) {
|
||||
func (cfg *Config) getListenClientURLs() (ss []string) {
|
||||
ss = make([]string, len(cfg.ListenClientUrls))
|
||||
for i := range cfg.ListenClientUrls {
|
||||
ss[i] = cfg.ListenClientUrls[i].String()
|
||||
|
@ -124,7 +124,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
|
||||
}
|
||||
e.cfg.logger.Info(
|
||||
"configuring peer listeners",
|
||||
zap.Strings("listen-peer-urls", e.cfg.getListenPeerUrls()),
|
||||
zap.Strings("listen-peer-urls", e.cfg.getListenPeerURLs()),
|
||||
)
|
||||
if e.Peers, err = configurePeerListeners(cfg); err != nil {
|
||||
return e, err
|
||||
@ -132,7 +132,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
|
||||
|
||||
e.cfg.logger.Info(
|
||||
"configuring client listeners",
|
||||
zap.Strings("listen-client-urls", e.cfg.getListenClientUrls()),
|
||||
zap.Strings("listen-client-urls", e.cfg.getListenClientURLs()),
|
||||
)
|
||||
if e.sctxs, err = configureClientListeners(cfg); err != nil {
|
||||
return e, err
|
||||
@ -280,10 +280,10 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
|
||||
e.cfg.logger.Info(
|
||||
"now serving peer/client/metrics",
|
||||
zap.String("local-member-id", e.Server.MemberID().String()),
|
||||
zap.Strings("initial-advertise-peer-urls", e.cfg.getAdvertisePeerUrls()),
|
||||
zap.Strings("listen-peer-urls", e.cfg.getListenPeerUrls()),
|
||||
zap.Strings("advertise-client-urls", e.cfg.getAdvertiseClientUrls()),
|
||||
zap.Strings("listen-client-urls", e.cfg.getListenClientUrls()),
|
||||
zap.Strings("initial-advertise-peer-urls", e.cfg.getAdvertisePeerURLs()),
|
||||
zap.Strings("listen-peer-urls", e.cfg.getListenPeerURLs()),
|
||||
zap.Strings("advertise-client-urls", e.cfg.getAdvertiseClientURLs()),
|
||||
zap.Strings("listen-client-urls", e.cfg.getListenClientURLs()),
|
||||
zap.Strings("listen-metrics-urls", e.cfg.getMetricsURLs()),
|
||||
)
|
||||
serving = true
|
||||
@ -331,10 +331,10 @@ func print(lg *zap.Logger, ec Config, sc config.ServerConfig, memberInitialized
|
||||
zap.Uint("max-wals", sc.MaxWALFiles),
|
||||
zap.Uint("max-snapshots", sc.MaxSnapFiles),
|
||||
zap.Uint64("snapshot-catchup-entries", sc.SnapshotCatchUpEntries),
|
||||
zap.Strings("initial-advertise-peer-urls", ec.getAdvertisePeerUrls()),
|
||||
zap.Strings("listen-peer-urls", ec.getListenPeerUrls()),
|
||||
zap.Strings("advertise-client-urls", ec.getAdvertiseClientUrls()),
|
||||
zap.Strings("listen-client-urls", ec.getListenClientUrls()),
|
||||
zap.Strings("initial-advertise-peer-urls", ec.getAdvertisePeerURLs()),
|
||||
zap.Strings("listen-peer-urls", ec.getListenPeerURLs()),
|
||||
zap.Strings("advertise-client-urls", ec.getAdvertiseClientURLs()),
|
||||
zap.Strings("listen-client-urls", ec.getListenClientURLs()),
|
||||
zap.Strings("listen-metrics-urls", ec.getMetricsURLs()),
|
||||
zap.Strings("cors", cors),
|
||||
zap.Strings("host-whitelist", hss),
|
||||
@ -386,8 +386,8 @@ func (e *Etcd) Close() {
|
||||
fields := []zap.Field{
|
||||
zap.String("name", e.cfg.Name),
|
||||
zap.String("data-dir", e.cfg.Dir),
|
||||
zap.Strings("advertise-peer-urls", e.cfg.getAdvertisePeerUrls()),
|
||||
zap.Strings("advertise-client-urls", e.cfg.getAdvertiseClientUrls()),
|
||||
zap.Strings("advertise-peer-urls", e.cfg.getAdvertisePeerURLs()),
|
||||
zap.Strings("advertise-client-urls", e.cfg.getAdvertiseClientURLs()),
|
||||
}
|
||||
lg := e.GetLogger()
|
||||
lg.Info("closing etcd server", fields...)
|
||||
|
@ -61,10 +61,10 @@ func TestConfigFileMemberFields(t *testing.T) {
|
||||
Name string `json:"name"`
|
||||
SnapshotCount uint64 `json:"snapshot-count"`
|
||||
SnapshotCatchUpEntries uint64 `json:"experimental-snapshot-catch-up-entries"`
|
||||
ListenPeerUrls string `json:"listen-peer-urls"`
|
||||
ListenClientUrls string `json:"listen-client-urls"`
|
||||
ListenClientHttpUrls string `json:"listen-client-http-urls"`
|
||||
AdvertiseClientUrls string `json:"advertise-client-urls"`
|
||||
ListenPeerURLs string `json:"listen-peer-urls"`
|
||||
ListenClientURLs string `json:"listen-client-urls"`
|
||||
ListenClientHTTPURLs string `json:"listen-client-http-urls"`
|
||||
AdvertiseClientURLs string `json:"advertise-client-urls"`
|
||||
}{
|
||||
"testdir",
|
||||
10,
|
||||
|
Loading…
x
Reference in New Issue
Block a user