From 658fbb94d5f0e9c10e8753d227bb16c287065ee1 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Thu, 7 Aug 2025 15:14:27 +0100 Subject: Initial commit --- 0001-Update-directories-fig-searches.patch | 63 ++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 0001-Update-directories-fig-searches.patch (limited to '0001-Update-directories-fig-searches.patch') diff --git a/0001-Update-directories-fig-searches.patch b/0001-Update-directories-fig-searches.patch new file mode 100644 index 0000000..b45990e --- /dev/null +++ b/0001-Update-directories-fig-searches.patch @@ -0,0 +1,63 @@ +From 0d47544d12656be9eb853f8323f0da19eec2316c Mon Sep 17 00:00:00 2001 +From: Leonardo Bishop +Date: Thu, 7 Aug 2025 12:00:20 +0100 +Subject: [PATCH] Update directories fig searches + +--- + walrss/internal/state/state.go | 23 ++++++++++------------- + 1 file changed, 10 insertions(+), 13 deletions(-) + +diff --git a/walrss/internal/state/state.go b/walrss/internal/state/state.go +index 522e1bf..1fe33ee 100644 +--- a/walrss/internal/state/state.go ++++ b/walrss/internal/state/state.go +@@ -3,12 +3,13 @@ package state + import ( + "errors" + "fmt" ++ "os" ++ "strings" ++ + "github.com/kkyr/fig" + "github.com/rs/zerolog" + "github.com/rs/zerolog/log" + "github.com/uptrace/bun" +- "os" +- "strings" + ) + + type State struct { +@@ -48,23 +49,19 @@ type Config struct { + Debug bool `fig:"debug"` + } + ++const walrssConfigDirEnv = "WALRSS_CONFIG_DIR" + const configFilename = "config.yaml" + + func LoadConfig() (*Config, error) { +- // If the file doesn't exist, Fig will throw a hissy fit, so we should create a blank one if it doesn't exist +- if _, err := os.Stat(configFilename); err != nil { +- if errors.Is(err, os.ErrNotExist) { +- // If the file doesn't have contents, Fig will throw an EOF, despite `touch config.yaml` working fine. idk lol +- if err := os.WriteFile(configFilename, []byte("{}"), 0777); err != nil { +- return nil, err +- } +- } else { +- return nil, err +- } ++ var configDirs []string ++ ++ if config := os.Getenv(walrssConfigDirEnv); config != "" { ++ configDirs = append(configDirs, config) + } ++ configDirs = append(configDirs, ".") + + cfg := new(Config) +- if err := fig.Load(cfg); err != nil { ++ if err := fig.Load(cfg, fig.Dirs(configDirs...), fig.File(configFilename)); err != nil { + return nil, err + } + +-- +2.50.1 + -- cgit v1.2.3-70-g09d2