Skip to content

Commit 90f5639

Browse files
authored
feat(backends): allow backends to not have a metadata file (#5963)
In this case we generate one on the fly and we infer the metadata we can. Obviously this have the side effect of not being able to register potential aliases. Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent a35a701 commit 90f5639

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

core/gallery/backends.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,16 +250,22 @@ func ListSystemBackends(basePath string) (map[string]string, error) {
250250
for _, backend := range backends {
251251
if backend.IsDir() {
252252
runFile := filepath.Join(basePath, backend.Name(), runFile)
253-
// Skip if metadata file don't exist
253+
254+
var metadata *BackendMetadata
255+
256+
// If metadata file does not exist, we just use the directory name
257+
// and we do not fill the other metadata (such as potential backend Aliases)
254258
metadataFilePath := filepath.Join(basePath, backend.Name(), metadataFile)
255259
if _, err := os.Stat(metadataFilePath); os.IsNotExist(err) {
256-
continue
257-
}
258-
259-
// Check for alias in metadata
260-
metadata, err := readBackendMetadata(filepath.Join(basePath, backend.Name()))
261-
if err != nil {
262-
return nil, err
260+
metadata = &BackendMetadata{
261+
Name: backend.Name(),
262+
}
263+
} else {
264+
// Check for alias in metadata
265+
metadata, err = readBackendMetadata(filepath.Join(basePath, backend.Name()))
266+
if err != nil {
267+
return nil, err
268+
}
263269
}
264270

265271
if metadata == nil {

0 commit comments

Comments
 (0)