*: rename ConfigStore to Configstore

This commit is contained in:
Simone Gotti 2019-05-07 23:42:42 +02:00
parent e4e7de4ad2
commit 44d5b0f25a
6 changed files with 28 additions and 28 deletions

View File

@ -155,9 +155,9 @@ func serve(cmd *cobra.Command, args []string) error {
}
}
var cs *configstore.ConfigStore
var cs *configstore.Configstore
if isComponentEnabled("configstore") {
cs, err = configstore.NewConfigStore(ctx, &c.ConfigStore)
cs, err = configstore.NewConfigstore(ctx, &c.Configstore)
if err != nil {
return errors.Wrapf(err, "failed to start config store")
}

View File

@ -2,7 +2,7 @@ gateway:
apiExposedURL: "http://172.17.0.1:8000"
webExposedURL: "http://172.17.0.1:8080"
runServiceURL: "http://localhost:4000"
configStoreURL: "http://localhost:4002"
configstoreURL: "http://localhost:4002"
gitServerURL: "http://172.17.0.1:4003"
web:
@ -20,7 +20,7 @@ gateway:
scheduler:
runServiceURL: "http://localhost:4000"
configStore:
configstore:
dataDir: /tmp/agola/configstore
etcd:
endpoints: "http://localhost:2379"

View File

@ -37,7 +37,7 @@ type Config struct {
Scheduler Scheduler `yaml:"scheduler"`
RunServiceScheduler RunServiceScheduler `yaml:"runServiceScheduler"`
RunServiceExecutor RunServiceExecutor `yaml:"runServiceExecutor"`
ConfigStore ConfigStore `yaml:"configStore"`
Configstore Configstore `yaml:"configstore"`
GitServer GitServer `yaml:"gitServer"`
}
@ -52,7 +52,7 @@ type Gateway struct {
WebExposedURL string `yaml:"webExposedURL"`
RunServiceURL string `yaml:"runServiceURL"`
ConfigStoreURL string `yaml:"configStoreURL"`
ConfigstoreURL string `yaml:"configstoreURL"`
GitServerURL string `yaml:"gitServerURL"`
Web Web `yaml:"web"`
@ -98,7 +98,7 @@ type RunServiceExecutor struct {
ActiveTasksLimit int `yaml:"active_tasks_limit"`
}
type ConfigStore struct {
type Configstore struct {
Debug bool `yaml:"debug"`
DataDir string `yaml:"dataDir"`
@ -263,8 +263,8 @@ func Validate(c *Config) error {
if c.Gateway.WebExposedURL == "" {
return errors.Errorf("gateway webExposedURL is empty")
}
if c.Gateway.ConfigStoreURL == "" {
return errors.Errorf("gateway configStoreURL is empty")
if c.Gateway.ConfigstoreURL == "" {
return errors.Errorf("gateway configstoreURL is empty")
}
if c.Gateway.RunServiceURL == "" {
return errors.Errorf("gateway runServiceURL is empty")
@ -274,10 +274,10 @@ func Validate(c *Config) error {
}
// Configstore
if c.ConfigStore.DataDir == "" {
if c.Configstore.DataDir == "" {
return errors.Errorf("configstore dataDir is empty")
}
if err := validateWeb(&c.ConfigStore.Web); err != nil {
if err := validateWeb(&c.Configstore.Web); err != nil {
return errors.Wrapf(err, "configstore web configuration error")
}

View File

@ -26,8 +26,8 @@ import (
slog "github.com/sorintlab/agola/internal/log"
"github.com/sorintlab/agola/internal/objectstorage"
"github.com/sorintlab/agola/internal/services/config"
"github.com/sorintlab/agola/internal/services/configstore/api"
action "github.com/sorintlab/agola/internal/services/configstore/action"
"github.com/sorintlab/agola/internal/services/configstore/api"
"github.com/sorintlab/agola/internal/services/configstore/readdb"
"github.com/sorintlab/agola/internal/services/types"
"github.com/sorintlab/agola/internal/util"
@ -42,8 +42,8 @@ var level = zap.NewAtomicLevelAt(zapcore.InfoLevel)
var logger = slog.New(level)
var log = logger.Sugar()
type ConfigStore struct {
c *config.ConfigStore
type Configstore struct {
c *config.Configstore
e *etcd.Store
dm *datamanager.DataManager
readDB *readdb.ReadDB
@ -52,7 +52,7 @@ type ConfigStore struct {
listenAddress string
}
func NewConfigStore(ctx context.Context, c *config.ConfigStore) (*ConfigStore, error) {
func NewConfigstore(ctx context.Context, c *config.Configstore) (*Configstore, error) {
if c.Debug {
level.SetLevel(zapcore.DebugLevel)
}
@ -66,7 +66,7 @@ func NewConfigStore(ctx context.Context, c *config.ConfigStore) (*ConfigStore, e
return nil, err
}
cs := &ConfigStore{
cs := &Configstore{
c: c,
e: e,
ost: ost,
@ -104,7 +104,7 @@ func NewConfigStore(ctx context.Context, c *config.ConfigStore) (*ConfigStore, e
return cs, nil
}
func (s *ConfigStore) Run(ctx context.Context) error {
func (s *Configstore) Run(ctx context.Context) error {
errCh := make(chan error)
dmReadyCh := make(chan struct{})

View File

@ -55,7 +55,7 @@ func shutdownEtcd(tetcd *testutil.TestEmbeddedEtcd) {
}
}
func setupConfigstore(t *testing.T, ctx context.Context, dir string) (*ConfigStore, *testutil.TestEmbeddedEtcd) {
func setupConfigstore(t *testing.T, ctx context.Context, dir string) (*Configstore, *testutil.TestEmbeddedEtcd) {
etcdDir, err := ioutil.TempDir(dir, "etcd")
tetcd := setupEtcd(t, etcdDir)
@ -67,7 +67,7 @@ func setupConfigstore(t *testing.T, ctx context.Context, dir string) (*ConfigSto
ostDir, err := ioutil.TempDir(dir, "ost")
csDir, err := ioutil.TempDir(dir, "cs")
baseConfig := config.ConfigStore{
baseConfig := config.Configstore{
Etcd: config.Etcd{
Endpoints: tetcd.Endpoint,
},
@ -81,7 +81,7 @@ func setupConfigstore(t *testing.T, ctx context.Context, dir string) (*ConfigSto
csConfig.DataDir = csDir
csConfig.Web.ListenAddress = net.JoinHostPort(listenAddress, port)
cs, err := NewConfigStore(ctx, &csConfig)
cs, err := NewConfigstore(ctx, &csConfig)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -89,7 +89,7 @@ func setupConfigstore(t *testing.T, ctx context.Context, dir string) (*ConfigSto
return cs, tetcd
}
func getProjects(cs *ConfigStore) ([]*types.Project, error) {
func getProjects(cs *Configstore) ([]*types.Project, error) {
var projects []*types.Project
err := cs.readDB.Do(func(tx *db.Tx) error {
var err error
@ -99,7 +99,7 @@ func getProjects(cs *ConfigStore) ([]*types.Project, error) {
return projects, err
}
func getUsers(cs *ConfigStore) ([]*types.User, error) {
func getUsers(cs *Configstore) ([]*types.User, error) {
var users []*types.User
err := cs.readDB.Do(func(tx *db.Tx) error {
var err error
@ -140,7 +140,7 @@ func TestResync(t *testing.T) {
csDir2, err := ioutil.TempDir(dir, "cs2")
csDir3, err := ioutil.TempDir(dir, "cs3")
baseConfig := config.ConfigStore{
baseConfig := config.Configstore{
Etcd: config.Etcd{
Endpoints: tetcd.Endpoint,
},
@ -158,11 +158,11 @@ func TestResync(t *testing.T) {
cs2Config.DataDir = csDir2
cs2Config.Web.ListenAddress = net.JoinHostPort(listenAddress2, port2)
cs1, err := NewConfigStore(ctx, &cs1Config)
cs1, err := NewConfigstore(ctx, &cs1Config)
if err != nil {
t.Fatalf("err: %v", err)
}
cs2, err := NewConfigStore(ctx, &cs2Config)
cs2, err := NewConfigstore(ctx, &cs2Config)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -215,7 +215,7 @@ func TestResync(t *testing.T) {
// start cs2
// it should resync from wals since the etcd revision as been compacted
cs2, err = NewConfigStore(ctx, &cs2Config)
cs2, err = NewConfigstore(ctx, &cs2Config)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -249,7 +249,7 @@ func TestResync(t *testing.T) {
cs3Config.Web.ListenAddress = net.JoinHostPort(listenAddress3, port3)
log.Infof("starting cs3")
cs3, err := NewConfigStore(ctx, &cs3Config)
cs3, err := NewConfigstore(ctx, &cs3Config)
if err != nil {
t.Fatalf("err: %v", err)
}

View File

@ -121,7 +121,7 @@ func NewGateway(gc *config.Config) (*Gateway, error) {
return nil, err
}
configstoreClient := csapi.NewClient(c.ConfigStoreURL)
configstoreClient := csapi.NewClient(c.ConfigstoreURL)
runserviceClient := rsapi.NewClient(c.RunServiceURL)
ah := action.NewActionHandler(logger, sd, configstoreClient, runserviceClient, gc.ID, c.APIExposedURL, c.WebExposedURL)