mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
cfg/ -> conf/
This commit is contained in:
parent
08b370ebe4
commit
a5eec89113
@ -1,4 +1,4 @@
|
||||
package cfg
|
||||
package conf
|
||||
|
||||
// ClusterConfig represents cluster-wide configuration settings.
|
||||
type ClusterConfig struct {
|
@ -1,4 +1,4 @@
|
||||
package cfg
|
||||
package conf
|
||||
|
||||
import (
|
||||
"flag"
|
@ -1,4 +1,4 @@
|
||||
package cfg
|
||||
package conf
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
@ -1,4 +1,4 @@
|
||||
package cfg
|
||||
package conf
|
||||
|
||||
import "time"
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cfg
|
||||
package conf
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
@ -26,7 +26,7 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/coreos/etcd/cfg"
|
||||
"github.com/coreos/etcd/conf"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -36,7 +36,7 @@ const (
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
config *cfg.Config
|
||||
config *conf.Config
|
||||
id int64
|
||||
pubAddr string
|
||||
raftPubAddr string
|
||||
@ -55,7 +55,7 @@ type Server struct {
|
||||
http.Handler
|
||||
}
|
||||
|
||||
func New(c *cfg.Config) (*Server, error) {
|
||||
func New(c *conf.Config) (*Server, error) {
|
||||
if err := c.Sanitize(); err != nil {
|
||||
log.Fatalf("server.new sanitizeErr=\"%v\"\n", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/coreos/etcd/cfg"
|
||||
"github.com/coreos/etcd/conf"
|
||||
"github.com/coreos/etcd/store"
|
||||
|
||||
"github.com/coreos/etcd/third_party/github.com/coreos/go-etcd/etcd"
|
||||
@ -54,7 +54,7 @@ func TestKillLeader(t *testing.T) {
|
||||
avgTime := totalTime / (time.Duration)(i+1)
|
||||
fmt.Println("Total time:", totalTime, "; Avg time:", avgTime)
|
||||
|
||||
c := cfg.New()
|
||||
c := conf.New()
|
||||
c.DataDir = es[lead].config.DataDir
|
||||
c.Addr = hs[lead].Listener.Addr().String()
|
||||
id := es[lead].id
|
||||
@ -95,7 +95,7 @@ func TestKillRandom(t *testing.T) {
|
||||
waitLeader(es)
|
||||
|
||||
for k := range toKill {
|
||||
c := cfg.New()
|
||||
c := conf.New()
|
||||
c.DataDir = es[k].config.DataDir
|
||||
c.Addr = hs[k].Listener.Addr().String()
|
||||
id := es[k].id
|
||||
@ -120,7 +120,7 @@ func TestJoinThroughFollower(t *testing.T) {
|
||||
es := make([]*Server, tt)
|
||||
hs := make([]*httptest.Server, tt)
|
||||
for i := 0; i < tt; i++ {
|
||||
c := cfg.New()
|
||||
c := conf.New()
|
||||
if i > 0 {
|
||||
c.Peers = []string{hs[i-1].URL}
|
||||
}
|
||||
@ -148,7 +148,7 @@ func TestClusterConfigReload(t *testing.T) {
|
||||
waitCluster(t, es)
|
||||
|
||||
lead, _ := waitLeader(es)
|
||||
conf := cfg.NewClusterConfig()
|
||||
conf := conf.NewClusterConfig()
|
||||
conf.ActiveSize = 15
|
||||
conf.RemoveDelay = 60
|
||||
if err := es[lead].p.setClusterConfig(conf); err != nil {
|
||||
@ -161,7 +161,7 @@ func TestClusterConfigReload(t *testing.T) {
|
||||
}
|
||||
|
||||
for k := range es {
|
||||
c := cfg.New()
|
||||
c := conf.New()
|
||||
c.DataDir = es[k].config.DataDir
|
||||
c.Addr = hs[k].Listener.Addr().String()
|
||||
id := es[k].id
|
||||
@ -200,7 +200,7 @@ func TestMultiNodeKillOne(t *testing.T) {
|
||||
es[idx].Stop()
|
||||
hs[idx].Close()
|
||||
|
||||
c := cfg.New()
|
||||
c := conf.New()
|
||||
c.DataDir = es[idx].config.DataDir
|
||||
c.Addr = hs[idx].Listener.Addr().String()
|
||||
id := es[idx].id
|
||||
@ -241,7 +241,7 @@ func TestMultiNodeKillAllAndRecovery(t *testing.T) {
|
||||
}
|
||||
|
||||
for k := range es {
|
||||
c := cfg.New()
|
||||
c := conf.New()
|
||||
c.DataDir = es[k].config.DataDir
|
||||
c.Addr = hs[k].Listener.Addr().String()
|
||||
id := es[k].id
|
||||
@ -291,7 +291,7 @@ func TestModeSwitch(t *testing.T) {
|
||||
es, hs := buildCluster(size, false)
|
||||
waitCluster(t, es)
|
||||
|
||||
config := cfg.NewClusterConfig()
|
||||
config := conf.NewClusterConfig()
|
||||
config.SyncInterval = 0
|
||||
id := int64(i)
|
||||
for j := 0; j < round; j++ {
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/coreos/etcd/cfg"
|
||||
"github.com/coreos/etcd/conf"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -55,7 +55,7 @@ func TestBadDiscoveryService(t *testing.T) {
|
||||
g := garbageHandler{t: t}
|
||||
ts := httptest.NewServer(&g)
|
||||
|
||||
c := cfg.New()
|
||||
c := conf.New()
|
||||
c.Discovery = ts.URL + "/v2/keys/_etcd/registry/1"
|
||||
_, _, err := buildServer(t, c, bootstrapId)
|
||||
w := `discovery service error`
|
||||
@ -79,7 +79,7 @@ func TestBadDiscoveryServiceWithAdvisedPeers(t *testing.T) {
|
||||
es, hs := buildCluster(1, false)
|
||||
waitCluster(t, es)
|
||||
|
||||
c := cfg.New()
|
||||
c := conf.New()
|
||||
c.Discovery = ts.URL + "/v2/keys/_etcd/registry/1"
|
||||
c.Peers = []string{hs[0].URL}
|
||||
_, _, err := buildServer(t, c, bootstrapId)
|
||||
@ -94,7 +94,7 @@ func TestBadDiscoveryServiceWithAdvisedPeers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBootstrapByEmptyPeers(t *testing.T) {
|
||||
c := cfg.New()
|
||||
c := conf.New()
|
||||
id := genId()
|
||||
e, h, err := buildServer(t, c, id)
|
||||
|
||||
@ -109,9 +109,9 @@ func TestBootstrapByEmptyPeers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBootstrapByDiscoveryService(t *testing.T) {
|
||||
de, dh, _ := buildServer(t, cfg.New(), genId())
|
||||
de, dh, _ := buildServer(t, conf.New(), genId())
|
||||
|
||||
c := cfg.New()
|
||||
c := conf.New()
|
||||
c.Discovery = dh.URL + "/v2/keys/_etcd/registry/1"
|
||||
e, h, err := buildServer(t, c, bootstrapId)
|
||||
if err != nil {
|
||||
@ -127,7 +127,7 @@ func TestRunByAdvisedPeers(t *testing.T) {
|
||||
es, hs := buildCluster(1, false)
|
||||
waitCluster(t, es)
|
||||
|
||||
c := cfg.New()
|
||||
c := conf.New()
|
||||
c.Peers = []string{hs[0].URL}
|
||||
e, h, err := buildServer(t, c, bootstrapId)
|
||||
if err != nil {
|
||||
|
@ -30,7 +30,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/coreos/etcd/cfg"
|
||||
"github.com/coreos/etcd/conf"
|
||||
"github.com/coreos/etcd/store"
|
||||
)
|
||||
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/coreos/etcd/cfg"
|
||||
"github.com/coreos/etcd/conf"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -38,7 +38,7 @@ type standby struct {
|
||||
leader int64
|
||||
leaderAddr string
|
||||
mu sync.RWMutex
|
||||
clusterConf *cfg.ClusterConfig
|
||||
clusterConf *conf.ClusterConfig
|
||||
|
||||
*http.ServeMux
|
||||
}
|
||||
@ -50,7 +50,7 @@ func newStandby(client *v2client, peerHub *peerHub) *standby {
|
||||
|
||||
leader: noneId,
|
||||
leaderAddr: "",
|
||||
clusterConf: cfg.NewClusterConfig(),
|
||||
clusterConf: conf.NewClusterConfig(),
|
||||
|
||||
ServeMux: http.NewServeMux(),
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/coreos/etcd/cfg"
|
||||
"github.com/coreos/etcd/conf"
|
||||
"github.com/coreos/etcd/store"
|
||||
)
|
||||
|
||||
@ -118,8 +118,8 @@ func (p *participant) serveAdminMachines(w http.ResponseWriter, r *http.Request)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *participant) clusterConfig() *cfg.ClusterConfig {
|
||||
c := cfg.NewClusterConfig()
|
||||
func (p *participant) clusterConfig() *conf.ClusterConfig {
|
||||
c := conf.NewClusterConfig()
|
||||
// This is used for backward compatibility because it doesn't
|
||||
// set cluster config in older version.
|
||||
if e, err := p.Store.Get(v2configKVPrefix, false, false); err == nil {
|
||||
@ -128,7 +128,7 @@ func (p *participant) clusterConfig() *cfg.ClusterConfig {
|
||||
return c
|
||||
}
|
||||
|
||||
func (p *participant) setClusterConfig(c *cfg.ClusterConfig) error {
|
||||
func (p *participant) setClusterConfig(c *conf.ClusterConfig) error {
|
||||
b, err := json.Marshal(c)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -29,7 +29,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/coreos/etcd/cfg"
|
||||
"github.com/coreos/etcd/conf"
|
||||
etcdErr "github.com/coreos/etcd/error"
|
||||
)
|
||||
|
||||
@ -122,7 +122,7 @@ func (c *v2client) GetMachines(url string) ([]*machineMessage, *etcdErr.Error) {
|
||||
return *msgs, nil
|
||||
}
|
||||
|
||||
func (c *v2client) GetClusterConfig(url string) (*cfg.ClusterConfig, *etcdErr.Error) {
|
||||
func (c *v2client) GetClusterConfig(url string) (*conf.ClusterConfig, *etcdErr.Error) {
|
||||
if c.runOne() == false {
|
||||
return nil, clientError(errors.New("v2_client is stopped"))
|
||||
}
|
||||
@ -136,7 +136,7 @@ func (c *v2client) GetClusterConfig(url string) (*cfg.ClusterConfig, *etcdErr.Er
|
||||
return nil, c.readErrorBody(resp.Body)
|
||||
}
|
||||
|
||||
config := new(cfg.ClusterConfig)
|
||||
config := new(conf.ClusterConfig)
|
||||
if uerr := c.readJSONBody(resp.Body, config); uerr != nil {
|
||||
return nil, uerr
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/coreos/etcd/cfg"
|
||||
"github.com/coreos/etcd/conf"
|
||||
"github.com/coreos/etcd/store"
|
||||
)
|
||||
|
||||
@ -136,14 +136,14 @@ func TestGetAdminConfigEndPoint(t *testing.T) {
|
||||
t.Errorf("#%d: ContentType = %d, want application/json", i, g)
|
||||
}
|
||||
|
||||
conf := new(cfg.ClusterConfig)
|
||||
conf := new(conf.ClusterConfig)
|
||||
err = json.NewDecoder(r.Body).Decode(conf)
|
||||
r.Body.Close()
|
||||
if err != nil {
|
||||
t.Errorf("%v", err)
|
||||
continue
|
||||
}
|
||||
w := cfg.NewClusterConfig()
|
||||
w := conf.NewClusterConfig()
|
||||
if !reflect.DeepEqual(conf, w) {
|
||||
t.Errorf("#%d: config = %+v, want %+v", i, conf, w)
|
||||
}
|
||||
|
6
main.go
6
main.go
@ -9,12 +9,12 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/coreos/etcd/cfg"
|
||||
"github.com/coreos/etcd/conf"
|
||||
"github.com/coreos/etcd/etcd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var config = cfg.New()
|
||||
var config = conf.New()
|
||||
if err := config.Load(os.Args[1:]); err != nil {
|
||||
fmt.Println(etcd.Usage() + "\n")
|
||||
fmt.Println(err.Error(), "\n")
|
||||
@ -45,7 +45,7 @@ func main() {
|
||||
serve("etcd", config.BindAddr, config.EtcdTLSInfo(), corsInfo, e, readTimeout, writeTimeout)
|
||||
}
|
||||
|
||||
func serve(who string, addr string, tinfo *cfg.TLSInfo, cinfo *CORSInfo, handler http.Handler, readTimeout, writeTimeout time.Duration) {
|
||||
func serve(who string, addr string, tinfo *conf.TLSInfo, cinfo *CORSInfo, handler http.Handler, readTimeout, writeTimeout time.Duration) {
|
||||
t, terr := tinfo.ServerConfig()
|
||||
l, err := net.Listen("tcp", addr)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user