This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
generated from beyondstorage/go-service-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement go-storage.Storager (#13)
* update: util.go and go.mod * update(storage.go): add create and delete * update(storager.go): read and write implemented * update(storage.go): all functions implemented * Update .gitignore * Revert "Update .gitignore" This reverts commit e8d82eb. * Update .gitignore * Update utils.go * feat(utils.go): implement formatError * feat: add Makefile.env.example * fix: Add if-errs * fix: Remove redundant blank lines * fix: Add pairs to service.toml * fix: remove redundant calls * fix: remove redeclared package * fix: Storager.list * fix: Storager.list * update(service.toml) * feat: implement integration test * feat: Add rfc example * update: Close #6 * update: Replace name with endpoint * fix: bug fix and code simplify * update: Simplify test * fix: Add more error handler * fix: use idempotent delete and pass the integration test * Update utils.go * feat: continuationToken * fix: Remove unused code - Remove unused code - Change HTTP to TCP - Change import format * fix: File separater
- Loading branch information
Showing
15 changed files
with
563 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
coverage.* | ||
bin/ | ||
bin/ | ||
.vscode/ | ||
Makefile.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
SHELL := /bin/bash | ||
|
||
-include Makefile.env | ||
|
||
.PHONY: all check format lint build test generate tidy | ||
|
||
help: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export STORAGE_FTP_INTEGRATION_TEST=on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
- Author: (fill me in with `name <mail>`, e.g., npofsi [[email protected]](mailto:[email protected])) | ||
- Start Date: (fill me in with today's date, YYYY-MM-DD) | ||
- RFC PR: [beyondstorage/go-service-ftp#0](https://github.com/beyondstorage/go-service-ftp/issues/0) | ||
- Tracking Issue: [beyondstorage/go-service-ftp#0](https://github.com/beyondstorage/go-service-ftp/issues/0) | ||
|
||
# RFC-0: | ||
|
||
- Updates: (delete this part if not applicable) | ||
- [RFC-20](https://github.com/beyondstorage/go-service-ftp/blob/master/docs/rfcs/34-something): Deletes something | ||
- Updated By: (delete this part if not applicable) | ||
- [RFC-10](https://github.com/beyondstorage/go-service-ftp/blob/master/docs/rfcs/10-ka-no): Adds something | ||
- [RFC-1000](https://github.com/beyondstorage/go-service-ftp/blob/master/docs/rfcs/1000-something): Deprecates this RFC | ||
|
||
## Background | ||
|
||
Explain why we are doing this. | ||
|
||
Related issues and early discussions can be linked, but the RFC should try to be self-contained if possible. | ||
|
||
## Proposal | ||
|
||
<proposal's content> | ||
|
||
## Rationale | ||
|
||
<proposal's rationale content, other implementations> | ||
|
||
Possible content: | ||
|
||
- Design Principles | ||
- Drawbacks | ||
- Alternative implementations and comparison | ||
- Possible Q&As | ||
|
||
## Compatibility | ||
|
||
<proposal's compatibility statement> | ||
|
||
## Implementation | ||
|
||
Explain what steps should be done to implement this proposal. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package ftp | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strconv" | ||
|
||
types "github.com/beyondstorage/go-storage/v4/types" | ||
) | ||
|
||
func (s *Storage) listDirNext(ctx context.Context, page *types.ObjectPage) (err error) { | ||
input := page.Status.(*listDirInput) | ||
if input.objList == nil { | ||
input.objList, err = s.connection.List(input.rp) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
if input.started { | ||
input.counter, err = strconv.Atoi(input.continuationToken) | ||
if err != nil { | ||
input.counter = 0 | ||
} | ||
} | ||
n := len(input.objList) | ||
input.continuationToken = fmt.Sprintf("%x", input.counter) | ||
if input.counter >= n { | ||
return types.IterateDone | ||
} | ||
|
||
v := input.objList[input.counter] | ||
obj, err := s.formatFileObject(v, input.rp) | ||
if err != nil { | ||
return err | ||
} | ||
obj.GetID() | ||
|
||
page.Data = append(page.Data, obj) | ||
|
||
input.counter++ | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.