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

chore: update dependency and cmd version #92

Merged
merged 5 commits into from
Sep 22, 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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## v0.1.1
FEATURES
* [#89](https://github.com/bnb-chain/greenfield-cmd/pull/89) support resumable download by adding a flag to "object get cmd"
* [#90](https://github.com/bnb-chain/greenfield-cmd/pull/90) improve cmd of downloading and uploading with printing progress details and speed
* [#90](https://github.com/bnb-chain/greenfield-cmd/pull/92) update dependency of go-sdk and greenfield to v0.2.6

BUGFIX
* [#90](https://github.com/bnb-chain/greenfield-cmd/pull/90) solve the problem of parsing object name err when recursive upload folder

## v0.1.0

FEATURES
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ To obtain the latest release, please visit the following URL: https://github.com
git clone https://github.com/bnb-chain/greenfield-cmd.git
cd greenfield-cmd
# Find the latest release here: https://github.com/bnb-chain/greenfield-cmd/releases
git checkout -b branch-name v0.1.0
git checkout -b branch-name v0.1.1
make build
cd build
./gnfd-cmd -h
Expand Down
6 changes: 3 additions & 3 deletions cmd/client_gnfd.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func showVersion(ctx *cli.Context) error {
}

// NewClient returns a new greenfield client
func NewClient(ctx *cli.Context, isQueryCmd bool) (client.Client, error) {
func NewClient(ctx *cli.Context, isQueryCmd bool) (client.IClient, error) {
var (
account *types.Account
err error
Expand All @@ -57,7 +57,7 @@ func NewClient(ctx *cli.Context, isQueryCmd bool) (client.Client, error) {
return nil, err
}

var cli client.Client
var cli client.IClient
if host != "" {
cli, err = client.New(chainId, rpcAddr, client.Option{DefaultAccount: account, Host: host})
} else {
Expand Down Expand Up @@ -112,7 +112,7 @@ func ParseBucket(urlPath string) (bucketName string) {
return splits[0]
}

func waitTxnStatus(cli client.Client, ctx context.Context, txnHash string, txnInfo string) error {
func waitTxnStatus(cli client.IClient, ctx context.Context, txnHash string, txnInfo string) error {
ctxTimeout, cancel := context.WithTimeout(ctx, ContextTimeout)
defer cancel()

Expand Down
6 changes: 3 additions & 3 deletions cmd/cmd_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func deleteBucket(ctx *cli.Context) error {
if err != nil {
return toCmdErr(err)
}

fmt.Printf("delete_bucket: %s \ntransaction hash: %s\n", bucketName, txnHash)
return nil
}
Expand Down Expand Up @@ -164,7 +164,7 @@ func deleteObject(ctx *cli.Context) error {
return nil
}

func deleteObjectByPage(cli client.Client, c context.Context, bucketName, prefixName string) error {
func deleteObjectByPage(cli client.IClient, c context.Context, bucketName, prefixName string) error {
var (
listResult sdktypes.ListObjectsResult
continuationToken string
Expand Down Expand Up @@ -195,7 +195,7 @@ func deleteObjectByPage(cli client.Client, c context.Context, bucketName, prefix
return nil
}

func deleteObjectAndWaitTxn(cli client.Client, c context.Context, bucketName, objectName string) {
func deleteObjectAndWaitTxn(cli client.IClient, c context.Context, bucketName, objectName string) {
txnHash, err := cli.DeleteObject(c, bucketName, objectName, sdktypes.DeleteObjectOption{TxOpts: &TxnOptionWithSyncMode})
if err != nil {
fmt.Printf("failed to delele object %s err:%v\n", objectName, err)
Expand Down
12 changes: 6 additions & 6 deletions cmd/cmd_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func putObject(ctx *cli.Context) error {

// uploadFolder upload folder and the files inside to bucket in a recursive way
func uploadFolder(urlInfo string, ctx *cli.Context,
gnfdClient client.Client) error {
gnfdClient client.IClient) error {
// upload folder with recursive flag
bucketName := ParseBucket(urlInfo)
if bucketName == "" {
Expand Down Expand Up @@ -398,7 +398,7 @@ func uploadFolder(urlInfo string, ctx *cli.Context,
}

func uploadFile(bucketName, objectName, filePath, urlInfo string, ctx *cli.Context,
gnfdClient client.Client, uploadSigleFolder, printTxnHash bool, objectSize int64) error {
gnfdClient client.IClient, uploadSigleFolder, printTxnHash bool, objectSize int64) error {
var file *os.File
contentType := ctx.String(contentTypeFlag)
secondarySPAccs := ctx.String(secondarySPFlag)
Expand Down Expand Up @@ -636,9 +636,9 @@ func getObject(ctx *cli.Context) error {
LastPrinted: time.Now(),
}

body, info, getErr := gnfdClient.GetObject(c, bucketName, objectName, opt)
if getErr != nil {
return toCmdErr(err)
body, info, downloadErr := gnfdClient.GetObject(c, bucketName, objectName, opt)
if downloadErr != nil {
return toCmdErr(downloadErr)
}

_, err = io.Copy(pw, body)
Expand Down Expand Up @@ -722,7 +722,7 @@ func listObjects(ctx *cli.Context) error {
return nil
}

func listObjectByPage(cli client.Client, c context.Context, bucketName, prefixName string, isRecursive bool) error {
func listObjectByPage(cli client.IClient, c context.Context, bucketName, prefixName string, isRecursive bool) error {
var (
listResult sdktypes.ListObjectsResult
continuationToken string
Expand Down
10 changes: 8 additions & 2 deletions cmd/cmd_payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,14 @@ func getQuotaInfo(ctx *cli.Context) error {
return toCmdErr(err)
}

fmt.Printf(" quota info:\n charged quota:%d \n free quota remained :%d \n charged quota consumed:%d \n free quota consumed: %d \n",
quotaInfo.ReadQuotaSize, quotaInfo.SPFreeReadQuotaSize, quotaInfo.ReadConsumedSize, quotaInfo.FreeConsumedSize)
nameMaxLen := len("consumed charged quota:")
format := fmt.Sprintf("%%-%ds %%-%dd \n", nameMaxLen, 50)
firstLineFormat := fmt.Sprintf("%%-%ds %%-%ds \n", nameMaxLen, 50)
fmt.Printf(firstLineFormat, "quota name", "quota value")
fmt.Printf(format, "charged quota:", quotaInfo.ReadQuotaSize)
fmt.Printf(format, "remained free quota:", quotaInfo.SPFreeReadQuotaSize)
fmt.Printf(format, "consumed charged quota:", quotaInfo.ReadConsumedSize)
fmt.Printf(format, "consumed free quota:", quotaInfo.FreeConsumedSize)

return nil
}
14 changes: 7 additions & 7 deletions cmd/cmd_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func handleListPolicy(ctx *cli.Context, resource string, policyType ResourceType
return nil
}

func handleObjectPolicy(ctx *cli.Context, client client.Client, bucketName, objectName string, principal sdktypes.Principal,
func handleObjectPolicy(ctx *cli.Context, client client.IClient, bucketName, objectName string, principal sdktypes.Principal,
statements []*permTypes.Statement, delete bool) error {
c, cancelObjectPolicy := context.WithCancel(globalContext)
defer cancelObjectPolicy()
Expand Down Expand Up @@ -393,7 +393,7 @@ func handleObjectPolicy(ctx *cli.Context, client client.Client, bucketName, obje
return nil
}

func handleBucketPolicy(ctx *cli.Context, client client.Client, bucketName string, principal sdktypes.Principal,
func handleBucketPolicy(ctx *cli.Context, client client.IClient, bucketName string, principal sdktypes.Principal,
statements []*permTypes.Statement, delete bool) error {
c, cancelBucketPolicy := context.WithCancel(globalContext)
defer cancelBucketPolicy()
Expand Down Expand Up @@ -427,7 +427,7 @@ func handleBucketPolicy(ctx *cli.Context, client client.Client, bucketName strin
return nil
}

func handleGroupPolicy(ctx *cli.Context, client client.Client, groupName string,
func handleGroupPolicy(ctx *cli.Context, client client.IClient, groupName string,
statements []*permTypes.Statement, delete bool) error {
c, cancelPolicy := context.WithCancel(globalContext)
defer cancelPolicy()
Expand Down Expand Up @@ -509,7 +509,7 @@ func parseGroupResource(resourceName string) (string, string, error) {
return objectPath[:index], objectPath[index+1:], nil
}

func printObjectPolicy(ctx *cli.Context, cli client.Client, bucketName, objectName string) {
func printObjectPolicy(ctx *cli.Context, cli client.IClient, bucketName, objectName string) {
// get the latest policy from chain
groupId := ctx.Uint64(groupIDFlag)
grantee := ctx.String(granteeFlag)
Expand All @@ -528,7 +528,7 @@ func printObjectPolicy(ctx *cli.Context, cli client.Client, bucketName, objectNa
}
}

func listObjectPolicy(ctx *cli.Context, cli client.Client, bucketName, objectName, resourceName string) error {
func listObjectPolicy(ctx *cli.Context, cli client.IClient, bucketName, objectName, resourceName string) error {
// get the latest policy from chain
groupId := ctx.Uint64(groupIDFlag)
grantee := ctx.String(granteeFlag)
Expand All @@ -553,7 +553,7 @@ func listObjectPolicy(ctx *cli.Context, cli client.Client, bucketName, objectNam
return nil
}

func printBucketPolicy(ctx *cli.Context, cli client.Client, bucketName string) {
func printBucketPolicy(ctx *cli.Context, cli client.IClient, bucketName string) {
c, cancelPolicy := context.WithCancel(globalContext)
defer cancelPolicy()
// get the latest policy from chain
Expand All @@ -572,7 +572,7 @@ func printBucketPolicy(ctx *cli.Context, cli client.Client, bucketName string) {
}
}

func listBucketPolicy(ctx *cli.Context, cli client.Client, bucketName, resourceName string) error {
func listBucketPolicy(ctx *cli.Context, cli client.IClient, bucketName, resourceName string) error {
c, cancelPolicy := context.WithCancel(globalContext)
defer cancelPolicy()

Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd_sp.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func getQuotaPrice(ctx *cli.Context) error {
return nil
}

func getSPAddr(spAddressInfo string, cli client.Client, c context.Context) (sdk.AccAddress, error) {
func getSPAddr(spAddressInfo string, cli client.IClient, c context.Context) (sdk.AccAddress, error) {
var addr sdk.AccAddress
var err error
var spList []sptypes.StorageProvider
Expand Down
2 changes: 1 addition & 1 deletion cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

const (
Version = "v0.1.0"
Version = "v0.1.1"
maxFileSize = 64 * 1024 * 1024 * 1024
maxPutWithoutResumeSize = 2 * 1024 * 1024 * 1024
publicReadType = "public-read"
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.20
require (
cosmossdk.io/math v1.0.1
github.com/BurntSushi/toml v1.3.2
github.com/bnb-chain/greenfield v0.2.5
github.com/bnb-chain/greenfield-go-sdk v0.2.5
github.com/bnb-chain/greenfield v0.2.6
github.com/bnb-chain/greenfield-go-sdk v0.2.6
github.com/cosmos/cosmos-sdk v0.47.3
github.com/ethereum/go-ethereum v1.10.26
github.com/urfave/cli/v2 v2.10.2
Expand Down Expand Up @@ -153,7 +153,7 @@ replace (
github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.3
github.com/cometbft/cometbft-db => github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.5
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.6
github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,24 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s=
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
github.com/bnb-chain/greenfield v0.2.5 h1:AmHvGfJmHm7FXB4II4mAB6i68bw98p86ZlIs9r6YeRM=
github.com/bnb-chain/greenfield v0.2.5/go.mod h1:nNsy8QGR8+R0j6Qz/duNE94NDDNuomC6wWDCzfl7jKc=
github.com/bnb-chain/greenfield v0.2.6 h1:U40wmSBQR4Wd0HiVCu/J6zqoLS4YUrvNgyuX71kgK3U=
github.com/bnb-chain/greenfield v0.2.6/go.mod h1:8kGVzKu3BEbpotk2Lmp/OzPh+nhbMsuUJueZtn0he4s=
github.com/bnb-chain/greenfield-cometbft v0.0.3 h1:tv8NMy3bzX/1urqXGQIIAZSLy83loiI+dG0VKeyh1CY=
github.com/bnb-chain/greenfield-cometbft v0.0.3/go.mod h1:f35mk/r5ab6yvzlqEWZt68LfUje68sYgMpVlt2CUYMk=
github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 h1:XcWulGacHVRiSCx90Q8Y//ajOrLNBQWR/KDB89dy3cU=
github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1/go.mod h1:ey1CiK4bYo1RBNJLRiVbYr5CMdSxci9S/AZRINLtppI=
github.com/bnb-chain/greenfield-common/go v0.0.0-20230830120314-a54ffd6da39f h1:zJvB2wCd80DQ9Nh/ZNQiP8MrHygSpDoav7OzHyIi/pM=
github.com/bnb-chain/greenfield-common/go v0.0.0-20230830120314-a54ffd6da39f/go.mod h1:it3JJVHeG9Wp4QED2GkY/7V9Qo3BuPdoC5/4/U6ecJM=
github.com/bnb-chain/greenfield-cosmos-sdk v0.2.5 h1:8zIn/ExfMHZVBbVwhILG9KYO1m3pZO8I8stpqbFgzkk=
github.com/bnb-chain/greenfield-cosmos-sdk v0.2.5/go.mod h1:y3hDhQhil5hMIhwBTpu07RZBF30ZITkoE+GHhVZChtY=
github.com/bnb-chain/greenfield-cosmos-sdk v0.2.6 h1:aPrd2nG2nYZr8nSmGgN8efus6sni4OIZ1Bdx6s+mS3A=
github.com/bnb-chain/greenfield-cosmos-sdk v0.2.6/go.mod h1:y3hDhQhil5hMIhwBTpu07RZBF30ZITkoE+GHhVZChtY=
github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230816082903-b48770f5e210 h1:GHPbV2bC+gmuO6/sG0Tm8oGal3KKSRlyE+zPscDjlA8=
github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230816082903-b48770f5e210/go.mod h1:vhsZxXE9tYJeYB5JR4hPhd6Pc/uPf7j1T8IJ7p9FdeM=
github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230816082903-b48770f5e210 h1:FLVOn4+OVbsKi2+YJX5kmD27/4dRu4FW7xCXFhzDO5s=
github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230816082903-b48770f5e210/go.mod h1:An0MllWJY6PxibUpnwGk8jOm+a/qIxlKmL5Zyp9NnaM=
github.com/bnb-chain/greenfield-go-sdk v0.2.5 h1:ErI7nUtNCRDvpXSVaG/XKXEBhTcmiofg/2ciKU1uBag=
github.com/bnb-chain/greenfield-go-sdk v0.2.5/go.mod h1:rWI9Xgcto7ujajNfG6x7+lW1SzbJWBkIgnOcoNjWS7U=
github.com/bnb-chain/greenfield-go-sdk v0.2.6-0.20230922033934-cdcf8250f37d h1:BxrPzgrB8Ara+wnMfEv/X/4fEw6YGecPhIy96NgmKkE=
github.com/bnb-chain/greenfield-go-sdk v0.2.6-0.20230922033934-cdcf8250f37d/go.mod h1:MrxZcdoK/YC8o0wECOv8fskozBokekxApLbi1P6qeTI=
github.com/bnb-chain/greenfield-go-sdk v0.2.6 h1:CGmMK+Ie3ZXae86rGYJnaF7FmO+y92S4a/Qp7DzxhLU=
github.com/bnb-chain/greenfield-go-sdk v0.2.6/go.mod h1:MrxZcdoK/YC8o0wECOv8fskozBokekxApLbi1P6qeTI=
github.com/bnb-chain/greenfield-iavl v0.20.1 h1:y3L64GU99otNp27/xLVBTDbv4eroR6CzoYz0rbaVotM=
github.com/bnb-chain/greenfield-iavl v0.20.1/go.mod h1:oLksTs8dfh7DYIKBro7hbRQ+ewls7ghJ27pIXlbEXyI=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
Expand Down
Loading