Skip to content

Commit

Permalink
Add hint to init command if no local lake exists (#4786)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattnibs authored Sep 28, 2023
1 parent f662ee1 commit 8119016
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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: ""

0 comments on commit 8119016

Please sign in to comment.