Skip to content

Commit 1395dfa

Browse files
authored
Allow Google storage endpoints without http/s (#179)
Fix Google URL check
1 parent 735b2ca commit 1395dfa

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

store/precomputed_key/s3/s3.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ import (
66
"encoding/hex"
77
"errors"
88
"io"
9-
"net/url"
109
"path"
10+
"strings"
1111
"time"
1212

1313
"github.com/Layr-Labs/eigenda-proxy/store"
1414
"github.com/ethereum/go-ethereum/crypto"
1515
"github.com/minio/minio-go/v7"
1616

1717
"github.com/minio/minio-go/v7/pkg/credentials"
18-
"github.com/minio/minio-go/v7/pkg/s3utils"
1918
)
2019

2120
const (
@@ -58,13 +57,13 @@ type Store struct {
5857
stats *store.Stats
5958
}
6059

60+
func isGoogleEndpoint(endpoint string) bool {
61+
return strings.Contains(endpoint, "storage.googleapis.com")
62+
}
63+
6164
func NewS3(cfg Config) (*Store, error) {
62-
endpointURL, err := url.Parse(cfg.Endpoint)
63-
if err != nil {
64-
return nil, err
65-
}
6665
putObjectOptions := minio.PutObjectOptions{}
67-
if s3utils.IsGoogleEndpoint(*endpointURL) {
66+
if isGoogleEndpoint(cfg.Endpoint) {
6867
putObjectOptions.DisableContentSha256 = true // Avoid chunk signatures on GCS: https://github.com/minio/minio-go/issues/1922
6968
}
7069

store/precomputed_key/s3/s3_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package s3
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestIsGoogleEndpoint_StorageGoogleapis(t *testing.T) {
10+
endpoint := "storage.googleapis.com"
11+
result := isGoogleEndpoint(endpoint)
12+
assert.True(t, result, "Expected true for Google Cloud Storage endpoint")
13+
}
14+
15+
func TestIsGoogleEndpoint_HttpsStorageGoogleapis(t *testing.T) {
16+
endpoint := "https://storage.googleapis.com"
17+
result := isGoogleEndpoint(endpoint)
18+
assert.True(t, result, "Expected true for Google Cloud Storage endpoint")
19+
}
20+
21+
func TestIsGoogleEndpoint_False(t *testing.T) {
22+
endpoint := "https://s3.amazonaws.com/my-bucket"
23+
result := isGoogleEndpoint(endpoint)
24+
assert.False(t, result, "Expected false for non-Google endpoint")
25+
}
26+
27+
func TestIsGoogleEndpoint_Empty(t *testing.T) {
28+
endpoint := ""
29+
result := isGoogleEndpoint(endpoint)
30+
assert.False(t, result, "Expected false for empty endpoint")
31+
}

0 commit comments

Comments
 (0)