mirror of
https://github.com/mudler/LocalAI.git
synced 2026-10-28 17:18:49 -04:00
Add the add-on runtime to LocalAI: manifests, the host operation broker, admin gating by account role, the add-on UI bundle builder and the SDK for add-on pages. Move the navigation to Chat, Models, Add-ons and Settings, with pinned add-ons in the sidebar and an Add-ons drawer. Ship the first-party add-ons (voice, face, fine-tuning, quantization) as packages for linux/amd64, linux/arm64 and darwin/arm64. Intel macOS (darwin/amd64) is enabled in the platform files. Squashed from the review branch. The tree is unchanged; the pre-squash history is kept on a local backup branch. Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
59 lines
2.5 KiB
Go
59 lines
2.5 KiB
Go
// SPDX-License-Identifier: MIT
|
|
//go:build auth
|
|
|
|
package application
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/mudler/LocalAI/core/config"
|
|
"github.com/mudler/LocalAI/pkg/system"
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("auth database location at first start", func() {
|
|
It("creates a missing data directory before opening the default auth database", func() {
|
|
root := GinkgoT().TempDir()
|
|
models, backends := filepath.Join(root, "models"), filepath.Join(root, "backends")
|
|
Expect(os.Mkdir(models, 0750)).To(Succeed())
|
|
Expect(os.Mkdir(backends, 0750)).To(Succeed())
|
|
state, err := system.GetSystemState(system.WithBackendPath(backends), system.WithModelPath(models))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
data := filepath.Join(root, "not", "yet", "created")
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
var app *Application
|
|
app, err = New(config.WithContext(ctx), config.WithSystemState(state), config.WithDataPath(data),
|
|
config.WithAuthEnabled(true), config.WithAuthDatabaseURL(filepath.Join(data, "database.db")),
|
|
config.WithAuthAPIKeyHMACSecret("secret"))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
DeferCleanup(func() { cancel(); _ = app.Shutdown() })
|
|
Expect(app.AuthDB()).NotTo(BeNil())
|
|
info, err := os.Stat(data)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(info.Mode().Perm()&0o027).To(BeZero(), "directory keeps the 0750 semantics")
|
|
_, err = os.Stat(filepath.Join(data, "database.db"))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
})
|
|
It("creates the parent of an explicit sqlite path outside the data directory", func() {
|
|
root := GinkgoT().TempDir()
|
|
models, backends := filepath.Join(root, "models"), filepath.Join(root, "backends")
|
|
Expect(os.Mkdir(models, 0750)).To(Succeed())
|
|
Expect(os.Mkdir(backends, 0750)).To(Succeed())
|
|
state, err := system.GetSystemState(system.WithBackendPath(backends), system.WithModelPath(models))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
var app *Application
|
|
db := filepath.Join(root, "elsewhere", "auth", "users.db?_busy_timeout=2000")
|
|
app, err = New(config.WithContext(ctx), config.WithSystemState(state), config.WithDataPath(filepath.Join(root, "data")),
|
|
config.WithAuthEnabled(true), config.WithAuthDatabaseURL(db), config.WithAuthAPIKeyHMACSecret("secret"))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
DeferCleanup(func() { cancel(); _ = app.Shutdown() })
|
|
Expect(app.AuthDB()).NotTo(BeNil())
|
|
_, err = os.Stat(filepath.Join(root, "elsewhere", "auth", "users.db"))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
})
|
|
})
|