Add flag for testing embedded file system

This commit is contained in:
Eli Ribble 2026-02-09 21:39:47 +00:00
parent 316a94a6cf
commit 443a13afcf
No known key found for this signature in database
3 changed files with 10 additions and 3 deletions

View file

@ -3,7 +3,7 @@ testdata_dir = "testdata"
tmp_dir = "tmp" tmp_dir = "tmp"
[build] [build]
args_bin = [] args_bin = ["-prod"]
bin = "./tmp/nidus-sync" bin = "./tmp/nidus-sync"
cmd = "go build -o ./tmp/nidus-sync ." cmd = "go build -o ./tmp/nidus-sync ."
delay = 1000 delay = 1000

View file

@ -16,7 +16,7 @@ import (
//"strings" //"strings"
//"time" //"time"
//"github.com/Gleipnir-Technology/nidus-sync/config" "github.com/Gleipnir-Technology/nidus-sync/config"
//"github.com/aarondl/opt/null" //"github.com/aarondl/opt/null"
//"github.com/google/uuid" //"github.com/google/uuid"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
@ -36,7 +36,7 @@ type templateSystemDisk struct {
func LoadTemplates() error { func LoadTemplates() error {
_, err := os.Stat("html/template") _, err := os.Stat("html/template")
if err == nil { if err == nil && !config.IsProductionEnvironment() {
templates = templateSystemDisk{ templates = templateSystemDisk{
sourceFS: os.DirFS("./html/template"), sourceFS: os.DirFS("./html/template"),
} }

View file

@ -2,6 +2,7 @@ package main
import ( import (
"context" "context"
"flag"
"fmt" "fmt"
"net/http" "net/http"
"os" "os"
@ -38,6 +39,12 @@ func main() {
} }
log.Info().Msg("Starting...") log.Info().Msg("Starting...")
var prod = flag.Bool("prod", false, "Force into production mode")
flag.Parse()
if prod != nil && *prod {
log.Warn().Msg("Forcing production mode for testing templates")
config.Environment = "PRODUCTION"
}
err = sentry.Init(sentry.ClientOptions{ err = sentry.Init(sentry.ClientOptions{
Debug: false, //!config.IsProductionEnvironment(), Debug: false, //!config.IsProductionEnvironment(),
Dsn: config.SentryDSN, Dsn: config.SentryDSN,