diff --git a/cmd/fusey/main.go b/cmd/fusey/main.go index 34f4c39..7487669 100644 --- a/cmd/fusey/main.go +++ b/cmd/fusey/main.go @@ -106,6 +106,7 @@ func main() { // the daemon failed; the parent exits non-zero and refers the user to the log. func runMount(mountpoint string) { cfg := mustLoadConfig() + requireStore(cfg) daemonID := newDaemonID() daemonDir := filepath.Join(cfg.CacheDir, daemonID) @@ -174,6 +175,7 @@ func runMount(mountpoint string) { // index, removes the PID file, and exits. func runDaemon(daemonID, mountpoint string) { cfg := mustLoadConfig() + requireStore(cfg) daemonDir := filepath.Join(cfg.CacheDir, daemonID) if err := os.MkdirAll(daemonDir, 0755); err != nil { @@ -318,6 +320,7 @@ func runUnmount(mountpoint string) { // updated index, and exits. Intended to be called from a Kubernetes CronJob. func runCompact() { cfg := mustLoadConfig() + requireStore(cfg) ctx := context.Background() objStore, cs := mustBuildStore(ctx, cfg) @@ -340,10 +343,17 @@ func mustLoadConfig() *config.Config { if err != nil { log.Fatalf("config: %v", err) } + return cfg +} + +// requireStore fatal-exits when neither FUSEY_BROKER_URL nor FUSEY_BUCKET is +// set. Only the mount, daemon, and compact paths need an object store; unmount +// operates purely on local PID files under FUSEY_CACHE_DIR and must not require +// store credentials. +func requireStore(cfg *config.Config) { if cfg.BrokerURL == "" && cfg.Bucket == "" { log.Fatal("either FUSEY_BROKER_URL or FUSEY_BUCKET is required") } - return cfg } // mustBuildStore constructs the appropriate ObjectStore based on config.