cfg/ -> conf/

release-2.0
Blake Mizerany 2014-08-13 17:01:59 -07:00 committed by Yicheng Qin
parent 08b370ebe4
commit a5eec89113
14 changed files with 41 additions and 41 deletions

View File

@ -1,4 +1,4 @@
package cfg package conf
// ClusterConfig represents cluster-wide configuration settings. // ClusterConfig represents cluster-wide configuration settings.
type ClusterConfig struct { type ClusterConfig struct {

View File

@ -1,4 +1,4 @@
package cfg package conf
import ( import (
"flag" "flag"

View File

@ -1,4 +1,4 @@
package cfg package conf
import ( import (
"io/ioutil" "io/ioutil"

View File

@ -1,4 +1,4 @@
package cfg package conf
import "time" import "time"

View File

@ -1,4 +1,4 @@
package cfg package conf
import ( import (
"crypto/tls" "crypto/tls"

View File

@ -26,7 +26,7 @@ import (
"os" "os"
"time" "time"
"github.com/coreos/etcd/cfg" "github.com/coreos/etcd/conf"
) )
const ( const (
@ -36,7 +36,7 @@ const (
) )
type Server struct { type Server struct {
config *cfg.Config config *conf.Config
id int64 id int64
pubAddr string pubAddr string
raftPubAddr string raftPubAddr string
@ -55,7 +55,7 @@ type Server struct {
http.Handler http.Handler
} }
func New(c *cfg.Config) (*Server, error) { func New(c *conf.Config) (*Server, error) {
if err := c.Sanitize(); err != nil { if err := c.Sanitize(); err != nil {
log.Fatalf("server.new sanitizeErr=\"%v\"\n", err) log.Fatalf("server.new sanitizeErr=\"%v\"\n", err)
} }

View File

@ -25,7 +25,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/coreos/etcd/cfg" "github.com/coreos/etcd/conf"
"github.com/coreos/etcd/store" "github.com/coreos/etcd/store"
"github.com/coreos/etcd/third_party/github.com/coreos/go-etcd/etcd" "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) avgTime := totalTime / (time.Duration)(i+1)
fmt.Println("Total time:", totalTime, "; Avg time:", avgTime) fmt.Println("Total time:", totalTime, "; Avg time:", avgTime)
c := cfg.New() c := conf.New()
c.DataDir = es[lead].config.DataDir c.DataDir = es[lead].config.DataDir
c.Addr = hs[lead].Listener.Addr().String() c.Addr = hs[lead].Listener.Addr().String()
id := es[lead].id id := es[lead].id
@ -95,7 +95,7 @@ func TestKillRandom(t *testing.T) {
waitLeader(es) waitLeader(es)
for k := range toKill { for k := range toKill {
c := cfg.New() c := conf.New()
c.DataDir = es[k].config.DataDir c.DataDir = es[k].config.DataDir
c.Addr = hs[k].Listener.Addr().String() c.Addr = hs[k].Listener.Addr().String()
id := es[k].id id := es[k].id
@ -120,7 +120,7 @@ func TestJoinThroughFollower(t *testing.T) {
es := make([]*Server, tt) es := make([]*Server, tt)
hs := make([]*httptest.Server, tt) hs := make([]*httptest.Server, tt)
for i := 0; i < tt; i++ { for i := 0; i < tt; i++ {
c := cfg.New() c := conf.New()
if i > 0 { if i > 0 {
c.Peers = []string{hs[i-1].URL} c.Peers = []string{hs[i-1].URL}
} }
@ -148,7 +148,7 @@ func TestClusterConfigReload(t *testing.T) {
waitCluster(t, es) waitCluster(t, es)
lead, _ := waitLeader(es) lead, _ := waitLeader(es)
conf := cfg.NewClusterConfig() conf := conf.NewClusterConfig()
conf.ActiveSize = 15 conf.ActiveSize = 15
conf.RemoveDelay = 60 conf.RemoveDelay = 60
if err := es[lead].p.setClusterConfig(conf); err != nil { if err := es[lead].p.setClusterConfig(conf); err != nil {
@ -161,7 +161,7 @@ func TestClusterConfigReload(t *testing.T) {
} }
for k := range es { for k := range es {
c := cfg.New() c := conf.New()
c.DataDir = es[k].config.DataDir c.DataDir = es[k].config.DataDir
c.Addr = hs[k].Listener.Addr().String() c.Addr = hs[k].Listener.Addr().String()
id := es[k].id id := es[k].id
@ -200,7 +200,7 @@ func TestMultiNodeKillOne(t *testing.T) {
es[idx].Stop() es[idx].Stop()
hs[idx].Close() hs[idx].Close()
c := cfg.New() c := conf.New()
c.DataDir = es[idx].config.DataDir c.DataDir = es[idx].config.DataDir
c.Addr = hs[idx].Listener.Addr().String() c.Addr = hs[idx].Listener.Addr().String()
id := es[idx].id id := es[idx].id
@ -241,7 +241,7 @@ func TestMultiNodeKillAllAndRecovery(t *testing.T) {
} }
for k := range es { for k := range es {
c := cfg.New() c := conf.New()
c.DataDir = es[k].config.DataDir c.DataDir = es[k].config.DataDir
c.Addr = hs[k].Listener.Addr().String() c.Addr = hs[k].Listener.Addr().String()
id := es[k].id id := es[k].id
@ -291,7 +291,7 @@ func TestModeSwitch(t *testing.T) {
es, hs := buildCluster(size, false) es, hs := buildCluster(size, false)
waitCluster(t, es) waitCluster(t, es)
config := cfg.NewClusterConfig() config := conf.NewClusterConfig()
config.SyncInterval = 0 config.SyncInterval = 0
id := int64(i) id := int64(i)
for j := 0; j < round; j++ { for j := 0; j < round; j++ {

View File

@ -26,7 +26,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/coreos/etcd/cfg" "github.com/coreos/etcd/conf"
) )
const ( const (
@ -55,7 +55,7 @@ func TestBadDiscoveryService(t *testing.T) {
g := garbageHandler{t: t} g := garbageHandler{t: t}
ts := httptest.NewServer(&g) ts := httptest.NewServer(&g)
c := cfg.New() c := conf.New()
c.Discovery = ts.URL + "/v2/keys/_etcd/registry/1" c.Discovery = ts.URL + "/v2/keys/_etcd/registry/1"
_, _, err := buildServer(t, c, bootstrapId) _, _, err := buildServer(t, c, bootstrapId)
w := `discovery service error` w := `discovery service error`
@ -79,7 +79,7 @@ func TestBadDiscoveryServiceWithAdvisedPeers(t *testing.T) {
es, hs := buildCluster(1, false) es, hs := buildCluster(1, false)
waitCluster(t, es) waitCluster(t, es)
c := cfg.New() c := conf.New()
c.Discovery = ts.URL + "/v2/keys/_etcd/registry/1" c.Discovery = ts.URL + "/v2/keys/_etcd/registry/1"
c.Peers = []string{hs[0].URL} c.Peers = []string{hs[0].URL}
_, _, err := buildServer(t, c, bootstrapId) _, _, err := buildServer(t, c, bootstrapId)
@ -94,7 +94,7 @@ func TestBadDiscoveryServiceWithAdvisedPeers(t *testing.T) {
} }
func TestBootstrapByEmptyPeers(t *testing.T) { func TestBootstrapByEmptyPeers(t *testing.T) {
c := cfg.New() c := conf.New()
id := genId() id := genId()
e, h, err := buildServer(t, c, id) e, h, err := buildServer(t, c, id)
@ -109,9 +109,9 @@ func TestBootstrapByEmptyPeers(t *testing.T) {
} }
func TestBootstrapByDiscoveryService(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" c.Discovery = dh.URL + "/v2/keys/_etcd/registry/1"
e, h, err := buildServer(t, c, bootstrapId) e, h, err := buildServer(t, c, bootstrapId)
if err != nil { if err != nil {
@ -127,7 +127,7 @@ func TestRunByAdvisedPeers(t *testing.T) {
es, hs := buildCluster(1, false) es, hs := buildCluster(1, false)
waitCluster(t, es) waitCluster(t, es)
c := cfg.New() c := conf.New()
c.Peers = []string{hs[0].URL} c.Peers = []string{hs[0].URL}
e, h, err := buildServer(t, c, bootstrapId) e, h, err := buildServer(t, c, bootstrapId)
if err != nil { if err != nil {

View File

@ -30,7 +30,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/coreos/etcd/cfg" "github.com/coreos/etcd/conf"
"github.com/coreos/etcd/store" "github.com/coreos/etcd/store"
) )

View File

@ -24,7 +24,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/coreos/etcd/cfg" "github.com/coreos/etcd/conf"
) )
var ( var (
@ -38,7 +38,7 @@ type standby struct {
leader int64 leader int64
leaderAddr string leaderAddr string
mu sync.RWMutex mu sync.RWMutex
clusterConf *cfg.ClusterConfig clusterConf *conf.ClusterConfig
*http.ServeMux *http.ServeMux
} }
@ -50,7 +50,7 @@ func newStandby(client *v2client, peerHub *peerHub) *standby {
leader: noneId, leader: noneId,
leaderAddr: "", leaderAddr: "",
clusterConf: cfg.NewClusterConfig(), clusterConf: conf.NewClusterConfig(),
ServeMux: http.NewServeMux(), ServeMux: http.NewServeMux(),
} }

View File

@ -25,7 +25,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/coreos/etcd/cfg" "github.com/coreos/etcd/conf"
"github.com/coreos/etcd/store" "github.com/coreos/etcd/store"
) )
@ -118,8 +118,8 @@ func (p *participant) serveAdminMachines(w http.ResponseWriter, r *http.Request)
return nil return nil
} }
func (p *participant) clusterConfig() *cfg.ClusterConfig { func (p *participant) clusterConfig() *conf.ClusterConfig {
c := cfg.NewClusterConfig() c := conf.NewClusterConfig()
// This is used for backward compatibility because it doesn't // This is used for backward compatibility because it doesn't
// set cluster config in older version. // set cluster config in older version.
if e, err := p.Store.Get(v2configKVPrefix, false, false); err == nil { if e, err := p.Store.Get(v2configKVPrefix, false, false); err == nil {
@ -128,7 +128,7 @@ func (p *participant) clusterConfig() *cfg.ClusterConfig {
return c return c
} }
func (p *participant) setClusterConfig(c *cfg.ClusterConfig) error { func (p *participant) setClusterConfig(c *conf.ClusterConfig) error {
b, err := json.Marshal(c) b, err := json.Marshal(c)
if err != nil { if err != nil {
return err return err

View File

@ -29,7 +29,7 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/coreos/etcd/cfg" "github.com/coreos/etcd/conf"
etcdErr "github.com/coreos/etcd/error" etcdErr "github.com/coreos/etcd/error"
) )
@ -122,7 +122,7 @@ func (c *v2client) GetMachines(url string) ([]*machineMessage, *etcdErr.Error) {
return *msgs, nil 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 { if c.runOne() == false {
return nil, clientError(errors.New("v2_client is stopped")) 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) return nil, c.readErrorBody(resp.Body)
} }
config := new(cfg.ClusterConfig) config := new(conf.ClusterConfig)
if uerr := c.readJSONBody(resp.Body, config); uerr != nil { if uerr := c.readJSONBody(resp.Body, config); uerr != nil {
return nil, uerr return nil, uerr
} }

View File

@ -27,7 +27,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/coreos/etcd/cfg" "github.com/coreos/etcd/conf"
"github.com/coreos/etcd/store" "github.com/coreos/etcd/store"
) )
@ -136,14 +136,14 @@ func TestGetAdminConfigEndPoint(t *testing.T) {
t.Errorf("#%d: ContentType = %d, want application/json", i, g) 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) err = json.NewDecoder(r.Body).Decode(conf)
r.Body.Close() r.Body.Close()
if err != nil { if err != nil {
t.Errorf("%v", err) t.Errorf("%v", err)
continue continue
} }
w := cfg.NewClusterConfig() w := conf.NewClusterConfig()
if !reflect.DeepEqual(conf, w) { if !reflect.DeepEqual(conf, w) {
t.Errorf("#%d: config = %+v, want %+v", i, conf, w) t.Errorf("#%d: config = %+v, want %+v", i, conf, w)
} }

View File

@ -9,12 +9,12 @@ import (
"os" "os"
"time" "time"
"github.com/coreos/etcd/cfg" "github.com/coreos/etcd/conf"
"github.com/coreos/etcd/etcd" "github.com/coreos/etcd/etcd"
) )
func main() { func main() {
var config = cfg.New() var config = conf.New()
if err := config.Load(os.Args[1:]); err != nil { if err := config.Load(os.Args[1:]); err != nil {
fmt.Println(etcd.Usage() + "\n") fmt.Println(etcd.Usage() + "\n")
fmt.Println(err.Error(), "\n") fmt.Println(err.Error(), "\n")
@ -45,7 +45,7 @@ func main() {
serve("etcd", config.BindAddr, config.EtcdTLSInfo(), corsInfo, e, readTimeout, writeTimeout) 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() t, terr := tinfo.ServerConfig()
l, err := net.Listen("tcp", addr) l, err := net.Listen("tcp", addr)
if err != nil { if err != nil {