From 9db8bd80500bfa0794f1c178667a16960cd1e671 Mon Sep 17 00:00:00 2001 From: Ethan Li Date: Fri, 12 Apr 2024 21:06:16 -0700 Subject: [PATCH] Don't fail in `stage` subcmds when --workspace is undefined but --stage-store is set (#180) --- CHANGELOG.md | 6 ++++++ cmd/forklift/stage/store.go | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd4c1203..5e1e0b9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## 0.7.0-alpha.3 - 2024-04-13 + +### Fixed + +- (cli) Subcommands under `stage` no longer require the workspace to be set via `--workspace` or `FORKLIFT_WORKSPACE` (which defaults to `$HOME`, which may be unset in systemd system services) if the path to the stage store is explicitly set via `--stage-store` or `FORKLIFT_STAGE_STORE`. + ## 0.7.0-alpha.2 - 2024-04-13 ### Added diff --git a/cmd/forklift/stage/store.go b/cmd/forklift/stage/store.go index aa563649..5bff2ef3 100644 --- a/cmd/forklift/stage/store.go +++ b/cmd/forklift/stage/store.go @@ -65,13 +65,20 @@ func loadNextBundle( return bundle, store, nil } -func getStageStore(wpath, sspath string, versions Versions) (*forklift.FSStageStore, error) { - workspace, err := forklift.LoadWorkspace(wpath) - if err != nil { - return nil, err +func getStageStore( + wpath, sspath string, versions Versions, +) (store *forklift.FSStageStore, err error) { + var workspace *forklift.FSWorkspace + if sspath == "" { + workspace, err = forklift.LoadWorkspace(wpath) + if err != nil { + return nil, errors.Wrap( + err, "couldn't load workspace to load the stage store, since no explicit path was "+ + "provided for the stage store", + ) + } } - store, err := fcli.GetStageStore(workspace, sspath, versions.NewStageStore) - if err != nil { + if store, err = fcli.GetStageStore(workspace, sspath, versions.NewStageStore); err != nil { return nil, err } return store, nil