Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hint to init command if no local lake exists #4786

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion cli/lakeflags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions cmd/zed/ztests/init-hint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
script: |
! zed -lake=path/to/zed ls

outputs:
- name: stderr
regexp: |
.* lake does not exist
\(hint: run 'zed init' to initialize lake at this location\)
- name: stdout
data: ""