Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2023-10-26 11:40:21 +0300
committerToon Claes <toon@gitlab.com>2023-11-20 12:42:16 +0300
commit0540fb5062304efffc5291acc533438ab7b412ec (patch)
tree962797846f9501c3333c2d713e2d2bdd8b2e15d1
parent5378715a77e05b2c00e4b6aabc2c61981a69fbb2 (diff)
backup: Make NewStorageServiceSink non-public
We're about to make some changes to this function and callers should not be aware of it's implementation details. That's why we're making this function non-public and make ResolveSink() the only entry point to initialize a backup.Sink.
-rw-r--r--internal/backup/sink.go24
-rw-r--r--internal/backup/sink_test.go2
2 files changed, 13 insertions, 13 deletions
diff --git a/internal/backup/sink.go b/internal/backup/sink.go
index 330b1c5b4..a02bab89d 100644
--- a/internal/backup/sink.go
+++ b/internal/backup/sink.go
@@ -10,13 +10,17 @@ import (
"gocloud.dev/blob"
"gocloud.dev/blob/azureblob"
"gocloud.dev/blob/gcsblob"
+ "gocloud.dev/blob/memblob"
"gocloud.dev/blob/s3blob"
"gocloud.dev/gcerrors"
)
-// ResolveSink returns a sink implementation based on the provided path.
-func ResolveSink(ctx context.Context, path string) (Sink, error) {
- parsed, err := url.Parse(path)
+// ResolveSink returns a sink implementation based on the provided uri.
+// The storage engine is chosen based on the provided uri.
+// It is the caller's responsibility to provide all required environment
+// variables in order to get properly initialized storage engine driver.
+func ResolveSink(ctx context.Context, uri string) (Sink, error) {
+ parsed, err := url.Parse(uri)
if err != nil {
return nil, err
}
@@ -29,11 +33,10 @@ func ResolveSink(ctx context.Context, path string) (Sink, error) {
}
switch scheme {
- case s3blob.Scheme, azureblob.Scheme, gcsblob.Scheme:
- sink, err := NewStorageServiceSink(ctx, path)
- return sink, err
+ case s3blob.Scheme, azureblob.Scheme, gcsblob.Scheme, memblob.Scheme:
+ return newStorageServiceSink(ctx, uri)
default:
- return NewFilesystemSink(path), nil
+ return NewFilesystemSink(uri), nil
}
}
@@ -42,11 +45,8 @@ type StorageServiceSink struct {
bucket *blob.Bucket
}
-// NewStorageServiceSink returns initialized instance of StorageServiceSink instance.
-// The storage engine is chosen based on the provided url value and a set of pre-registered
-// blank imports in that file. It is the caller's responsibility to provide all required environment
-// variables in order to get properly initialized storage engine driver.
-func NewStorageServiceSink(ctx context.Context, url string) (*StorageServiceSink, error) {
+// newStorageServiceSink returns initialized instance of StorageServiceSink instance.
+func newStorageServiceSink(ctx context.Context, url string) (*StorageServiceSink, error) {
bucket, err := blob.OpenBucket(ctx, url)
if err != nil {
return nil, fmt.Errorf("storage service sink: open bucket: %w", err)
diff --git a/internal/backup/sink_test.go b/internal/backup/sink_test.go
index 0c40ee6ff..a2d24cbe8 100644
--- a/internal/backup/sink_test.go
+++ b/internal/backup/sink_test.go
@@ -115,7 +115,7 @@ func TestStorageServiceSink(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- sss, err := NewStorageServiceSink(ctx, "mem://test_bucket")
+ sss, err := ResolveSink(ctx, "mem://test_bucket")
require.NoError(t, err)
defer func() { require.NoError(t, sss.Close()) }()