Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
597e822
refactor: Log warn when no package found
teresaromero Oct 7, 2025
160ee72
Merge branch 'main' into 1351-empty-registry
teresaromero Nov 17, 2025
ee5afd8
Add flag to allow empty package paths on startup
teresaromero Nov 17, 2025
60a967d
Update indexer constructors to include watch interval parameter
teresaromero Nov 17, 2025
e4cb9b1
Update ensurePackagesAvailable function to accept serverOptions param…
teresaromero Nov 17, 2025
9844fc5
Add watchInterval parameter to FileSystemIndexer constructors
teresaromero Nov 17, 2025
624a848
Add packagePathsWatchInterval flag to control watch interval for pack…
teresaromero Nov 17, 2025
39e6423
lock read and write packages on fs watcher
teresaromero Nov 18, 2025
b65fd7a
Change log level from Info to Debug for package indexer watcher messages
teresaromero Nov 18, 2025
1ca31cf
Validate package paths configuration and log fatal error if none are set
teresaromero Nov 18, 2025
08e5d81
Use fsnotify for path watch
teresaromero Nov 18, 2025
ffa5cf5
Revert "Validate package paths configuration and log fatal error if n…
teresaromero Nov 18, 2025
165038d
Log fatal error if no package paths are configured when enabling watcher
teresaromero Nov 18, 2025
9fae69c
Fix typo in comment for SearchCacheTTL in Config struct
teresaromero Nov 18, 2025
95f239f
refactor debouncer at watcher and filter events by indexer
teresaromero Nov 21, 2025
c8fb821
Merge branch 'main' of github.com:elastic/package-registry into 1351-…
teresaromero Nov 21, 2025
9a5b55d
Add APM tracer support to FileSystemIndexer and ZipFileSystemIndexer
teresaromero Nov 21, 2025
dba6d8a
Update indexer initialization to use nil for the second parameter in …
teresaromero Nov 21, 2025
bcb985c
remove redundant log
teresaromero Nov 24, 2025
17c9f70
Refactor FileSystemIndexer initialization to use FSIndexerOptions struct
teresaromero Nov 24, 2025
f20c036
Add tests for FileSystemIndexer and ZipFileSystemIndexer functionality
teresaromero Nov 24, 2025
0231b20
Enhance event filtering in FileSystemIndexer to watch only relevant f…
teresaromero Nov 24, 2025
1afb4bc
Add TODO comment for issue #1488 in FileSystemIndexer watchPackageFil…
teresaromero Nov 24, 2025
a8b8a63
remove defer file close at createMockZipPackage
teresaromero Nov 25, 2025
6597ea9
Add missing file close in createMockZipPackage function
teresaromero Nov 25, 2025
b1f30cc
Improve Windows compatibility in FileSystemIndexer tests by adding de…
teresaromero Nov 25, 2025
f4b85c0
Revert "Improve Windows compatibility in FileSystemIndexer tests by a…
teresaromero Nov 25, 2025
7bb4530
Fix file closing in createMockZipPackage function to ensure proper re…
teresaromero Nov 25, 2025
2b5e470
Refactor createMockZipPackage to return the zip file path and ensure …
teresaromero Nov 25, 2025
c5353d0
Refactor TestFileSystemIndexer to initialize packageList directly and…
teresaromero Nov 25, 2025
718572e
Merge branch 'main' of github.com:elastic/package-registry into 1351-…
teresaromero Nov 26, 2025
4280300
Remove current transaction before starting new one in package file sy…
teresaromero Nov 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion categories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ func TestCategoriesWithProxyMode(t *testing.T) {
}))
defer webServer.Close()

indexerProxy := packages.NewFileSystemIndexer(testLogger, "./testdata/second_package_path")
fsOpts := packages.FSIndexerOptions{
Logger: testLogger,
}

indexerProxy := packages.NewFileSystemIndexer(fsOpts, "./testdata/second_package_path")
defer indexerProxy.Close(t.Context())

