Add embed Filesystem

This commit is contained in:
Thomas Miceli
2023-03-24 14:41:08 +01:00
parent c1ad78d984
commit f9f5b140b8
3 changed files with 61 additions and 8 deletions

View File

@ -1,9 +1,12 @@
package main
import (
"embed"
"flag"
"fmt"
"github.com/rs/zerolog/log"
"opengist/internal/config"
"opengist/internal/git"
"opengist/internal/models"
"opengist/internal/ssh"
"opengist/internal/web"
@ -11,6 +14,9 @@ import (
"path/filepath"
)
//go:embed templates/*/*.html public/manifest.json public/assets/*.js public/assets/*.css public/assets/*.svg
var embedFS embed.FS
func initialize() {
configPath := flag.String("config", "config.yml", "Path to a config file in YML format")
flag.Parse()
@ -25,8 +31,20 @@ func initialize() {
config.InitLog()
log.Info().Msg("Opengist v" + config.OpengistVersion)
log.Info().Msg("Using config file: " + absolutePath)
fmt.Println("Opengist v" + config.OpengistVersion)
fmt.Println("Using config file: " + absolutePath)
gitVersion, err := git.GetGitVersion()
if err != nil {
log.Fatal().Err(err).Send()
}
if ok, err := config.CheckGitVersion(gitVersion); err != nil {
log.Fatal().Err(err).Send()
} else if !ok {
log.Warn().Msg("Git version may be too old, as Opengist has not been tested prior git version 2.20. " +
"Current git version: " + gitVersion)
}
homePath := config.GetHomeDir()
log.Info().Msg("Data directory: " + homePath)
@ -42,6 +60,8 @@ func initialize() {
if err := models.Setup(filepath.Join(homePath, config.C.DBFilename)); err != nil {
log.Fatal().Err(err).Msg("Failed to initialize database")
}
web.EmbedFS = embedFS
}
func main() {