Skip to content

Commit d20368b

Browse files
committed
cmd: fix hostd config write location
1 parent 148567c commit d20368b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cmd/hostd/config.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,13 @@ func setDataDirectory() {
262262
}
263263

264264
func buildConfig() {
265-
if _, err := os.Stat("hostd.yml"); err == nil {
265+
// write the config file
266+
configPath := "hostd.yml"
267+
if str := os.Getenv("HOSTD_CONFIG_FILE"); str != "" {
268+
configPath = str
269+
}
270+
271+
if _, err := os.Stat(configPath); err == nil {
266272
if !promptYesNo("hostd.yml already exists. Would you like to overwrite it?") {
267273
return
268274
}
@@ -297,7 +303,7 @@ func buildConfig() {
297303
setAdvancedConfig()
298304

299305
// write the config file
300-
f, err := os.Create("hostd.yml")
306+
f, err := os.Create(configPath)
301307
if err != nil {
302308
stdoutFatalError("failed to create config file: " + err.Error())
303309
return

0 commit comments

Comments
 (0)