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

fix: remove create object & bucket approval #225

Merged
merged 23 commits into from
Mar 28, 2024
Merged

Conversation

BarryTong65
Copy link
Collaborator

@BarryTong65 BarryTong65 commented Feb 28, 2024

Description

Remove the create object approval & create bucket approval, and during the process of creating objects & buckets, the calls to the SP side are eliminated through the Go-sdk.

Rationale

image

Example

N/A

Changes

Notable changes:

  • fix e2e test
  • remove get create bucket & object approval

// - ret1: The nonce value for the Client
//
// - ret2: Return error when getting next nonce failed, otherwise return nil.
func (c *Client) GetNonceByAddr(ctx context.Context, address sdk.AccAddress) (uint64, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it better to clarify what kind of nonce here the SDK need to get?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As SP off-chain-auth also did have a nonce concept, it would better to explain what nonce is it .

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's just redundant function for local test, i will delete it

// - ret1: The msg of create bucket which contain the approval signature from the storage provider
//
// - ret2: Return error when get approval failed, otherwise return nil.
func (c *Client) GetCreateBucketApproval(ctx context.Context, createBucketMsg *storageTypes.MsgCreateBucket) (*storageTypes.MsgCreateBucket, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to remove those old "getApproval" methods because we need make sure the change is backward compatible.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an exported method. Clients code might have already used it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should not delete this part for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

if err != nil {
return "", err
}

families, err := c.QuerySpAvailableGlobalVirtualGroupFamilies(ctx, sp.Id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd better use the optimal API to get one VGF here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -34,7 +33,6 @@ import (
// IObjectClient interface defines functions related to object operations.
// The concept of "object" is the same as the concept of the object in AWS S3 storage.
type IObjectClient interface {
GetCreateObjectApproval(ctx context.Context, createObjectMsg *storageTypes.MsgCreateObject) (*storageTypes.MsgCreateObject, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to delete this API for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

strings.Contains(objectName, "\\") ||
utils.IsSQLInjection(objectName) {
return "", fmt.Errorf("fail to check object name:%s", objectName)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you wrap these format check codes into a single function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also move the object name rules into the CheckObjectName function, not comment here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CheckObjectName already has the same comments, so i just delete it

@@ -1031,59 +1037,6 @@ func (c *Client) ListObjects(ctx context.Context, bucketName string, opts types.
return listObjectsResult, nil
}

// GetCreateObjectApproval returns the signature info for the approval of preCreating resources
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Deprecated: GetCreateObjectApproval returns the signature info for the approval of preCreating resources

No need to delete this API

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean change the comment to other than delete this line:

// Deprecated: GetCreateObjectApproval returns the signature info for the approval of preCreating resources

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the same to GetCreateBucketApproval API

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@BarryTong65 BarryTong65 added the r4r label Mar 7, 2024
Copy link
Collaborator

@ruojunm ruojunm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BarryTong65 BarryTong65 removed the r4r label Mar 28, 2024
@BarryTong65 BarryTong65 merged commit edb0d8a into master Mar 28, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants