1
0

🏗️」 wip(Mariadb-entry): entrypoint starting to work

This commit is contained in:
2025-01-07 16:01:49 +01:00
parent 5a855b17d7
commit 108b42eb98
12 changed files with 266 additions and 32 deletions

34
internal/env/env_util.go vendored Normal file
View File

@ -0,0 +1,34 @@
package env
import (
"os"
"git.keyzox.me/42_adjoly/inception/internal/log"
)
func FileEnv(Value string, Default string) string {
val, is := os.LookupEnv(Value)
if is {
return val
} else {
val, is := os.LookupEnv(Value + "_FILE")
if is {
content, err := os.ReadFile(val)
if err != nil {
_log.Log("error", "Error reading file")
}
return string(content)
}
}
return Default
}
func EnvCheck(Value, Default string) string {
val, is := os.LookupEnv(Value)
if is {
return val
}
return Default
}

20
internal/log/log.go Normal file
View File

@ -0,0 +1,20 @@
package _log
import (
"fmt"
"os"
"time"
)
func Log(Type string, Log string) {
t := time.Now()
t.Format(time.RFC3339)
if Type == "note" {
fmt.Printf("%s-[%s] [Entrypoint]: %s\n", t, Type, Log)
} else if Type == "warn" {
fmt.Fprintf(os.Stderr ,"%s-[%s] [Entrypoint]: %s\n", t, Type, Log)
} else if Type == "error" {
fmt.Fprintf(os.Stderr ,"%s-[%s] [Entrypoint]: %s\n", t, Type, Log)
os.Exit(1)
}
}