go-rocket-update icon indicating copy to clipboard operation
go-rocket-update copied to clipboard

GCS provider

Open joe-getcouragenow opened this issue 4 years ago • 1 comments

Would like to add a Provider: GCS.

Example code: https://github.com/rudderlabs/rudder-server/blob/master/services/filemanager/gcsmanager.go

Module used: https://pkg.go.dev/cloud.google.com/go/storage

What do you think ?

joe-getcouragenow avatar Jan 18 '21 15:01 joe-getcouragenow

Yes I guess that would work If you would like to add a provider you just have to respect the following interface:

type Provider interface {
	Open() error
	Close() error
	GetLatestVersion() (string, error) // Get the latest version (Should be accessible even if Open() was not called)
	Walk(walkFn WalkFunc) error
	Retrieve(srcPath string, destPath string) error
}

Provider definition is here: https://github.com/mouuff/go-rocket-update/blob/master/pkg/provider/types.go#L28

The Retrieve function would be pretty much the same as here: https://github.com/rudderlabs/rudder-server/blob/master/services/filemanager/gcsmanager.go#L61

I guess the Walk function could use this method: https://cloud.google.com/storage/docs/listing-objects#storage-list-objects-go

And the GetLatestVersion is up to you to decide, you could retrieve a VERSION file / folder or maybe use buckets or maybe GCS already has a method to do that.

And the Open and Close functions would be pretty straightforward :)

Thank you for your interest in this project

mouuff avatar Jan 18 '21 17:01 mouuff