snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s

This commit is contained in:
upstream-mirror
2026-09-18 01:22:23 +05:00
commit 7e385fc126
8391 changed files with 1766236 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
package app
import (
"context"
"github.com/cortezaproject/corteza/extra/server-discovery/pkg/options"
"github.com/cortezaproject/corteza/server/pkg/logger"
"github.com/davecgh/go-spew/spew"
"github.com/elastic/go-elasticsearch/v7/esutil"
"github.com/go-chi/chi/v5"
"go.uber.org/zap"
)
type (
httpApiServer interface {
//MountRoutes(mm ...func(chi.Router))
//Serve(ctx context.Context)
Serve(ctx context.Context)
Activate(mm ...func(chi.Router))
Shutdown()
}
CortezaDiscoveryApp struct {
Opt *options.Options
lvl int
Log *zap.Logger
// Servers
HttpServer httpApiServer
}
)
var (
_ *spew.ConfigState = nil
_ esutil.BulkIndexer
)
func New() (app *CortezaDiscoveryApp, err error) {
app = &CortezaDiscoveryApp{
Log: logger.MakeDebugLogger().WithOptions(zap.AddStacktrace(zap.PanicLevel)),
}
app.Opt, err = options.Init()
if err != nil {
return
}
return
}
func (app CortezaDiscoveryApp) Serve(ctx context.Context) (err error) {
return
}
//func (app CortezaDiscoveryApp) InitService(ctx context.Context) (err error) {
// // Initialize indexer service
// err = indexer.Initialize(ctx, app.Log, indexer.Config{
// ES: app.Opt.ES,
// Indexer: app.Opt.Indexer,
// })
// if err != nil {
// return err
// }
//
// return
//}

View File

@@ -0,0 +1,128 @@
package app
import (
"context"
"fmt"
"github.com/cortezaproject/corteza/extra/server-discovery/indexer"
"github.com/cortezaproject/corteza/extra/server-discovery/pkg/auth"
"github.com/cortezaproject/corteza/extra/server-discovery/pkg/es"
"github.com/cortezaproject/corteza/extra/server-discovery/pkg/healthcheck"
"github.com/cortezaproject/corteza/extra/server-discovery/searcher"
)
const (
bootLevelWaiting = iota
bootLevelSetup
bootLevelStoreInitialized
bootLevelProvisioned
bootLevelServicesInitialized
bootLevelActivated
)
// Setup configures all required services
func (app *CortezaDiscoveryApp) Setup() (err error) {
app.lvl = bootLevelSetup
hcd := healthcheck.Defaults()
if app.Opt.Searcher.Enabled {
hcd.Add(searcher.Healthcheck, "OpenSearch")
}
return nil
}
// InitStore initializes open search store and runs upgrade procedures
func (app *CortezaDiscoveryApp) InitStore(ctx context.Context) (err error) {
if app.lvl >= bootLevelStoreInitialized {
// Is store already initialised?
return nil
} else if err = app.Setup(); err != nil {
// Initialize previous level
return err
}
app.lvl = bootLevelStoreInitialized
return nil
}
// Provision instance with configuration and settings
// by importing preset configurations and running autodiscovery procedures
func (app *CortezaDiscoveryApp) Provision(ctx context.Context) (err error) {
if app.lvl >= bootLevelProvisioned {
return
}
if err = app.InitStore(ctx); err != nil {
return err
}
app.lvl = bootLevelProvisioned
return
}
// InitServices initializes all services used
func (app *CortezaDiscoveryApp) InitServices(ctx context.Context) (err error) {
if app.lvl >= bootLevelServicesInitialized {
return nil
}
if err = app.Provision(ctx); err != nil {
return err
}
if auth.HttpTokenVerifier, err = auth.TokenVerifierMiddlewareWithSecretSigner(string(app.Opt.Searcher.JwtSecret)); err != nil {
return fmt.Errorf("could not set token verifier")
}
//initialize Elastic search client
esClient, err := es.Connect(app.Opt.ES)
if err != nil {
return fmt.Errorf("failed to initialize Elasticsearch client: %s", err.Error())
}
if app.Opt.Indexer.Enabled {
err = indexer.Initialize(ctx, app.Log, indexer.Config{
Corteza: app.Opt.Corteza,
ES: app.Opt.ES,
Indexer: app.Opt.Indexer,
}, esClient)
if err != nil {
return
}
}
if app.Opt.Searcher.Enabled {
err = searcher.Initialize(ctx, app.Log, searcher.Config{
Corteza: app.Opt.Corteza,
ES: app.Opt.ES,
HttpServer: app.Opt.HTTPServer,
Searcher: app.Opt.Searcher,
}, esClient)
if err != nil {
return
}
}
app.lvl = bootLevelServicesInitialized
return
}
// Activate start all internal services and watchers
func (app *CortezaDiscoveryApp) Activate(ctx context.Context) (err error) {
if app.lvl >= bootLevelActivated {
return
}
if err := app.InitServices(ctx); err != nil {
return err
}
if app.Opt.Indexer.Enabled {
go indexer.Watchers(ctx)
}
app.lvl = bootLevelActivated
return nil
}

View File

@@ -0,0 +1,35 @@
package app
import (
"strings"
searcherRest "github.com/cortezaproject/corteza/extra/server-discovery/searcher/rest"
"github.com/cortezaproject/corteza/server/pkg/options"
"github.com/go-chi/chi/v5"
"go.uber.org/zap"
)
func (app *CortezaDiscoveryApp) MountHttpRoutes(r chi.Router) {
var (
ho = app.Opt.HTTPServer
)
func() {
if !app.Opt.Searcher.Enabled {
app.Log.Info("JSON REST API disabled")
return
}
r.Route(options.CleanBase(ho.ApiBaseUrl), func(r chi.Router) {
var fullPathAPI = "/" + strings.TrimPrefix(options.CleanBase(ho.BaseUrl, ho.ApiBaseUrl), "/")
app.Log.Info(
"JSON REST API enabled",
zap.String("baseUrl", fullPathAPI),
)
r.Route("/", searcherRest.MountRoutes(app.Log))
})
}()
}