From 3571886fe7366cd8a907b75590291e694d1580ad Mon Sep 17 00:00:00 2001 From: aligeti <34487396+aligeti@users.noreply.github.com> Date: Thu, 13 Sep 2018 13:34:01 -0400 Subject: [PATCH] check uplink setup (#339) * check uplink setup * code review comments changes --- cmd/uplink/cmd/ls.go | 2 +- cmd/uplink/cmd/run.go | 12 ++++++++++++ pkg/storage/buckets/store.go | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cmd/uplink/cmd/ls.go b/cmd/uplink/cmd/ls.go index a6d117342..a6542bc22 100644 --- a/cmd/uplink/cmd/ls.go +++ b/cmd/uplink/cmd/ls.go @@ -78,7 +78,7 @@ func list(cmd *cobra.Command, args []string) error { } if noBuckets { - return fmt.Errorf("No buckets") + fmt.Println("No buckets") } return nil diff --git a/cmd/uplink/cmd/run.go b/cmd/uplink/cmd/run.go index 8366a3196..ccd8c8002 100644 --- a/cmd/uplink/cmd/run.go +++ b/cmd/uplink/cmd/run.go @@ -4,6 +4,7 @@ package cmd import ( + "errors" "fmt" "net" @@ -39,5 +40,16 @@ func cmdRun(cmd *cobra.Command, args []string) (err error) { fmt.Printf("Access key: %s\n", cfg.AccessKey) fmt.Printf("Secret key: %s\n", cfg.SecretKey) + ctx := process.Ctx(cmd) + bs, err := cfg.BucketStore(ctx) + if err != nil { + return err + } + + _, _, err = bs.List(ctx, "", "", 0) + if err != nil { + return errors.New("uplink setup error") + } + return cfg.Run(process.Ctx(cmd)) } diff --git a/pkg/storage/buckets/store.go b/pkg/storage/buckets/store.go index 3e40dcd5c..2fa65be10 100644 --- a/pkg/storage/buckets/store.go +++ b/pkg/storage/buckets/store.go @@ -122,6 +122,9 @@ func (b *BucketStore) List(ctx context.Context, startAfter, endBefore string, li items []ListItem, more bool, err error) { defer mon.Task()(&ctx)(&err) objItems, more, err := b.o.List(ctx, nil, paths.New(startAfter), paths.New(endBefore), false, limit, meta.Modified) + if err != nil { + return items, more, err + } items = make([]ListItem, 0, len(objItems)) for _, itm := range objItems { if itm.IsPrefix {