diff --git a/cmd/conduit/root/config/config_test.go b/cmd/conduit/root/config/config_test.go index bd410949b..aa65d0153 100644 --- a/cmd/conduit/root/config/config_test.go +++ b/cmd/conduit/root/config/config_test.go @@ -56,8 +56,8 @@ func TestPrintStructOutput(t *testing.T) { "db.postgres.table: conduit_kv_store", "db.sqlite.table: conduit_kv_store", "api.enabled: true", - "http.address: :8080", - "grpc.address: :8084", + "api.http.address: :8080", + "api.grpc.address: :8084", "log.level: info", "log.format: cli", "pipelines.exit-on-degraded: false", diff --git a/cmd/conduit/root/run/run.go b/cmd/conduit/root/run/run.go index 4ec8ee877..1f0a9b832 100644 --- a/cmd/conduit/root/run/run.go +++ b/cmd/conduit/root/run/run.go @@ -68,6 +68,7 @@ func (c *RunCommand) Flags() []ecdysis.Flag { } c.Cfg = conduit.DefaultConfigWithBasePath(currentPath) + flags.SetDefault("test", true) flags.SetDefault("config.path", c.Cfg.ConduitCfgPath) flags.SetDefault("db.type", c.Cfg.DB.Type) flags.SetDefault("db.badger.path", c.Cfg.DB.Badger.Path) @@ -76,8 +77,8 @@ func (c *RunCommand) Flags() []ecdysis.Flag { flags.SetDefault("db.sqlite.path", c.Cfg.DB.SQLite.Path) flags.SetDefault("db.sqlite.table", c.Cfg.DB.SQLite.Table) flags.SetDefault("api.enabled", c.Cfg.API.Enabled) - flags.SetDefault("http.address", c.Cfg.API.HTTP.Address) - flags.SetDefault("grpc.address", c.Cfg.API.GRPC.Address) + flags.SetDefault("api.http.address", c.Cfg.API.HTTP.Address) + flags.SetDefault("api.grpc.address", c.Cfg.API.GRPC.Address) flags.SetDefault("log.level", c.Cfg.Log.Level) flags.SetDefault("log.format", c.Cfg.Log.Format) flags.SetDefault("connectors.path", c.Cfg.Connectors.Path) diff --git a/cmd/conduit/root/run/run_test.go b/cmd/conduit/root/run/run_test.go index 09f197617..535bc8561 100644 --- a/cmd/conduit/root/run/run_test.go +++ b/cmd/conduit/root/run/run_test.go @@ -39,8 +39,8 @@ func TestRunCommandFlags(t *testing.T) { {longName: "db.sqlite.path", usage: "path to sqlite3 DB"}, {longName: "db.sqlite.table", usage: "sqlite3 table in which to store data (will be created if it does not exist)"}, {longName: "api.enabled", usage: "enable HTTP and gRPC API"}, - {longName: "http.address", usage: "address for serving the HTTP API"}, - {longName: "grpc.address", usage: "address for serving the gRPC API"}, + {longName: "api.http.address", usage: "address for serving the HTTP API"}, + {longName: "api.grpc.address", usage: "address for serving the gRPC API"}, {longName: "log.level", usage: "sets logging level; accepts debug, info, warn, error, trace"}, {longName: "log.format", usage: "sets the format of the logging; accepts json, cli"}, {longName: "connectors.path", usage: "path to standalone connectors' directory"}, diff --git a/pkg/conduit/config.go b/pkg/conduit/config.go index 7c14e0621..d428249b4 100644 --- a/pkg/conduit/config.go +++ b/pkg/conduit/config.go @@ -39,47 +39,47 @@ const ( SchemaRegistryTypeBuiltin = "builtin" ) -type ConfigDB struct { - // When Driver is specified it takes precedence over other DB related - // fields. - Driver database.DB - - Type string `long:"db.type" usage:"database type; accepts badger,postgres,inmemory,sqlite"` - Badger struct { - Path string `long:"db.badger.path" usage:"path to badger DB"` - } - Postgres struct { - ConnectionString string `long:"db.postgres.connection-string" usage:"postgres connection string, may be a database URL or in PostgreSQL keyword/value format"` - Table string `long:"db.postgres.table" usage:"postgres table in which to store data (will be created if it does not exist)"` - } - SQLite struct { - Path string `long:"db.sqlite.path" usage:"path to sqlite3 DB"` - Table string `long:"db.sqlite.table" usage:"sqlite3 table in which to store data (will be created if it does not exist)"` - } -} +// Config holds all configurable values for Conduit. +type Config struct { + ConduitCfgPath string `long:"config.path" usage:"global conduit configuration file" default:"./conduit.yaml"` -type ConfigAPI struct { - Enabled bool `long:"api.enabled" usage:"enable HTTP and gRPC API"` - HTTP struct { - Address string `long:"http.address" usage:"address for serving the HTTP API"` - } - GRPC struct { - Address string `long:"grpc.address" usage:"address for serving the gRPC API"` + DB struct { + // When Driver is specified it takes precedence over other DB related + // fields. + Driver database.DB + + Type string `long:"db.type" usage:"database type; accepts badger,postgres,inmemory,sqlite"` + Badger struct { + Path string `long:"badger.path" usage:"path to badger DB"` + } + Postgres struct { + ConnectionString string `long:"db.postgres.connection-string" usage:"postgres connection string, may be a database URL or in PostgreSQL keyword/value format"` + Table string `long:"db.postgres.table" usage:"postgres table in which to store data (will be created if it does not exist)"` + } + SQLite struct { + Path string `long:"db.sqlite.path" usage:"path to sqlite3 DB"` + Table string `long:"db.sqlite.table" usage:"sqlite3 table in which to store data (will be created if it does not exist)"` + } } -} -type ConfigLog struct { - NewLogger func(level, format string) log.CtxLogger - Level string `long:"log.level" usage:"sets logging level; accepts debug, info, warn, error, trace"` - Format string `long:"log.format" usage:"sets the format of the logging; accepts json, cli"` -} + // TODO: Remove + Test bool `long:"test" usage:"testing" default:"true"` -// Config holds all configurable values for Conduit. -type Config struct { - ConduitCfgPath string `long:"config.path" usage:"global conduit configuration file" default:"./conduit.yaml"` - DB ConfigDB - API ConfigAPI - Log ConfigLog + API struct { + Enabled bool `long:"api.enabled" usage:"enable HTTP and gRPC API"` + HTTP struct { + Address string `long:"api.http.address" usage:"address for serving the HTTP API"` + } + GRPC struct { + Address string `long:"api.grpc.address" usage:"address for serving the gRPC API"` + } + } + + Log struct { + NewLogger func(level, format string) log.CtxLogger + Level string `long:"log.level" usage:"sets logging level; accepts debug, info, warn, error, trace"` + Format string `long:"log.format" usage:"sets the format of the logging; accepts json, cli"` + } Connectors struct { Path string `long:"connectors.path" usage:"path to standalone connectors' directory"` @@ -169,6 +169,9 @@ func DefaultConfigWithBasePath(basePath string) Config { cfg.SchemaRegistry.Type = SchemaRegistryTypeBuiltin + // TODO: remove once https://github.com/ConduitIO/conduit/issues/2062 is fixed (testing) + cfg.Test = true + cfg.ConnectorPlugins = builtin.DefaultBuiltinConnectors return cfg } @@ -256,10 +259,10 @@ func (c Config) Validate() error { if c.API.Enabled { if c.API.GRPC.Address == "" { - return requiredConfigFieldErr("grpc.address") + return requiredConfigFieldErr("api.grpc.address") } if c.API.HTTP.Address == "" { - return requiredConfigFieldErr("http.address") + return requiredConfigFieldErr("api.http.address") } } diff --git a/pkg/conduit/config_test.go b/pkg/conduit/config_test.go index b1026a26b..f01b5f1aa 100644 --- a/pkg/conduit/config_test.go +++ b/pkg/conduit/config_test.go @@ -95,7 +95,7 @@ func TestConfig_Validate(t *testing.T) { c.API.HTTP.Address = "" return c }, - want: requiredConfigFieldErr("http.address"), + want: requiredConfigFieldErr("api.http.address"), }, { name: "required GRPC address", @@ -103,7 +103,7 @@ func TestConfig_Validate(t *testing.T) { c.API.GRPC.Address = "" return c }, - want: requiredConfigFieldErr("grpc.address"), + want: requiredConfigFieldErr("api.grpc.address"), }, { name: "disabled API valid",