Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion cmd/fusey/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand Down
Loading