pass configuration directory as arg

This commit is contained in:
rmanach 2025-05-08 15:26:10 +02:00
parent 7c01fa438c
commit 18605a76e1

11
main.go
View File

@ -219,10 +219,10 @@ func initLogger(debug bool) {
}
// loadHMMap loads your instance configuration map from `$HOME/.homeserver` dir.
func loadHMMap() (models.HMMap, error) {
func loadHMMap(baseDir string) (models.HMMap, error) {
var hmmap models.HMMap
hmmap_path := path.Join(HOME_PATH, HMDeployDirname, NetworkFilename)
hmmap_path := path.Join(baseDir, NetworkFilename)
c, err := os.ReadFile(hmmap_path)
if err != nil {
return hmmap, fmt.Errorf(
@ -428,6 +428,11 @@ func main() { //nolint: funlen // TODO: to reduce
)
projectDir := flag.String("path", ".", "define the .homeserver project root dir")
configDir := flag.String(
"config",
path.Join(HOME_PATH, HMDeployDirname),
"define the configuration directory",
)
destroy := flag.Bool("destroy", false, "delete the deployed project")
noNginx := flag.Bool("no-nginx", false, "no Nginx deployment")
noSwarm := flag.Bool("no-swarm", false, "no Swarm deployment")
@ -448,7 +453,7 @@ func main() { //nolint: funlen // TODO: to reduce
initLogger(*debug)
hmmap, err := loadHMMap()
hmmap, err := loadHMMap(*configDir)
if err != nil {
log.Fatal().Err(err).Msg("failed to load conf")
}