err := indexerProxy.Init(t.Context())
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ require (
github.com/elastic/go-windows v1.0.2 // indirect
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
github.com/fsnotify/fsnotify v1.9.0
github.com/go-jose/go-jose/v4 v4.1.2 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/fsouza/fake-gcs-server v1.52.3 h1:hXddOPMGDKq5ENmttw6xkodVJy0uVhf7HhWvQgAOH6g=
github.com/fsouza/fake-gcs-server v1.52.3/go.mod h1:A0XtSRX+zz5pLRAt88j9+Of0omQQW+RMqipFbvdNclQ=
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
Expand Down
25 changes: 21 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ var (
proxyTo string
serviceName = getServiceName()

packagePathsEnableWatcher = false

defaultConfig = Config{
CacheTimeIndex: 10 * time.Second,
CacheTimeSearch: 10 * time.Minute,
Expand Down Expand Up @@ -128,6 +130,8 @@ func init() {
// The following proxy-indexer related flags are technical preview and might be removed in the future or renamed
flag.BoolVar(&featureProxyMode, "feature-proxy-mode", false, "Enable proxy mode to include packages from other endpoint (technical preview).")
flag.StringVar(&proxyTo, "proxy-to", "https://epr.elastic.co/", "Proxy-to endpoint")

flag.BoolVar(&packagePathsEnableWatcher, "package-paths-enable-watcher", false, "Enable file system watcher for package paths to automatically detect new packages.")
}

type Config struct {
Expand All @@ -138,9 +142,9 @@ type Config struct {
CacheTimeCatchAll time.Duration `config:"cache_time.catch_all"`
SQLIndexerDatabaseFolderPath string `config:"sql_indexer.database_folder_path"` // technical preview, used by the SQL storage indexer
SearchCacheSize int `config:"search.cache_size"` // technical preview, used by the SQL storage indexer
SearchCacheTTL time.Duration `config:"search.cache_ttl"` // technical preview, used by the SQL storage indexe^
SearchCacheTTL time.Duration `config:"search.cache_ttl"` // technical preview, used by the SQL storage indexer
CategoriesCacheSize int `config:"categories.cache_size"` // technical preview, used by the SQL storage indexer
CategoriesCacheTTL time.Duration `config:"categories.cache_ttl"` // technical preview, used by the SQL storage indexe^
CategoriesCacheTTL time.Duration `config:"categories.cache_ttl"` // technical preview, used by the SQL storage indexer
}

func main() {
Expand Down Expand Up @@ -179,6 +183,10 @@ func main() {

config := mustLoadConfig(logger)

if len(config.PackagePaths) == 0 && packagePathsEnableWatcher {
logger.Fatal("no package paths configured, cannot enable watcher")
}

options := serverOptions{
apmTracer: apmTracer,
config: config,
Expand Down Expand Up @@ -388,9 +396,15 @@ func initIndexer(ctx context.Context, logger *zap.Logger, options serverOptions)
combined = append(combined, indexer)
}

fsOptions := packages.FSIndexerOptions{
Logger: logger,
EnablePathsWatcher: packagePathsEnableWatcher,
APMTracer: options.apmTracer,
}

combined = append(combined,
packages.NewZipFileSystemIndexer(logger, packagesBasePaths...),
packages.NewFileSystemIndexer(logger, packagesBasePaths...),
packages.NewZipFileSystemIndexer(fsOptions, packagesBasePaths...),
packages.NewFileSystemIndexer(fsOptions, packagesBasePaths...),
)
ensurePackagesAvailable(ctx, logger, combined)
return combined
Expand Down Expand Up @@ -574,6 +588,7 @@ func getConfig(logger *zap.Logger) (*Config, error) {
}
config.CategoriesCacheTTL = cacheTTL
}

return &config, nil
}

Expand Down Expand Up @@ -619,6 +634,8 @@ func ensurePackagesAvailable(ctx context.Context, logger *zap.Logger, indexer In
logger.Info(fmt.Sprintf("%v local package manifests loaded.", len(packages)))
} else if featureProxyMode {
logger.Info("No local packages found, but the proxy mode can access remote ones.")
} else if packagePathsEnableWatcher {
logger.Warn("No packages found at startup. The registry is running but no content is available yet.")
} else {
logger.Fatal("No local packages found.")
}
Expand Down
72 changes: 55 additions & 17 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ func TestRouter(t *testing.T) {

func TestEndpoints(t *testing.T) {
t.Parallel()
fsOpts := packages.FSIndexerOptions{
Logger: testLogger,
}

packagesBasePaths := []string{"./testdata/second_package_path", "./testdata/package"}
indexer := NewCombinedIndexer(
packages.NewZipFileSystemIndexer(testLogger, "./testdata/local-storage"),
packages.NewFileSystemIndexer(testLogger, packagesBasePaths...),
packages.NewZipFileSystemIndexer(fsOpts, "./testdata/local-storage"),
packages.NewFileSystemIndexer(fsOpts, packagesBasePaths...),
)
t.Cleanup(func() { indexer.Close(context.Background()) })

Expand Down Expand Up @@ -171,8 +174,12 @@ func TestEndpoints(t *testing.T) {
func TestArtifacts(t *testing.T) {
t.Parallel()

fsOpts := packages.FSIndexerOptions{
Logger: testLogger,
}

packagesBasePaths := []string{"./testdata/package"}
indexer := packages.NewFileSystemIndexer(testLogger, packagesBasePaths...)
indexer := packages.NewFileSystemIndexer(fsOpts, packagesBasePaths...)
t.Cleanup(func() { indexer.Close(context.Background()) })

err := indexer.Init(t.Context())
Expand Down Expand Up @@ -203,7 +210,10 @@ func TestArtifacts(t *testing.T) {
func TestSignatures(t *testing.T) {
t.Parallel()

indexer := packages.NewZipFileSystemIndexer(testLogger, "./testdata/local-storage")
fsOpts := packages.FSIndexerOptions{
Logger: testLogger,
}
indexer := packages.NewZipFileSystemIndexer(fsOpts, "./testdata/local-storage")
t.Cleanup(func() { indexer.Close(context.Background()) })

err := indexer.Init(t.Context())
Expand Down Expand Up @@ -232,8 +242,11 @@ func TestSignatures(t *testing.T) {
func TestStatics(t *testing.T) {
t.Parallel()

fsOpts := packages.FSIndexerOptions{
Logger: testLogger,
}
packagesBasePaths := []string{"./testdata/package"}
indexer := packages.NewFileSystemIndexer(testLogger, packagesBasePaths...)
indexer := packages.NewFileSystemIndexer(fsOpts, packagesBasePaths...)
t.Cleanup(func() { indexer.Close(context.Background()) })

err := indexer.Init(t.Context())
Expand Down Expand Up @@ -324,9 +337,13 @@ func TestStaticsModifiedTime(t *testing.T) {
},
}

fsOpts := packages.FSIndexerOptions{
Logger: testLogger,
}

indexer := NewCombinedIndexer(
packages.NewZipFileSystemIndexer(testLogger, "./testdata/local-storage"),
packages.NewFileSystemIndexer(testLogger, "./testdata/package"),
packages.NewZipFileSystemIndexer(fsOpts, "./testdata/local-storage"),
packages.NewFileSystemIndexer(fsOpts, "./testdata/package"),
)
t.Cleanup(func() { indexer.Close(context.Background()) })

Expand Down Expand Up @@ -361,7 +378,11 @@ func TestStaticsModifiedTime(t *testing.T) {
func TestZippedArtifacts(t *testing.T) {
t.Parallel()

indexer := packages.NewZipFileSystemIndexer(testLogger, "./testdata/local-storage")
fsOpts := packages.FSIndexerOptions{
Logger: testLogger,
}

indexer := packages.NewZipFileSystemIndexer(fsOpts, "./testdata/local-storage")
t.Cleanup(func() { indexer.Close(context.Background()) })

err := indexer.Init(t.Context())
Expand Down Expand Up @@ -395,10 +416,12 @@ func TestZippedArtifacts(t *testing.T) {

func TestPackageIndex(t *testing.T) {
t.Parallel()

fsOpts := packages.FSIndexerOptions{
Logger: testLogger,
}
indexer := NewCombinedIndexer(
packages.NewZipFileSystemIndexer(testLogger, "./testdata/local-storage"),
packages.NewFileSystemIndexer(testLogger, "./testdata/package"),
packages.NewZipFileSystemIndexer(fsOpts, "./testdata/local-storage"),
packages.NewFileSystemIndexer(fsOpts, "./testdata/package"),
)
t.Cleanup(func() { indexer.Close(context.Background()) })

Expand Down Expand Up @@ -435,8 +458,11 @@ func TestPackageIndex(t *testing.T) {
func TestZippedPackageIndex(t *testing.T) {
t.Parallel()

fsOpts := packages.FSIndexerOptions{
Logger: testLogger,
}
packagesBasePaths := []string{"./testdata/local-storage"}
indexer := packages.NewZipFileSystemIndexer(testLogger, packagesBasePaths...)
indexer := packages.NewZipFileSystemIndexer(fsOpts, packagesBasePaths...)
t.Cleanup(func() { indexer.Close(context.Background()) })

err := indexer.Init(t.Context())
Expand Down Expand Up @@ -468,10 +494,14 @@ func TestZippedPackageIndex(t *testing.T) {
func TestAllPackageIndex(t *testing.T) {
t.Parallel()

fsOpts := packages.FSIndexerOptions{
Logger: testLogger,
}

testPackagePath := filepath.Join("testdata", "package")
secondPackagePath := filepath.Join("testdata", "second_package_path")
packagesBasePaths := []string{secondPackagePath, testPackagePath}
indexer := packages.NewFileSystemIndexer(testLogger, packagesBasePaths...)
indexer := packages.NewFileSystemIndexer(fsOpts, packagesBasePaths...)
t.Cleanup(func() { indexer.Close(context.Background()) })

err := indexer.Init(t.Context())
Expand Down Expand Up @@ -528,9 +558,13 @@ func TestContentTypes(t *testing.T) {
{"/package/example/1.0.1/img/kibana-envoyproxy.jpg", "image/jpeg"},
}

fsOpts := packages.FSIndexerOptions{
Logger: testLogger,
}

indexer := NewCombinedIndexer(
packages.NewZipFileSystemIndexer(testLogger, "./testdata/local-storage"),
packages.NewFileSystemIndexer(testLogger, "./testdata/package"),
packages.NewZipFileSystemIndexer(fsOpts, "./testdata/local-storage"),
packages.NewFileSystemIndexer(fsOpts, "./testdata/package"),
)
t.Cleanup(func() { indexer.Close(context.Background()) })

Expand Down Expand Up @@ -562,9 +596,13 @@ func TestContentTypes(t *testing.T) {
func TestRangeDownloads(t *testing.T) {
t.Parallel()

fsOpts := packages.FSIndexerOptions{
Logger: testLogger,
}

indexer := NewCombinedIndexer(
packages.NewZipFileSystemIndexer(testLogger, "./testdata/local-storage"),
packages.NewFileSystemIndexer(testLogger, "./testdata/package"),
packages.NewZipFileSystemIndexer(fsOpts, "./testdata/local-storage"),
packages.NewFileSystemIndexer(fsOpts, "./testdata/package"),
)
t.Cleanup(func() { indexer.Close(context.Background()) })

Expand Down
11 changes: 9 additions & 2 deletions packages/marshaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ var generateFlag = flag.Bool("generate", false, "Write golden files")
func TestMarshalJSON(t *testing.T) {
// given
packagesBasePaths := []string{"../testdata/second_package_path", "../testdata/package"}
indexer := NewFileSystemIndexer(util.NewTestLogger(), packagesBasePaths...)
fsOpts := FSIndexerOptions{
Logger: util.NewTestLogger(),
}
indexer := NewFileSystemIndexer(fsOpts, packagesBasePaths...)
defer indexer.Close(t.Context())

err := indexer.Init(t.Context())
Expand All @@ -39,8 +42,12 @@ func TestMarshalJSON(t *testing.T) {

func TestUnmarshalJSON(t *testing.T) {
// given

fsOpts := FSIndexerOptions{
Logger: util.NewTestLogger(),
}
packagesBasePaths := []string{"../testdata/second_package_path", "../testdata/package"}
indexer := NewFileSystemIndexer(util.NewTestLogger(), packagesBasePaths...)
indexer := NewFileSystemIndexer(fsOpts, packagesBasePaths...)
defer indexer.Close(t.Context())

err := indexer.Init(t.Context())
Expand Down
Loading