isle/go/cmd/entrypoint/bootstrap_util.go

27 lines
542 B
Go
Raw Normal View History

2022-10-26 22:23:39 +00:00
package main
import (
"errors"
"fmt"
"io/fs"
"isle/bootstrap"
2022-10-26 22:23:39 +00:00
)
2022-10-26 22:37:03 +00:00
func loadHostBootstrap() (bootstrap.Bootstrap, error) {
2022-10-26 22:23:39 +00:00
stateDirPath := bootstrap.StateDirPath(daemonEnvVars.StateDirPath)
2022-10-26 22:23:39 +00:00
hostBootstrap, err := bootstrap.FromFile(stateDirPath)
2022-10-26 22:23:39 +00:00
if errors.Is(err, fs.ErrNotExist) {
return bootstrap.Bootstrap{}, fmt.Errorf(
"%q not found, has the daemon ever been run?",
stateDirPath,
)
2022-10-26 22:23:39 +00:00
} else if err != nil {
return bootstrap.Bootstrap{}, fmt.Errorf("loading %q: %w", stateDirPath, err)
2022-10-26 22:23:39 +00:00
}
return hostBootstrap, nil
}