Skip to content

Add gcp storage #26963

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

Closed
wants to merge 11 commits into from
Closed

Conversation

techknowlogick
Copy link
Member

WIP as missing docs, tests, and probably more

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 7, 2023
@pull-request-size pull-request-size bot added size/XL and removed size/L labels Sep 7, 2023
@techknowlogick techknowlogick marked this pull request as draft September 7, 2023 21:29
@silverwind silverwind added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Sep 8, 2023
@techknowlogick techknowlogick marked this pull request as ready for review December 27, 2023 21:31
}

// GCPStorage returns a gcp bucket storage
type GCPStorage struct {
Copy link
Member

Choose a reason for hiding this comment

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

I think this file is weirdly structured:
You start with the assertment that the GCPStorage is a storage.
Okay.
But then I'd expect to see the definition of that type immediately afterward, with all its object methods, then the child types contained within, then the error, and only then the package methods.
Or something like that, that is at least the structure I've seen the most in Gitea so far.


// Convert two responses to standard analogues
// switch errResp.Code {
// case "NoSuchKey":
Copy link
Member

Choose a reason for hiding this comment

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

Why commented out?

if pl > count {
p = p[0:count]
} else {
count = pl
Copy link
Member

Choose a reason for hiding this comment

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

count = min(count, int64(len(p)))
p = p[0:count]

}

func (g *gcpObject) Read(p []byte) (int, error) {
c, err := g.downloadStream(p)
Copy link
Member

Choose a reason for hiding this comment

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

return directly?

offset += g.Size
}
if offset < 0 {
return 0, fmt.Errorf("Seek: invalid offset")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return 0, fmt.Errorf("Seek: invalid offset")
return 0, fmt.Errorf("Seek: invalid offset to read GCP bucket: " + offset)


// createBucket creates a new bucket in the specified location (region).
func createBucket(ctx context.Context, client *storage.Client, projectID, bucketName, location string) error {
bkt := client.Bucket(bucketName)
Copy link
Member

Choose a reason for hiding this comment

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

bucket :=...

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Dec 29, 2023

Would something like https://github.com/beyondstorage/go-storage help? It also helps Azure Blob Storage #25458

@wxiaoguang wxiaoguang mentioned this pull request Dec 29, 2023
6 tasks
@lunny
Copy link
Member

lunny commented Dec 29, 2023

Would something like https://github.com/beyondstorage/go-storage help? It also helps Azure Blob Storage #25458

https://github.com/beyondstorage/go-storage looks promise.

@techknowlogick techknowlogick changed the title [WIP] add gcp storage Add gcp storage Dec 29, 2023
@techknowlogick
Copy link
Member Author

https://github.com/beyondstorage/go-storage looks promise.

I'm not sure that is still actively developed. The domain was taken over by domain squatters, the only commits and PRs appear to be from dependabot.

https://gocloud.dev might be one we want to look at instead, pulumi is a project that uses it.

@techknowlogick
Copy link
Member Author

closing as gcp has s3 API support, so this is not needed.

@techknowlogick techknowlogick deleted the gcp-storage branch April 12, 2024 06:00
@delvh
Copy link
Member

delvh commented Apr 12, 2024

@techknowlogick perhaps we should document that.
I don't think most GCP users are aware they can simply use the S3 Settings

@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jul 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants