*: rename ConfigStore to Configstore
This commit is contained in:
parent
e4e7de4ad2
commit
44d5b0f25a
|
@ -155,9 +155,9 @@ func serve(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var cs *configstore.ConfigStore
|
var cs *configstore.Configstore
|
||||||
if isComponentEnabled("configstore") {
|
if isComponentEnabled("configstore") {
|
||||||
cs, err = configstore.NewConfigStore(ctx, &c.ConfigStore)
|
cs, err = configstore.NewConfigstore(ctx, &c.Configstore)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "failed to start config store")
|
return errors.Wrapf(err, "failed to start config store")
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ gateway:
|
||||||
apiExposedURL: "http://172.17.0.1:8000"
|
apiExposedURL: "http://172.17.0.1:8000"
|
||||||
webExposedURL: "http://172.17.0.1:8080"
|
webExposedURL: "http://172.17.0.1:8080"
|
||||||
runServiceURL: "http://localhost:4000"
|
runServiceURL: "http://localhost:4000"
|
||||||
configStoreURL: "http://localhost:4002"
|
configstoreURL: "http://localhost:4002"
|
||||||
gitServerURL: "http://172.17.0.1:4003"
|
gitServerURL: "http://172.17.0.1:4003"
|
||||||
|
|
||||||
web:
|
web:
|
||||||
|
@ -20,7 +20,7 @@ gateway:
|
||||||
scheduler:
|
scheduler:
|
||||||
runServiceURL: "http://localhost:4000"
|
runServiceURL: "http://localhost:4000"
|
||||||
|
|
||||||
configStore:
|
configstore:
|
||||||
dataDir: /tmp/agola/configstore
|
dataDir: /tmp/agola/configstore
|
||||||
etcd:
|
etcd:
|
||||||
endpoints: "http://localhost:2379"
|
endpoints: "http://localhost:2379"
|
||||||
|
|
|
@ -37,7 +37,7 @@ type Config struct {
|
||||||
Scheduler Scheduler `yaml:"scheduler"`
|
Scheduler Scheduler `yaml:"scheduler"`
|
||||||
RunServiceScheduler RunServiceScheduler `yaml:"runServiceScheduler"`
|
RunServiceScheduler RunServiceScheduler `yaml:"runServiceScheduler"`
|
||||||
RunServiceExecutor RunServiceExecutor `yaml:"runServiceExecutor"`
|
RunServiceExecutor RunServiceExecutor `yaml:"runServiceExecutor"`
|
||||||
ConfigStore ConfigStore `yaml:"configStore"`
|
Configstore Configstore `yaml:"configstore"`
|
||||||
GitServer GitServer `yaml:"gitServer"`
|
GitServer GitServer `yaml:"gitServer"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ type Gateway struct {
|
||||||
WebExposedURL string `yaml:"webExposedURL"`
|
WebExposedURL string `yaml:"webExposedURL"`
|
||||||
|
|
||||||
RunServiceURL string `yaml:"runServiceURL"`
|
RunServiceURL string `yaml:"runServiceURL"`
|
||||||
ConfigStoreURL string `yaml:"configStoreURL"`
|
ConfigstoreURL string `yaml:"configstoreURL"`
|
||||||
GitServerURL string `yaml:"gitServerURL"`
|
GitServerURL string `yaml:"gitServerURL"`
|
||||||
|
|
||||||
Web Web `yaml:"web"`
|
Web Web `yaml:"web"`
|
||||||
|
@ -98,7 +98,7 @@ type RunServiceExecutor struct {
|
||||||
ActiveTasksLimit int `yaml:"active_tasks_limit"`
|
ActiveTasksLimit int `yaml:"active_tasks_limit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfigStore struct {
|
type Configstore struct {
|
||||||
Debug bool `yaml:"debug"`
|
Debug bool `yaml:"debug"`
|
||||||
|
|
||||||
DataDir string `yaml:"dataDir"`
|
DataDir string `yaml:"dataDir"`
|
||||||
|
@ -263,8 +263,8 @@ func Validate(c *Config) error {
|
||||||
if c.Gateway.WebExposedURL == "" {
|
if c.Gateway.WebExposedURL == "" {
|
||||||
return errors.Errorf("gateway webExposedURL is empty")
|
return errors.Errorf("gateway webExposedURL is empty")
|
||||||
}
|
}
|
||||||
if c.Gateway.ConfigStoreURL == "" {
|
if c.Gateway.ConfigstoreURL == "" {
|
||||||
return errors.Errorf("gateway configStoreURL is empty")
|
return errors.Errorf("gateway configstoreURL is empty")
|
||||||
}
|
}
|
||||||
if c.Gateway.RunServiceURL == "" {
|
if c.Gateway.RunServiceURL == "" {
|
||||||
return errors.Errorf("gateway runServiceURL is empty")
|
return errors.Errorf("gateway runServiceURL is empty")
|
||||||
|
@ -274,10 +274,10 @@ func Validate(c *Config) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configstore
|
// Configstore
|
||||||
if c.ConfigStore.DataDir == "" {
|
if c.Configstore.DataDir == "" {
|
||||||
return errors.Errorf("configstore dataDir is empty")
|
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")
|
return errors.Wrapf(err, "configstore web configuration error")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@ import (
|
||||||
slog "github.com/sorintlab/agola/internal/log"
|
slog "github.com/sorintlab/agola/internal/log"
|
||||||
"github.com/sorintlab/agola/internal/objectstorage"
|
"github.com/sorintlab/agola/internal/objectstorage"
|
||||||
"github.com/sorintlab/agola/internal/services/config"
|
"github.com/sorintlab/agola/internal/services/config"
|
||||||
"github.com/sorintlab/agola/internal/services/configstore/api"
|
|
||||||
action "github.com/sorintlab/agola/internal/services/configstore/action"
|
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/configstore/readdb"
|
||||||
"github.com/sorintlab/agola/internal/services/types"
|
"github.com/sorintlab/agola/internal/services/types"
|
||||||
"github.com/sorintlab/agola/internal/util"
|
"github.com/sorintlab/agola/internal/util"
|
||||||
|
@ -42,8 +42,8 @@ var level = zap.NewAtomicLevelAt(zapcore.InfoLevel)
|
||||||
var logger = slog.New(level)
|
var logger = slog.New(level)
|
||||||
var log = logger.Sugar()
|
var log = logger.Sugar()
|
||||||
|
|
||||||
type ConfigStore struct {
|
type Configstore struct {
|
||||||
c *config.ConfigStore
|
c *config.Configstore
|
||||||
e *etcd.Store
|
e *etcd.Store
|
||||||
dm *datamanager.DataManager
|
dm *datamanager.DataManager
|
||||||
readDB *readdb.ReadDB
|
readDB *readdb.ReadDB
|
||||||
|
@ -52,7 +52,7 @@ type ConfigStore struct {
|
||||||
listenAddress string
|
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 {
|
if c.Debug {
|
||||||
level.SetLevel(zapcore.DebugLevel)
|
level.SetLevel(zapcore.DebugLevel)
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ func NewConfigStore(ctx context.Context, c *config.ConfigStore) (*ConfigStore, e
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cs := &ConfigStore{
|
cs := &Configstore{
|
||||||
c: c,
|
c: c,
|
||||||
e: e,
|
e: e,
|
||||||
ost: ost,
|
ost: ost,
|
||||||
|
@ -104,7 +104,7 @@ func NewConfigStore(ctx context.Context, c *config.ConfigStore) (*ConfigStore, e
|
||||||
return cs, nil
|
return cs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConfigStore) Run(ctx context.Context) error {
|
func (s *Configstore) Run(ctx context.Context) error {
|
||||||
errCh := make(chan error)
|
errCh := make(chan error)
|
||||||
dmReadyCh := make(chan struct{})
|
dmReadyCh := make(chan struct{})
|
||||||
|
|
||||||
|
|
|
@ -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")
|
etcdDir, err := ioutil.TempDir(dir, "etcd")
|
||||||
tetcd := setupEtcd(t, etcdDir)
|
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")
|
ostDir, err := ioutil.TempDir(dir, "ost")
|
||||||
csDir, err := ioutil.TempDir(dir, "cs")
|
csDir, err := ioutil.TempDir(dir, "cs")
|
||||||
|
|
||||||
baseConfig := config.ConfigStore{
|
baseConfig := config.Configstore{
|
||||||
Etcd: config.Etcd{
|
Etcd: config.Etcd{
|
||||||
Endpoints: tetcd.Endpoint,
|
Endpoints: tetcd.Endpoint,
|
||||||
},
|
},
|
||||||
|
@ -81,7 +81,7 @@ func setupConfigstore(t *testing.T, ctx context.Context, dir string) (*ConfigSto
|
||||||
csConfig.DataDir = csDir
|
csConfig.DataDir = csDir
|
||||||
csConfig.Web.ListenAddress = net.JoinHostPort(listenAddress, port)
|
csConfig.Web.ListenAddress = net.JoinHostPort(listenAddress, port)
|
||||||
|
|
||||||
cs, err := NewConfigStore(ctx, &csConfig)
|
cs, err := NewConfigstore(ctx, &csConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ func setupConfigstore(t *testing.T, ctx context.Context, dir string) (*ConfigSto
|
||||||
return cs, tetcd
|
return cs, tetcd
|
||||||
}
|
}
|
||||||
|
|
||||||
func getProjects(cs *ConfigStore) ([]*types.Project, error) {
|
func getProjects(cs *Configstore) ([]*types.Project, error) {
|
||||||
var projects []*types.Project
|
var projects []*types.Project
|
||||||
err := cs.readDB.Do(func(tx *db.Tx) error {
|
err := cs.readDB.Do(func(tx *db.Tx) error {
|
||||||
var err error
|
var err error
|
||||||
|
@ -99,7 +99,7 @@ func getProjects(cs *ConfigStore) ([]*types.Project, error) {
|
||||||
return projects, err
|
return projects, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUsers(cs *ConfigStore) ([]*types.User, error) {
|
func getUsers(cs *Configstore) ([]*types.User, error) {
|
||||||
var users []*types.User
|
var users []*types.User
|
||||||
err := cs.readDB.Do(func(tx *db.Tx) error {
|
err := cs.readDB.Do(func(tx *db.Tx) error {
|
||||||
var err error
|
var err error
|
||||||
|
@ -140,7 +140,7 @@ func TestResync(t *testing.T) {
|
||||||
csDir2, err := ioutil.TempDir(dir, "cs2")
|
csDir2, err := ioutil.TempDir(dir, "cs2")
|
||||||
csDir3, err := ioutil.TempDir(dir, "cs3")
|
csDir3, err := ioutil.TempDir(dir, "cs3")
|
||||||
|
|
||||||
baseConfig := config.ConfigStore{
|
baseConfig := config.Configstore{
|
||||||
Etcd: config.Etcd{
|
Etcd: config.Etcd{
|
||||||
Endpoints: tetcd.Endpoint,
|
Endpoints: tetcd.Endpoint,
|
||||||
},
|
},
|
||||||
|
@ -158,11 +158,11 @@ func TestResync(t *testing.T) {
|
||||||
cs2Config.DataDir = csDir2
|
cs2Config.DataDir = csDir2
|
||||||
cs2Config.Web.ListenAddress = net.JoinHostPort(listenAddress2, port2)
|
cs2Config.Web.ListenAddress = net.JoinHostPort(listenAddress2, port2)
|
||||||
|
|
||||||
cs1, err := NewConfigStore(ctx, &cs1Config)
|
cs1, err := NewConfigstore(ctx, &cs1Config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
cs2, err := NewConfigStore(ctx, &cs2Config)
|
cs2, err := NewConfigstore(ctx, &cs2Config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ func TestResync(t *testing.T) {
|
||||||
|
|
||||||
// start cs2
|
// start cs2
|
||||||
// it should resync from wals since the etcd revision as been compacted
|
// 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 {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ func TestResync(t *testing.T) {
|
||||||
cs3Config.Web.ListenAddress = net.JoinHostPort(listenAddress3, port3)
|
cs3Config.Web.ListenAddress = net.JoinHostPort(listenAddress3, port3)
|
||||||
|
|
||||||
log.Infof("starting cs3")
|
log.Infof("starting cs3")
|
||||||
cs3, err := NewConfigStore(ctx, &cs3Config)
|
cs3, err := NewConfigstore(ctx, &cs3Config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ func NewGateway(gc *config.Config) (*Gateway, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
configstoreClient := csapi.NewClient(c.ConfigStoreURL)
|
configstoreClient := csapi.NewClient(c.ConfigstoreURL)
|
||||||
runserviceClient := rsapi.NewClient(c.RunServiceURL)
|
runserviceClient := rsapi.NewClient(c.RunServiceURL)
|
||||||
|
|
||||||
ah := action.NewActionHandler(logger, sd, configstoreClient, runserviceClient, gc.ID, c.APIExposedURL, c.WebExposedURL)
|
ah := action.NewActionHandler(logger, sd, configstoreClient, runserviceClient, gc.ID, c.APIExposedURL, c.WebExposedURL)
|
||||||
|
|
Loading…
Reference in New Issue