Skip to content

Commit f114119

Browse files
Merge pull request #1980 from tesshuflower/update-restic-to-v0.18.1
update restic to v0.18.1
2 parents 51d4153 + 7ce32b5 commit f114119

139 files changed

Lines changed: 5061 additions & 1347 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.sonarcloud.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ sonar.sources=.
1313
# Patterns used to exclude some source files from analysis.
1414
sonar.exclusions=**/*_test.go,**/*_generated*.go,**/*_generated/**,**/vendor/**,**/api/v1alpha1/**,**/main.go,mover-restic/restic/**/*,mover-restic/minio-go/**/*
1515

16+
# Patterns used to exclude some source files from security hotspot analysis.
17+
sonar.security.exclusions=mover-restic/restic/**,mover-restic/minio-go/**
18+
1619
# Comma-separated paths to directories containing test source files
1720
sonar.tests=.
1821

mover-restic/SOURCE_VERSIONS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
https://github.com/restic/restic.git v0.18.0 d401ad6c1ec93a8fbcfcd9f6855a7a4468878ec2
2-
https://github.com/minio/minio-go.git v7.0.88 c34f06bd8b0c1abfffb8b5c4d939dc93268461e7
1+
https://github.com/restic/restic.git v0.18.1 7d0aa7f2e30546fba7c8f1c0bae4d6704e3d8423
2+
https://github.com/minio/minio-go.git v7.0.95 bd91926e6b4d828b4b5072088fd8b4a6a7a44eab

mover-restic/minio-go/.github/workflows/go-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ${{ matrix.os }}
1818
strategy:
1919
matrix:
20-
go-version: [1.22.x, 1.23.x]
20+
go-version: [1.23.x, 1.24.x]
2121
os: [windows-latest]
2222
steps:
2323
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}

mover-restic/minio-go/.github/workflows/go.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ${{ matrix.os }}
1818
strategy:
1919
matrix:
20-
go-version: [1.22.x, 1.23.x]
20+
go-version: [1.23.x, 1.24.x]
2121
os: [ubuntu-latest]
2222
steps:
2323
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -36,7 +36,7 @@ jobs:
3636
ACCESS_KEY: minioadmin
3737
SECRET_KEY: minioadmin
3838
ENABLE_HTTPS: 1
39-
MINIO_KMS_MASTER_KEY: my-minio-key:6368616e676520746869732070617373776f726420746f206120736563726574
39+
MINIO_KMS_SECRET_KEY: my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw=
4040
SSL_CERT_FILE: /tmp/certs-dir/public.crt
4141
MINIO_CI_CD: true
4242
MINT_NO_FULL_OBJECT: true

mover-restic/minio-go/.github/workflows/vulncheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
go-version: [ 1.23.x ]
17+
go-version: [ 1.24.x ]
1818
steps:
1919
- name: Check out code into the Go module directory
2020
uses: actions/checkout@v4
Lines changed: 65 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,72 @@
1-
linters-settings:
2-
misspell:
3-
locale: US
4-
1+
version: "2"
52
linters:
63
disable-all: true
74
enable:
8-
- typecheck
9-
- goimports
10-
- misspell
11-
- revive
5+
- durationcheck
6+
- gocritic
7+
- gomodguard
128
- govet
139
- ineffassign
14-
- gosimple
10+
- misspell
11+
- revive
12+
- staticcheck
13+
- unconvert
1514
- unused
16-
- gocritic
17-
15+
- usetesting
16+
- whitespace
17+
settings:
18+
misspell:
19+
locale: US
20+
staticcheck:
21+
checks:
22+
- all
23+
- -SA1008
24+
- -SA1019
25+
- -SA4000
26+
- -SA9004
27+
- -ST1000
28+
- -ST1005
29+
- -ST1016
30+
- -ST1021
31+
- -ST1020
32+
- -U1000
33+
exclusions:
34+
generated: lax
35+
rules:
36+
- path: (.+)\.go$
37+
text: "empty-block:"
38+
- path: (.+)\.go$
39+
text: "unused-parameter:"
40+
- path: (.+)\.go$
41+
text: "dot-imports:"
42+
- path: (.+)\.go$
43+
text: "singleCaseSwitch: should rewrite switch statement to if statement"
44+
- path: (.+)\.go$
45+
text: "unlambda: replace"
46+
- path: (.+)\.go$
47+
text: "captLocal:"
48+
- path: (.+)\.go$
49+
text: "should have a package comment"
50+
- path: (.+)\.go$
51+
text: "ifElseChain:"
52+
- path: (.+)\.go$
53+
text: "elseif:"
54+
- path: (.+)\.go$
55+
text: "Error return value of"
56+
- path: (.+)\.go$
57+
text: "unnecessary conversion"
58+
- path: (.+)\.go$
59+
text: "Error return value is not checked"
1860
issues:
19-
exclude-use-default: false
20-
exclude:
21-
# todo fix these when we get enough time.
22-
- "singleCaseSwitch: should rewrite switch statement to if statement"
23-
- "unlambda: replace"
24-
- "captLocal:"
25-
- "ifElseChain:"
26-
- "elseif:"
27-
- "should have a package comment"
61+
max-issues-per-linter: 100
62+
max-same-issues: 100
63+
formatters:
64+
enable:
65+
- gofumpt
66+
- goimports
67+
exclusions:
68+
generated: lax
69+
paths:
70+
- third_party$
71+
- builtin$
72+
- examples$
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
/*
2+
* MinIO Go Library for Amazon S3 Compatible Cloud Storage
3+
* Copyright 2017-2020 MinIO, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package minio
19+
20+
import (
21+
"context"
22+
"fmt"
23+
"net/http"
24+
"net/http/httptest"
25+
"net/url"
26+
"os"
27+
"testing"
28+
"time"
29+
30+
"github.com/minio/minio-go/v7/pkg/credentials"
31+
)
32+
33+
func Test200MultipartUploadWithSpaces(t *testing.T) {
34+
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
35+
w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>`))
36+
w.(http.Flusher).Flush()
37+
for i := 0; i < 10; i++ {
38+
time.Sleep(time.Second)
39+
w.Write([]byte(" "))
40+
w.(http.Flusher).Flush()
41+
}
42+
43+
w.Write([]byte(`<CompleteMultipartUploadResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Location>http://random/bucket/object</Location><Bucket>bucket</Bucket><Key>object</Key><ETag>&#34;2b3ffa539769372e2df9553358fe26b2-2&#34;</ETag></CompleteMultipartUploadResult>`))
44+
}))
45+
46+
srv, err := url.Parse(ts.URL)
47+
if err != nil {
48+
t.Fatal(err)
49+
}
50+
51+
// Instantiate new minio client object.
52+
core, err := NewCore(
53+
srv.Host,
54+
&Options{
55+
Creds: credentials.NewStaticV4("foo", "foo12345", ""),
56+
Secure: srv.Scheme == "https",
57+
})
58+
if err != nil {
59+
t.Fatal("Error:", err)
60+
}
61+
62+
parts := []CompletePart{
63+
{PartNumber: 1, ETag: "b386a859d8a22ff986c0b1252be34658"},
64+
{PartNumber: 2, ETag: "78c577a580bbbba92845789cda1fa932"},
65+
}
66+
67+
foundUploadInfo, err := core.CompleteMultipartUpload(context.Background(),
68+
"bucket",
69+
"object",
70+
"jY1M2U5NWMtZGY2OC00ZjYyLTljZGYtYmZlOWEzODM3MDMwLjlmZWY5OGNlLWQ1Y2EtNDgwMC04N2Y4LWZkNTNkMDM4ZDdiMXgxNzQ4NjA0NzI0NzE4NjU3MTY3",
71+
parts,
72+
PutObjectOptions{},
73+
)
74+
if err != nil {
75+
t.Fatal("Error:", err)
76+
}
77+
78+
expectedUploadInfo := UploadInfo{
79+
Bucket: "bucket",
80+
Key: "object",
81+
ETag: "2b3ffa539769372e2df9553358fe26b2-2",
82+
Location: "http://random/bucket/object",
83+
}
84+
85+
if foundUploadInfo != expectedUploadInfo {
86+
t.Fatalf("Unexpected upload info, expected: `%v`, found: `%v`", expectedUploadInfo, foundUploadInfo)
87+
}
88+
}
89+
90+
func Test200MultipartUploadWithError(t *testing.T) {
91+
const maxRetries = 3
92+
retries := maxRetries
93+
94+
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
95+
retries--
96+
w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>`))
97+
w.(http.Flusher).Flush()
98+
for i := 0; i < 5; i++ {
99+
time.Sleep(time.Second)
100+
w.Write([]byte(" "))
101+
w.(http.Flusher).Flush()
102+
}
103+
104+
w.Write([]byte(`<Error><Code>SlowDownWrite</Code><Message>Resource requested is unwritable, please reduce your request rate</Message><Key>object</Key><BucketName>bucket</BucketName><Resource>/bucket/object</Resource><RequestId>18413E84F6C30613</RequestId><HostId>49371f38c0d7ec74eae2befc695360a3dfece04732914e58a4281759cd2eba4f</HostId></Error>`))
105+
}))
106+
107+
srv, err := url.Parse(ts.URL)
108+
if err != nil {
109+
t.Fatal(err)
110+
}
111+
112+
// Instantiate new minio client object.
113+
core, err := NewCore(
114+
srv.Host,
115+
&Options{
116+
Creds: credentials.NewStaticV4("foo", "foo12345", ""),
117+
Secure: srv.Scheme == "https",
118+
Region: "us-east-1",
119+
MaxRetries: retries,
120+
})
121+
if err != nil {
122+
t.Fatal("Error:", err)
123+
}
124+
125+
parts := []CompletePart{
126+
{PartNumber: 1, ETag: "b386a859d8a22ff986c0b1252be34658"},
127+
{PartNumber: 2, ETag: "78c577a580bbbba92845789cda1fa932"},
128+
}
129+
130+
_, err = core.CompleteMultipartUpload(context.Background(),
131+
"bucket",
132+
"object",
133+
"jY1M2U5NWMtZGY2OC00ZjYyLTljZGYtYmZlOWEzODM3MDMwLjlmZWY5OGNlLWQ1Y2EtNDgwMC04N2Y4LWZkNTNkMDM4ZDdiMXgxNzQ4NjA0NzI0NzE4NjU3MTY3",
134+
parts,
135+
PutObjectOptions{},
136+
)
137+
if err == nil {
138+
t.Fatal("CompleteMultipartUpload() returned <nil>, which is unexpected")
139+
}
140+
141+
expectedErrorMsg := "Resource requested is unwritable, please reduce your request rate"
142+
if err.Error() != expectedErrorMsg {
143+
t.Fatalf("Unexpected returned error, expected: `%v`, found: `%v`", expectedErrorMsg, err.Error())
144+
}
145+
146+
if retries != 0 {
147+
t.Fatalf("CompleteMultipart request was not retried enough times, expected: %d, found: %d", maxRetries, retries)
148+
}
149+
}
150+
151+
func Test200DeleteObjectsWithError(t *testing.T) {
152+
const maxRetries = 3
153+
retries := maxRetries
154+
155+
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
156+
retries--
157+
w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>`))
158+
w.(http.Flusher).Flush()
159+
for i := 0; i < 5; i++ {
160+
time.Sleep(time.Second)
161+
w.Write([]byte(" "))
162+
w.(http.Flusher).Flush()
163+
}
164+
165+
w.Write([]byte(`<Error><Code>SlowDownWrite</Code><Message>Resource requested is unwritable, please reduce your request rate</Message><Key>object</Key><BucketName>bucket</BucketName><Resource>/bucket/object</Resource><RequestId>18413E84F6C30613</RequestId><HostId>49371f38c0d7ec74eae2befc695360a3dfece04732914e58a4281759cd2eba4f</HostId></Error>`))
166+
}))
167+
168+
srv, err := url.Parse(ts.URL)
169+
if err != nil {
170+
t.Fatal(err)
171+
}
172+
173+
// Instantiate new minio client object.
174+
core, err := NewCore(
175+
srv.Host,
176+
&Options{
177+
Creds: credentials.NewStaticV4("foo", "foo12345", ""),
178+
Secure: srv.Scheme == "https",
179+
Region: "us-east-1",
180+
MaxRetries: retries,
181+
})
182+
if err != nil {
183+
t.Fatal("Error:", err)
184+
}
185+
186+
core.TraceOn(os.Stderr)
187+
188+
objs := make(chan ObjectInfo, 1000)
189+
for i := range 1000 {
190+
objs <- ObjectInfo{Key: fmt.Sprintf("obj-%d", i)}
191+
}
192+
close(objs)
193+
194+
delErrCh := core.RemoveObjects(context.Background(), "bucket", objs, RemoveObjectsOptions{})
195+
delErr := <-delErrCh
196+
err = delErr.Err
197+
if err == nil {
198+
t.Fatal("RemoveObjects() returned <nil>, which is unexpected")
199+
}
200+
201+
expectedErrorMsg := "Resource requested is unwritable, please reduce your request rate"
202+
if err.Error() != expectedErrorMsg {
203+
t.Fatalf("Unexpected returned error, expected: `%v`, found: `%v`", expectedErrorMsg, err.Error())
204+
}
205+
206+
if retries != 0 {
207+
t.Fatalf("RemoveObjects() request was not retried enough times, expected: %d, found: %d", maxRetries, retries)
208+
}
209+
}

0 commit comments

Comments
 (0)