remove sqlite support
1 file changed, 8 insertions(+), 57 deletions(-)
changed files
M domain/content/builder/build/main.go → domain/content/builder/build/main.go
@@ -1,18 +1,13 @@ package main import ( - "database/sql" "errors" "fmt" "os" - "path/filepath" "alin.ovh/homestead/domain/content/builder" "alin.ovh/homestead/shared/config" - "alin.ovh/homestead/shared/file" - "alin.ovh/homestead/shared/storage" "alin.ovh/homestead/shared/storage/files" - "alin.ovh/homestead/shared/storage/sqlite" "alin.ovh/homestead/shared/vcs" "alin.ovh/x/log"@@ -23,7 +18,6 @@ type Options struct { *builder.Options Destination string `conf:"default:./public,short:d,flag:dest"` Compress bool `conf:"default:true"` - Writer string `conf:"default:files,help:Output type (files|sqlite)"` } const branch = "main"@@ -48,59 +42,16 @@ panic("could not open repository: " + err.Error()) } options.Repo = repo - var storage storage.Writer - switch options.Writer { - case "files": - storage, err = files.NewWriter(options.Destination, log.Named("storage"), &files.Options{ + options.Storage, err = files.NewWriter( + options.Destination, + log.Named("storage"), + &files.Options{ Compress: options.Compress, - }) - if err != nil { - panic("could not create storage: " + err.Error()) - } - case "sqlite": - var stat os.FileInfo - stat, err = file.Stat(options.Destination) - if err != nil && !errors.Is(err, os.ErrNotExist) { - panic("could not stat destination: " + err.Error()) - } - switch { - case stat == nil: - err := os.MkdirAll(options.Destination, 0o750) - if err != nil { - panic("could not make directory: " + err.Error()) - } - case !stat.IsDir(): - panic("destination is not a directory") - default: - err := file.CleanDir(options.Destination) - if err != nil { - panic("could not clean destination: " + err.Error()) - } - } - - var db *sql.DB - db, err = sqlite.OpenDB(filepath.Join(options.Destination, "site.db")) - if err != nil { - panic("could not open database: " + err.Error()) - } - defer db.Close() - storage, err = sqlite.NewWriter(db, log.Named("storage"), &sqlite.Options{ - Compress: options.Compress, - }) - if err != nil { - panic("could not create storage: " + err.Error()) - } - err = file.Copy( - filepath.Join(options.Source, "config.toml"), - filepath.Join(options.Destination, "config.toml"), - ) - if err != nil { - panic("could not copy configuration: " + err.Error()) - } - default: - panic("unknown storage type: " + options.Writer) + }, + ) + if err != nil { + panic("could not create storage: " + err.Error()) } - options.Storage = storage log.Debug("starting build process") cfg, err := config.GetConfig(options.Source, log)