From 839449fafcc9198765cd8531292d0a1591f4ca69 Mon Sep 17 00:00:00 2001 From: Matthew Nibecker Date: Thu, 28 Sep 2023 12:16:16 -0500 Subject: [PATCH 1/2] Add hint to init command in no local lake exists --- cli/lakeflags/flags.go | 7 ++++++- cmd/zed/ztests/init-hint.yaml | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 cmd/zed/ztests/init-hint.yaml diff --git a/cli/lakeflags/flags.go b/cli/lakeflags/flags.go index 11566e78eb..b4678fba3c 100644 --- a/cli/lakeflags/flags.go +++ b/cli/lakeflags/flags.go @@ -11,6 +11,7 @@ import ( "github.com/brimdata/zed/api/client" "github.com/brimdata/zed/api/client/auth0" + "github.com/brimdata/zed/lake" "github.com/brimdata/zed/lake/api" "github.com/brimdata/zed/pkg/storage" "go.uber.org/zap" @@ -73,7 +74,11 @@ func (l *Flags) Open(ctx context.Context) (api.Interface, error) { } return api.NewRemoteLake(conn), nil } - return api.OpenLocalLake(ctx, zap.Must(zap.NewProduction()), uri.String()) + lk, err := api.OpenLocalLake(ctx, zap.Must(zap.NewProduction()), uri.String()) + if errors.Is(err, lake.ErrNotExist) { + return nil, fmt.Errorf("%w\n(hint: run 'zed init' to initialize lake at this location)", err) + } + return lk, err } func (l *Flags) AuthStore() *auth0.Store { diff --git a/cmd/zed/ztests/init-hint.yaml b/cmd/zed/ztests/init-hint.yaml new file mode 100644 index 0000000000..775177fa41 --- /dev/null +++ b/cmd/zed/ztests/init-hint.yaml @@ -0,0 +1,11 @@ +script: | + export ZED_LAKE=path/to/zed + ! zed ls + +outputs: + - name: stderr + regexp: | + .* lake does not exist + \(hint: run 'zed init' to initialize lake at this location\) + - name: stdout + data: "" From 15b9c07ad0ce556c0dd37b983e7cd7798afeb710 Mon Sep 17 00:00:00 2001 From: Matthew Nibecker Date: Thu, 28 Sep 2023 12:39:27 -0500 Subject: [PATCH 2/2] Update cmd/zed/ztests/init-hint.yaml Co-authored-by: Noah Treuhaft --- cmd/zed/ztests/init-hint.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/zed/ztests/init-hint.yaml b/cmd/zed/ztests/init-hint.yaml index 775177fa41..8fd6e8b288 100644 --- a/cmd/zed/ztests/init-hint.yaml +++ b/cmd/zed/ztests/init-hint.yaml @@ -1,6 +1,5 @@ script: | - export ZED_LAKE=path/to/zed - ! zed ls + ! zed -lake=path/to/zed ls outputs: - name: stderr