diff --git a/cfg/cluster_config.go b/conf/cluster_config.go similarity index 98% rename from cfg/cluster_config.go rename to conf/cluster_config.go index 11375a8ef..1ffd10abf 100644 --- a/cfg/cluster_config.go +++ b/conf/cluster_config.go @@ -1,4 +1,4 @@ -package cfg +package conf // ClusterConfig represents cluster-wide configuration settings. type ClusterConfig struct { diff --git a/cfg/config.go b/conf/config.go similarity index 99% rename from cfg/config.go rename to conf/config.go index b7f2e463c..cbe055736 100644 --- a/cfg/config.go +++ b/conf/config.go @@ -1,4 +1,4 @@ -package cfg +package conf import ( "flag" diff --git a/cfg/config_test.go b/conf/config_test.go similarity index 99% rename from cfg/config_test.go rename to conf/config_test.go index dc227edde..72b3cb062 100644 --- a/cfg/config_test.go +++ b/conf/config_test.go @@ -1,4 +1,4 @@ -package cfg +package conf import ( "io/ioutil" diff --git a/cfg/default.go b/conf/default.go similarity index 98% rename from cfg/default.go rename to conf/default.go index 9425d8818..214351e7b 100644 --- a/cfg/default.go +++ b/conf/default.go @@ -1,4 +1,4 @@ -package cfg +package conf import "time" diff --git a/cfg/tls_config.go b/conf/tls_config.go similarity index 99% rename from cfg/tls_config.go rename to conf/tls_config.go index d24a17c5c..38573d5b7 100644 --- a/cfg/tls_config.go +++ b/conf/tls_config.go @@ -1,4 +1,4 @@ -package cfg +package conf import ( "crypto/tls" diff --git a/etcd/etcd.go b/etcd/etcd.go index bcec48a84..848094f35 100644 --- a/etcd/etcd.go +++ b/etcd/etcd.go @@ -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) } diff --git a/etcd/etcd_functional_test.go b/etcd/etcd_functional_test.go index 42cbefd4b..ae08db076 100644 --- a/etcd/etcd_functional_test.go +++ b/etcd/etcd_functional_test.go @@ -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++ { diff --git a/etcd/etcd_start_test.go b/etcd/etcd_start_test.go index d6c75e0d8..e466dcf39 100644 --- a/etcd/etcd_start_test.go +++ b/etcd/etcd_start_test.go @@ -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 { diff --git a/etcd/etcd_test.go b/etcd/etcd_test.go index 25492c137..a2360500c 100644 --- a/etcd/etcd_test.go +++ b/etcd/etcd_test.go @@ -30,7 +30,7 @@ import ( "testing" "time" - "github.com/coreos/etcd/cfg" + "github.com/coreos/etcd/conf" "github.com/coreos/etcd/store" ) diff --git a/etcd/standby.go b/etcd/standby.go index 5c3a2ca15..8ea06f00f 100644 --- a/etcd/standby.go +++ b/etcd/standby.go @@ -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(), } diff --git a/etcd/v2_admin.go b/etcd/v2_admin.go index dbc68cb67..ad8841abd 100644 --- a/etcd/v2_admin.go +++ b/etcd/v2_admin.go @@ -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 diff --git a/etcd/v2_client.go b/etcd/v2_client.go index f50550b76..16d2d7748 100644 --- a/etcd/v2_client.go +++ b/etcd/v2_client.go @@ -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 } diff --git a/etcd/v2_http_endpoint_test.go b/etcd/v2_http_endpoint_test.go index dfd2d250c..6a9b40e46 100644 --- a/etcd/v2_http_endpoint_test.go +++ b/etcd/v2_http_endpoint_test.go @@ -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) } diff --git a/main.go b/main.go index 924cd205b..da1496f50 100644 --- a/main.go +++ b/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 {