Skip to content

Commit 246a1df

Browse files
fix(deps): update module github.com/ncw/swift to v2 (#13951)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Paul Rogers <[email protected]>
1 parent 96b5c79 commit 246a1df

25 files changed

+4638
-36
lines changed

go.mod

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ require (
7272
github.com/mitchellh/mapstructure v1.5.0
7373
github.com/modern-go/reflect2 v1.0.2
7474
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
75-
github.com/ncw/swift v1.0.53
7675
github.com/oklog/run v1.1.0
7776
github.com/oklog/ulid v1.3.1
7877
github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e
@@ -132,6 +131,7 @@ require (
132131
github.com/heroku/x v0.0.61
133132
github.com/influxdata/tdigest v0.0.2-0.20210216194612-fc98d27c9e8b
134133
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
134+
github.com/ncw/swift/v2 v2.0.2
135135
github.com/prometheus/alertmanager v0.27.0
136136
github.com/prometheus/common/sigv4 v0.1.0
137137
github.com/richardartoul/molecule v1.0.0
@@ -169,6 +169,7 @@ require (
169169
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
170170
github.com/moby/docker-image-spec v1.3.1 // indirect
171171
github.com/moby/sys/userns v0.1.0 // indirect
172+
github.com/ncw/swift v1.0.53 // indirect
172173
github.com/pires/go-proxyproto v0.7.0 // indirect
173174
github.com/pkg/xattr v0.4.10 // indirect
174175
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,8 @@ github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OS
14971497
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
14981498
github.com/ncw/swift v1.0.53 h1:luHjjTNtekIEvHg5KdAFIBaH7bWfNkefwFnpDffSIks=
14991499
github.com/ncw/swift v1.0.53/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM=
1500+
github.com/ncw/swift/v2 v2.0.2 h1:jx282pcAKFhmoZBSdMcCRFn9VWkoBIRsCpe+yZq7vEk=
1501+
github.com/ncw/swift/v2 v2.0.2/go.mod h1:z0A9RVdYPjNjXVo2pDOPxZ4eu3oarO1P91fTItcb+Kg=
15001502
github.com/newrelic/newrelic-telemetry-sdk-go v0.2.0/go.mod h1:G9MqE/cHGv3Hx3qpYhfuyFUsGx2DpVcGi1iJIqTg+JQ=
15011503
github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk=
15021504
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=

pkg/storage/chunk/client/openstack/swift_object_client.go

+35-35
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"net/http"
1010
"time"
1111

12-
"github.com/ncw/swift"
12+
swift "github.com/ncw/swift/v2"
1313
"github.com/pkg/errors"
1414
"github.com/prometheus/client_golang/prometheus"
1515

@@ -61,7 +61,7 @@ func NewSwiftObjectClient(cfg SwiftConfig, hedgingCfg hedging.Config) (*SwiftObj
6161
return nil, err
6262
}
6363
// Ensure the container is created, no error is returned if it already exists.
64-
if err := c.ContainerCreate(cfg.ContainerName, nil); err != nil {
64+
if err := c.ContainerCreate(context.Background(), cfg.Config.ContainerName, nil); err != nil {
6565
return nil, err
6666
}
6767
hedging, err := createConnection(cfg, hedgingCfg, true)
@@ -78,30 +78,30 @@ func NewSwiftObjectClient(cfg SwiftConfig, hedgingCfg hedging.Config) (*SwiftObj
7878
func createConnection(cfg SwiftConfig, hedgingCfg hedging.Config, hedging bool) (*swift.Connection, error) {
7979
// Create a connection
8080
c := &swift.Connection{
81-
AuthVersion: cfg.AuthVersion,
82-
AuthUrl: cfg.AuthURL,
83-
Internal: cfg.Internal,
84-
ApiKey: cfg.Password,
85-
UserName: cfg.Username,
86-
UserId: cfg.UserID,
87-
Retries: cfg.MaxRetries,
88-
ConnectTimeout: cfg.ConnectTimeout,
89-
Timeout: cfg.RequestTimeout,
90-
TenantId: cfg.ProjectID,
91-
Tenant: cfg.ProjectName,
92-
TenantDomain: cfg.ProjectDomainName,
93-
TenantDomainId: cfg.ProjectDomainID,
94-
Domain: cfg.DomainName,
95-
DomainId: cfg.DomainID,
96-
Region: cfg.RegionName,
81+
AuthVersion: cfg.Config.AuthVersion,
82+
AuthUrl: cfg.Config.AuthURL,
83+
Internal: cfg.Config.Internal,
84+
ApiKey: cfg.Config.Password,
85+
UserName: cfg.Config.Username,
86+
UserId: cfg.Config.UserID,
87+
Retries: cfg.Config.MaxRetries,
88+
ConnectTimeout: cfg.Config.ConnectTimeout,
89+
Timeout: cfg.Config.RequestTimeout,
90+
TenantId: cfg.Config.ProjectID,
91+
Tenant: cfg.Config.ProjectName,
92+
TenantDomain: cfg.Config.ProjectDomainName,
93+
TenantDomainId: cfg.Config.ProjectDomainID,
94+
Domain: cfg.Config.DomainName,
95+
DomainId: cfg.Config.DomainID,
96+
Region: cfg.Config.RegionName,
9797
Transport: defaultTransport,
9898
}
9999

100100
switch {
101-
case cfg.UserDomainName != "":
102-
c.Domain = cfg.UserDomainName
103-
case cfg.UserDomainID != "":
104-
c.DomainId = cfg.UserDomainID
101+
case cfg.Config.UserDomainName != "":
102+
c.Domain = cfg.Config.UserDomainName
103+
case cfg.Config.UserDomainID != "":
104+
c.DomainId = cfg.Config.UserDomainID
105105
}
106106
if hedging {
107107
var err error
@@ -111,7 +111,7 @@ func createConnection(cfg SwiftConfig, hedgingCfg hedging.Config, hedging bool)
111111
}
112112
}
113113

114-
err := c.Authenticate()
114+
err := c.Authenticate(context.TODO())
115115
if err != nil {
116116
return nil, err
117117
}
@@ -124,8 +124,8 @@ func (s *SwiftObjectClient) Stop() {
124124
s.hedgingConn.UnAuthenticate()
125125
}
126126

127-
func (s *SwiftObjectClient) ObjectExists(_ context.Context, objectKey string) (bool, error) {
128-
_, _, err := s.hedgingConn.Object(s.cfg.ContainerName, objectKey)
127+
func (s *SwiftObjectClient) ObjectExists(ctx context.Context, objectKey string) (bool, error) {
128+
_, _, err := s.hedgingConn.Object(ctx, s.cfg.Config.ContainerName, objectKey)
129129
if err != nil {
130130
return false, err
131131
}
@@ -134,9 +134,9 @@ func (s *SwiftObjectClient) ObjectExists(_ context.Context, objectKey string) (b
134134
}
135135

136136
// GetObject returns a reader and the size for the specified object key from the configured swift container.
137-
func (s *SwiftObjectClient) GetObject(_ context.Context, objectKey string) (io.ReadCloser, int64, error) {
137+
func (s *SwiftObjectClient) GetObject(ctx context.Context, objectKey string) (io.ReadCloser, int64, error) {
138138
var buf bytes.Buffer
139-
_, err := s.hedgingConn.ObjectGet(s.cfg.ContainerName, objectKey, &buf, false, nil)
139+
_, err := s.hedgingConn.ObjectGet(ctx, s.cfg.Config.ContainerName, objectKey, &buf, false, nil)
140140
if err != nil {
141141
return nil, 0, err
142142
}
@@ -145,12 +145,12 @@ func (s *SwiftObjectClient) GetObject(_ context.Context, objectKey string) (io.R
145145
}
146146

147147
// GetObject returns a reader and the size for the specified object key from the configured swift container.
148-
func (s *SwiftObjectClient) GetObjectRange(_ context.Context, objectKey string, offset, length int64) (io.ReadCloser, error) {
148+
func (s *SwiftObjectClient) GetObjectRange(ctx context.Context, objectKey string, offset, length int64) (io.ReadCloser, error) {
149149
var buf bytes.Buffer
150150
h := swift.Headers{
151151
"Range": fmt.Sprintf("bytes=%d-%d", offset, offset+length-1),
152152
}
153-
_, err := s.hedgingConn.ObjectGet(s.cfg.ContainerName, objectKey, &buf, false, h)
153+
_, err := s.hedgingConn.ObjectGet(ctx, s.cfg.Config.ContainerName, objectKey, &buf, false, h)
154154
if err != nil {
155155
return nil, err
156156
}
@@ -159,13 +159,13 @@ func (s *SwiftObjectClient) GetObjectRange(_ context.Context, objectKey string,
159159
}
160160

161161
// PutObject puts the specified bytes into the configured Swift container at the provided key
162-
func (s *SwiftObjectClient) PutObject(_ context.Context, objectKey string, object io.Reader) error {
163-
_, err := s.conn.ObjectPut(s.cfg.ContainerName, objectKey, object, false, "", "", nil)
162+
func (s *SwiftObjectClient) PutObject(ctx context.Context, objectKey string, object io.Reader) error {
163+
_, err := s.conn.ObjectPut(ctx, s.cfg.Config.ContainerName, objectKey, object, false, "", "", nil)
164164
return err
165165
}
166166

167167
// List only objects from the store non-recursively
168-
func (s *SwiftObjectClient) List(_ context.Context, prefix, delimiter string) ([]client.StorageObject, []client.StorageCommonPrefix, error) {
168+
func (s *SwiftObjectClient) List(ctx context.Context, prefix, delimiter string) ([]client.StorageObject, []client.StorageCommonPrefix, error) {
169169
if len(delimiter) > 1 {
170170
return nil, nil, fmt.Errorf("delimiter must be a single character but was %s", delimiter)
171171
}
@@ -177,7 +177,7 @@ func (s *SwiftObjectClient) List(_ context.Context, prefix, delimiter string) ([
177177
opts.Delimiter = []rune(delimiter)[0]
178178
}
179179

180-
objs, err := s.conn.ObjectsAll(s.cfg.ContainerName, opts)
180+
objs, err := s.conn.ObjectsAll(ctx, s.cfg.Config.ContainerName, opts)
181181
if err != nil {
182182
return nil, nil, err
183183
}
@@ -203,8 +203,8 @@ func (s *SwiftObjectClient) List(_ context.Context, prefix, delimiter string) ([
203203
}
204204

205205
// DeleteObject deletes the specified object key from the configured Swift container.
206-
func (s *SwiftObjectClient) DeleteObject(_ context.Context, objectKey string) error {
207-
return s.conn.ObjectDelete(s.cfg.ContainerName, objectKey)
206+
func (s *SwiftObjectClient) DeleteObject(ctx context.Context, objectKey string) error {
207+
return s.conn.ObjectDelete(ctx, s.cfg.Config.ContainerName, objectKey)
208208
}
209209

210210
// IsObjectNotFoundErr returns true if error means that object is not found. Relevant to GetObject and DeleteObject operations.

vendor/github.com/ncw/swift/v2/.gitignore

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/ncw/swift/v2/.golangci.yml

+56
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/ncw/swift/v2/COPYING

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)