Browse Source

config -> cfg

It is extremely confusing to use variables named the same as a package.
Please no longer do this.
Blake Mizerany 11 years ago
parent
commit
41ccf13393

+ 1 - 1
config/cluster_config.go → cfg/cluster_config.go

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

+ 1 - 1
config/config.go → cfg/config.go

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

+ 1 - 1
config/config_test.go → cfg/config_test.go

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

+ 1 - 1
config/default.go → cfg/default.go

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

+ 1 - 1
config/tls_config.go → cfg/tls_config.go

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

+ 3 - 3
etcd/etcd.go

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

+ 9 - 9
etcd/etcd_functional_test.go

@@ -25,7 +25,7 @@ import (
 	"testing"
 	"time"
 
-	"github.com/coreos/etcd/config"
+	"github.com/coreos/etcd/cfg"
 	"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 := config.New()
+			c := cfg.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 := config.New()
+				c := cfg.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 := config.New()
+			c := cfg.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 := config.NewClusterConfig()
+		conf := cfg.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 := config.New()
+			c := cfg.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 := config.New()
+			c := cfg.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 := config.New()
+			c := cfg.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 := config.NewClusterConfig()
+		config := cfg.NewClusterConfig()
 		config.SyncInterval = 0
 		id := int64(i)
 		for j := 0; j < round; j++ {

+ 7 - 7
etcd/etcd_start_test.go

@@ -26,7 +26,7 @@ import (
 	"testing"
 	"time"
 
-	"github.com/coreos/etcd/config"
+	"github.com/coreos/etcd/cfg"
 )
 
 const (
@@ -55,7 +55,7 @@ func TestBadDiscoveryService(t *testing.T) {
 	g := garbageHandler{t: t}
 	ts := httptest.NewServer(&g)
 
-	c := config.New()
+	c := cfg.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 := config.New()
+	c := cfg.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 := config.New()
+	c := cfg.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, config.New(), genId())
+	de, dh, _ := buildServer(t, cfg.New(), genId())
 
-	c := config.New()
+	c := cfg.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 := config.New()
+	c := cfg.New()
 	c.Peers = []string{hs[0].URL}
 	e, h, err := buildServer(t, c, bootstrapId)
 	if err != nil {

+ 1 - 1
etcd/etcd_test.go

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

+ 3 - 3
etcd/standby.go

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

+ 4 - 4
etcd/v2_admin.go

@@ -25,7 +25,7 @@ import (
 	"strconv"
 	"strings"
 
-	"github.com/coreos/etcd/config"
+	"github.com/coreos/etcd/cfg"
 	"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() *config.ClusterConfig {
-	c := config.NewClusterConfig()
+func (p *participant) clusterConfig() *cfg.ClusterConfig {
+	c := cfg.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() *config.ClusterConfig {
 	return c
 }
 
-func (p *participant) setClusterConfig(c *config.ClusterConfig) error {
+func (p *participant) setClusterConfig(c *cfg.ClusterConfig) error {
 	b, err := json.Marshal(c)
 	if err != nil {
 		return err

+ 3 - 3
etcd/v2_client.go

@@ -29,7 +29,7 @@ import (
 	"strings"
 	"sync"
 
-	"github.com/coreos/etcd/config"
+	"github.com/coreos/etcd/cfg"
 	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) (*config.ClusterConfig, *etcdErr.Error) {
+func (c *v2client) GetClusterConfig(url string) (*cfg.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) (*config.ClusterConfig, *etcdErr
 		return nil, c.readErrorBody(resp.Body)
 	}
 
-	config := new(config.ClusterConfig)
+	config := new(cfg.ClusterConfig)
 	if uerr := c.readJSONBody(resp.Body, config); uerr != nil {
 		return nil, uerr
 	}

+ 3 - 3
etcd/v2_http_endpoint_test.go

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

+ 3 - 3
main.go

@@ -9,12 +9,12 @@ import (
 	"os"
 	"time"
 
-	"github.com/coreos/etcd/config"
+	"github.com/coreos/etcd/cfg"
 	"github.com/coreos/etcd/etcd"
 )
 
 func main() {
-	var config = config.New()
+	var config = cfg.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 *config.TLSInfo, cinfo *CORSInfo, handler http.Handler, readTimeout, writeTimeout time.Duration) {
+func serve(who string, addr string, tinfo *cfg.TLSInfo, cinfo *CORSInfo, handler http.Handler, readTimeout, writeTimeout time.Duration) {
 	t, terr := tinfo.ServerConfig()
 	l, err := net.Listen("tcp", addr)
 	if err != nil {