Open loads a Devbox config from a file or project directory. If path is a directory, Open looks for a well-known config name (such as devbox.json) within it. The error will be [ErrNotFound] if path is a valid directory without a config file. Open does not recursively search outside of path. See [Fi
(path string)
| 88 | // Open does not recursively search outside of path. See [Find] to load a config |
| 89 | // by walking up the directory tree. |
| 90 | func Open(path string) (*Config, error) { |
| 91 | start := time.Now() |
| 92 | slog.Debug("searching for config file (excluding parent directories)", "path", path) |
| 93 | |
| 94 | cfg, err := open(path) |
| 95 | |
| 96 | if err == nil { |
| 97 | slog.Debug("config file found", "path", cfg.Root.AbsRootPath, "dur", time.Since(start)) |
| 98 | } else { |
| 99 | slog.Error("config file search error", "err", err.Error(), "dur", time.Since(start)) |
| 100 | } |
| 101 | return cfg, err |
| 102 | } |
| 103 | |
| 104 | func open(path string) (*Config, error) { |
| 105 | // First try the happy path by assuming that path is a directory |