Skip to content

Commit e6eeeb7

Browse files
Merge pull request #2114 from ardaguclu/update-some-dependencies
NO-JIRA: Migrate to aws-sdk-go-v2 from archived aws-sdk-go
2 parents 672ff62 + 9e4292b commit e6eeeb7

File tree

830 files changed

+185754
-133758
lines changed

Some content is hidden

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

830 files changed

+185754
-133758
lines changed

go.mod

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ require (
1010
github.com/alexbrainman/sspi v0.0.0-20250919150558-7d374ff0d59e
1111
github.com/alicebob/sqlittle v1.4.0
1212
github.com/apcera/gssapi v0.0.0-00010101000000-000000000000
13-
github.com/aws/aws-sdk-go v1.55.7
13+
github.com/aws/aws-sdk-go-v2 v1.39.2
14+
github.com/aws/aws-sdk-go-v2/config v1.31.12
15+
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.19.11
16+
github.com/aws/aws-sdk-go-v2/service/s3 v1.88.3
17+
github.com/aws/smithy-go v1.23.0
1418
github.com/blang/semver v3.5.1+incompatible
1519
github.com/containers/image/v5 v5.32.2
1620
github.com/containers/storage v1.58.0
@@ -70,6 +74,20 @@ require (
7074
github.com/BurntSushi/toml v1.5.0 // indirect
7175
github.com/Microsoft/go-winio v0.6.2 // indirect
7276
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
77+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.1 // indirect
78+
github.com/aws/aws-sdk-go-v2/credentials v1.18.16 // indirect
79+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.9 // indirect
80+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.9 // indirect
81+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.9 // indirect
82+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
83+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.9 // indirect
84+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.1 // indirect
85+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.8.9 // indirect
86+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.9 // indirect
87+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.9 // indirect
88+
github.com/aws/aws-sdk-go-v2/service/sso v1.29.6 // indirect
89+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.1 // indirect
90+
github.com/aws/aws-sdk-go-v2/service/sts v1.38.6 // indirect
7391
github.com/beorn7/perks v1.0.1 // indirect
7492
github.com/blang/semver/v4 v4.0.0 // indirect
7593
github.com/cespare/xxhash/v2 v2.3.0 // indirect
@@ -127,7 +145,6 @@ require (
127145
github.com/inconshreveable/mousetrap v1.1.0 // indirect
128146
github.com/int128/listener v1.2.0 // indirect
129147
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
130-
github.com/jmespath/go-jmespath v0.4.0 // indirect
131148
github.com/jonboulle/clockwork v0.4.0 // indirect
132149
github.com/josharian/intern v1.0.0 // indirect
133150
github.com/json-iterator/go v1.1.12 // indirect

go.sum

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,44 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd
3131
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
3232
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
3333
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
34-
github.com/aws/aws-sdk-go v1.55.7 h1:UJrkFq7es5CShfBwlWAC8DA077vp8PyVbQd3lqLiztE=
35-
github.com/aws/aws-sdk-go v1.55.7/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
34+
github.com/aws/aws-sdk-go-v2 v1.39.2 h1:EJLg8IdbzgeD7xgvZ+I8M1e0fL0ptn/M47lianzth0I=
35+
github.com/aws/aws-sdk-go-v2 v1.39.2/go.mod h1:sDioUELIUO9Znk23YVmIk86/9DOpkbyyVb1i/gUNFXY=
36+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.1 h1:i8p8P4diljCr60PpJp6qZXNlgX4m2yQFpYk+9ZT+J4E=
37+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.1/go.mod h1:ddqbooRZYNoJ2dsTwOty16rM+/Aqmk/GOXrK8cg7V00=
38+
github.com/aws/aws-sdk-go-v2/config v1.31.12 h1:pYM1Qgy0dKZLHX2cXslNacbcEFMkDMl+Bcj5ROuS6p8=
39+
github.com/aws/aws-sdk-go-v2/config v1.31.12/go.mod h1:/MM0dyD7KSDPR+39p9ZNVKaHDLb9qnfDurvVS2KAhN8=
40+
github.com/aws/aws-sdk-go-v2/credentials v1.18.16 h1:4JHirI4zp958zC026Sm+V4pSDwW4pwLefKrc0bF2lwI=
41+
github.com/aws/aws-sdk-go-v2/credentials v1.18.16/go.mod h1:qQMtGx9OSw7ty1yLclzLxXCRbrkjWAM7JnObZjmCB7I=
42+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.9 h1:Mv4Bc0mWmv6oDuSWTKnk+wgeqPL5DRFu5bQL9BGPQ8Y=
43+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.9/go.mod h1:IKlKfRppK2a1y0gy1yH6zD+yX5uplJ6UuPlgd48dJiQ=
44+
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.19.11 h1:w4GjasReY0m9vZA/3YhoBUBi1ZIWUHYQRm61v0BKcZg=
45+
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.19.11/go.mod h1:IPS1CSYQ8lfLYGytpMEPW4erZmVFUdxLpC0RCI/RCn8=
46+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.9 h1:se2vOWGD3dWQUtfn4wEjRQJb1HK1XsNIt825gskZ970=
47+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.9/go.mod h1:hijCGH2VfbZQxqCDN7bwz/4dzxV+hkyhjawAtdPWKZA=
48+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.9 h1:6RBnKZLkJM4hQ+kN6E7yWFveOTg8NLPHAkqrs4ZPlTU=
49+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.9/go.mod h1:V9rQKRmK7AWuEsOMnHzKj8WyrIir1yUJbZxDuZLFvXI=
50+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 h1:bIqFDwgGXXN1Kpp99pDOdKMTTb5d2KyU5X/BZxjOkRo=
51+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3/go.mod h1:H5O/EsxDWyU+LP/V8i5sm8cxoZgc2fdNR9bxlOFrQTo=
52+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.9 h1:w9LnHqTq8MEdlnyhV4Bwfizd65lfNCNgdlNC6mM5paE=
53+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.9/go.mod h1:LGEP6EK4nj+bwWNdrvX/FnDTFowdBNwcSPuZu/ouFys=
54+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.1 h1:oegbebPEMA/1Jny7kvwejowCaHz1FWZAQ94WXFNCyTM=
55+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.1/go.mod h1:kemo5Myr9ac0U9JfSjMo9yHLtw+pECEHsFtJ9tqCEI8=
56+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.8.9 h1:by3nYZLR9l8bUH7kgaMU4dJgYFjyRdFEfORlDpPILB4=
57+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.8.9/go.mod h1:IWjQYlqw4EX9jw2g3qnEPPWvCE6bS8fKzhMed1OK7c8=
58+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.9 h1:5r34CgVOD4WZudeEKZ9/iKpiT6cM1JyEROpXjOcdWv8=
59+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.9/go.mod h1:dB12CEbNWPbzO2uC6QSWHteqOg4JfBVJOojbAoAUb5I=
60+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.9 h1:wuZ5uW2uhJR63zwNlqWH2W4aL4ZjeJP3o92/W+odDY4=
61+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.9/go.mod h1:/G58M2fGszCrOzvJUkDdY8O9kycodunH4VdT5oBAqls=
62+
github.com/aws/aws-sdk-go-v2/service/s3 v1.88.3 h1:P18I4ipbk+b/3dZNq5YYh+Hq6XC0vp5RWkLp1tJldDA=
63+
github.com/aws/aws-sdk-go-v2/service/s3 v1.88.3/go.mod h1:Rm3gw2Jov6e6kDuamDvyIlZJDMYk97VeCZ82wz/mVZ0=
64+
github.com/aws/aws-sdk-go-v2/service/sso v1.29.6 h1:A1oRkiSQOWstGh61y4Wc/yQ04sqrQZr1Si/oAXj20/s=
65+
github.com/aws/aws-sdk-go-v2/service/sso v1.29.6/go.mod h1:5PfYspyCU5Vw1wNPsxi15LZovOnULudOQuVxphSflQA=
66+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.1 h1:5fm5RTONng73/QA73LhCNR7UT9RpFH3hR6HWL6bIgVY=
67+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.1/go.mod h1:xBEjWD13h+6nq+z4AkqSfSvqRKFgDIQeaMguAJndOWo=
68+
github.com/aws/aws-sdk-go-v2/service/sts v1.38.6 h1:p3jIvqYwUZgu/XYeI48bJxOhvm47hZb5HUQ0tn6Q9kA=
69+
github.com/aws/aws-sdk-go-v2/service/sts v1.38.6/go.mod h1:WtKK+ppze5yKPkZ0XwqIVWD4beCwv056ZbPQNoeHqM8=
70+
github.com/aws/smithy-go v1.23.0 h1:8n6I3gXzWJB2DxBDnfxgBaSX6oe0d/t10qGz7OKqMCE=
71+
github.com/aws/smithy-go v1.23.0/go.mod h1:t1ufH5HMublsJYulve2RKmHDC15xu1f26kHCp/HgceI=
3672
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
3773
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
3874
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -241,10 +277,6 @@ github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh6
241277
github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs=
242278
github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY=
243279
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
244-
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
245-
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
246-
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
247-
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
248280
github.com/jmhodges/clock v1.2.0 h1:eq4kys+NI0PLngzaHEe7AmPT90XMGIEySD1JfV1PDIs=
249281
github.com/jmhodges/clock v1.2.0/go.mod h1:qKjhA7x7u/lQpPB1XAqX1b1lCI/w3/fNuYpI/ZjLynI=
250282
github.com/joelanford/ignore v0.1.1 h1:vKky5RDoPT+WbONrbQBgOn95VV/UPh4ejlyAbbzgnQk=
@@ -539,7 +571,6 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
539571
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
540572
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
541573
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
542-
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
543574
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
544575
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
545576
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

pkg/cli/image/imagesource/s3.go

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package imagesource
33
import (
44
"bytes"
55
"context"
6+
"errors"
67
"fmt"
78
"io"
89
"net/http"
@@ -14,17 +15,16 @@ import (
1415

1516
"k8s.io/klog/v2"
1617

17-
"github.com/aws/aws-sdk-go/aws"
18-
"github.com/aws/aws-sdk-go/aws/awserr"
19-
"github.com/aws/aws-sdk-go/aws/credentials"
20-
"github.com/aws/aws-sdk-go/aws/session"
21-
"github.com/aws/aws-sdk-go/service/s3"
22-
"github.com/aws/aws-sdk-go/service/s3/s3manager"
18+
"github.com/aws/aws-sdk-go-v2/aws"
19+
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
20+
"github.com/aws/aws-sdk-go-v2/config"
21+
"github.com/aws/aws-sdk-go-v2/feature/s3/manager"
22+
"github.com/aws/aws-sdk-go-v2/service/s3"
23+
"github.com/aws/smithy-go"
2324

2425
"github.com/distribution/distribution/v3"
2526
"github.com/distribution/distribution/v3/reference"
2627
"github.com/distribution/distribution/v3/registry/client/auth"
27-
"github.com/distribution/distribution/v3/registry/client/transport"
2828
godigest "github.com/opencontainers/go-digest"
2929
)
3030

@@ -34,76 +34,73 @@ type s3Driver struct {
3434
Creds auth.CredentialStore
3535
CopyFrom []string
3636

37-
repositories map[string]*s3.S3
37+
repositories map[string]*s3.Client
3838
}
3939

4040
type s3CredentialStore struct {
41-
store auth.CredentialStore
42-
url *url.URL
43-
retrieved bool
41+
store auth.CredentialStore
42+
url *url.URL
4443
}
4544

46-
func (s *s3CredentialStore) IsExpired() bool { return !s.retrieved }
47-
48-
func (s *s3CredentialStore) Retrieve() (credentials.Value, error) {
49-
s.retrieved = false
45+
func (s *s3CredentialStore) Retrieve(ctx context.Context) (aws.Credentials, error) {
5046
accessKeyID, secretAccessKey := s.store.Basic(s.url)
5147
if len(accessKeyID) == 0 || len(secretAccessKey) == 0 {
52-
return credentials.Value{}, fmt.Errorf("no AWS credentials located for %s", s.url)
48+
return aws.Credentials{}, fmt.Errorf("no AWS credentials located for %s", s.url)
5349
}
54-
s.retrieved = true
5550
klog.V(4).Infof("found credentials for %s", s.url)
56-
return credentials.Value{
51+
return aws.Credentials{
5752
AccessKeyID: accessKeyID,
5853
SecretAccessKey: secretAccessKey,
59-
ProviderName: "DockerCfg",
54+
Source: "DockerCfg",
6055
}, nil
6156
}
6257

63-
func (d *s3Driver) newObject(server *url.URL, region string, insecure bool, securityDomain *url.URL) (*s3.S3, error) {
58+
func (d *s3Driver) newObject(server *url.URL, region string, insecure bool, securityDomain *url.URL) (*s3.Client, error) {
6459
key := fmt.Sprintf("%s:%s:%t:%s", server, region, insecure, securityDomain)
6560
s3obj, ok := d.repositories[key]
6661
if ok {
6762
return s3obj, nil
6863
}
6964

70-
awsConfig := aws.NewConfig()
65+
ctx := context.Background()
7166

72-
var creds *credentials.Credentials
73-
creds = credentials.NewChainCredentials([]credentials.Provider{
74-
&s3CredentialStore{store: d.Creds, url: securityDomain},
75-
&credentials.EnvProvider{},
76-
&credentials.SharedCredentialsProvider{},
77-
})
67+
configOpts := []func(*config.LoadOptions) error{
68+
config.WithRegion(region),
69+
}
7870

79-
awsConfig.WithCredentials(creds)
80-
awsConfig.WithRegion(region)
81-
awsConfig.WithDisableSSL(insecure)
71+
credStore := &s3CredentialStore{store: d.Creds, url: securityDomain}
72+
if _, err := credStore.Retrieve(ctx); err == nil {
73+
configOpts = append(configOpts, config.WithCredentialsProvider(credStore))
74+
}
8275

8376
switch {
8477
case klog.V(10).Enabled():
85-
awsConfig.WithLogLevel(aws.LogDebugWithHTTPBody | aws.LogDebugWithRequestErrors | aws.LogDebugWithSigning)
78+
configOpts = append(configOpts, config.WithClientLogMode(aws.LogSigning|aws.LogRetries|aws.LogRequest|aws.LogResponse|aws.LogResponseWithBody|aws.LogDeprecatedUsage))
8679
case klog.V(8).Enabled():
87-
awsConfig.WithLogLevel(aws.LogDebugWithRequestErrors)
80+
configOpts = append(configOpts, config.WithClientLogMode(aws.LogRetries|aws.LogRequest|aws.LogResponse|aws.LogDeprecatedUsage))
8881
case klog.V(6).Enabled():
89-
awsConfig.WithLogLevel(aws.LogDebug)
82+
configOpts = append(configOpts, config.WithClientLogMode(aws.LogRetries|aws.LogRequest|aws.LogDeprecatedUsage))
9083
}
9184

92-
if d.UserAgent != "" {
93-
awsConfig.WithHTTPClient(&http.Client{
94-
Transport: transport.NewTransport(http.DefaultTransport, transport.NewHeaderRequestModifier(http.Header{http.CanonicalHeaderKey("User-Agent"): []string{d.UserAgent}})),
95-
})
96-
}
97-
s, err := session.NewSession(awsConfig)
85+
cfg, err := config.LoadDefaultConfig(ctx, configOpts...)
9886
if err != nil {
9987
return nil, err
10088
}
101-
s3obj = s3.New(s)
89+
90+
s3Client := s3.NewFromConfig(cfg, func(o *s3.Options) {
91+
if insecure {
92+
o.EndpointOptions.DisableHTTPS = true
93+
}
94+
if d.UserAgent != "" {
95+
o.APIOptions = append(o.APIOptions, awsmiddleware.AddUserAgentKey(d.UserAgent))
96+
}
97+
})
98+
10299
if d.repositories == nil {
103-
d.repositories = make(map[string]*s3.S3)
100+
d.repositories = make(map[string]*s3.Client)
104101
}
105-
d.repositories[key] = s3obj
106-
return s3obj, nil
102+
d.repositories[key] = s3Client
103+
return s3Client, nil
107104
}
108105

109106
func (d *s3Driver) Repository(ctx context.Context, server *url.URL, repoName string, insecure bool) (distribution.Repository, error) {
@@ -137,7 +134,7 @@ func (d *s3Driver) Repository(ctx context.Context, server *url.URL, repoName str
137134

138135
type s3Repository struct {
139136
ctx context.Context
140-
s3 *s3.S3
137+
s3 *s3.Client
141138
bucket string
142139
once sync.Once
143140
initErr error
@@ -168,7 +165,7 @@ func (r *s3Repository) Tags(ctx context.Context) distribution.TagService {
168165
}
169166

170167
func (r *s3Repository) attemptCopy(id string, bucket, key string) bool {
171-
if _, err := r.s3.HeadObject(&s3.HeadObjectInput{
168+
if _, err := r.s3.HeadObject(r.ctx, &s3.HeadObjectInput{
172169
Bucket: aws.String(bucket),
173170
Key: aws.String(key),
174171
}); err == nil {
@@ -190,16 +187,17 @@ func (r *s3Repository) attemptCopy(id string, bucket, key string) bool {
190187
} else {
191188
sourceKey = path.Join(copyFrom, id)
192189
}
193-
_, err := r.s3.CopyObject(&s3.CopyObjectInput{
194-
CopySource: aws.String(sourceKey),
190+
_, err := r.s3.CopyObject(r.ctx, &s3.CopyObjectInput{
191+
CopySource: aws.String(url.QueryEscape(sourceKey)),
195192
Bucket: aws.String(bucket),
196193
Key: aws.String(key),
197194
})
198195
if err == nil {
199196
klog.V(4).Infof("Copied existing object from %s to %s", sourceKey, key)
200197
return true
201198
}
202-
if a, ok := err.(awserr.Error); ok && a.Code() == "NoSuchKey" {
199+
var apiErr smithy.APIError
200+
if errors.As(err, &apiErr) && apiErr.ErrorCode() == "NoSuchKey" {
203201
klog.V(4).Infof("No existing object matches source %s", sourceKey)
204202
continue
205203
}
@@ -208,19 +206,20 @@ func (r *s3Repository) attemptCopy(id string, bucket, key string) bool {
208206
return false
209207
}
210208

211-
func (r *s3Repository) conditionalUpload(input *s3manager.UploadInput, id string) error {
209+
func (r *s3Repository) conditionalUpload(input *s3.PutObjectInput, id string) error {
212210
if r.attemptCopy(id, *input.Bucket, *input.Key) {
213211
return nil
214212
}
215-
_, err := s3manager.NewUploaderWithClient(r.s3).Upload(input)
213+
uploader := manager.NewUploader(r.s3)
214+
_, err := uploader.Upload(r.ctx, input)
216215
return err
217216
}
218217

219218
func (r *s3Repository) init() error {
220219
r.once.Do(func() {
221-
r.initErr = r.conditionalUpload(&s3manager.UploadInput{
220+
r.initErr = r.conditionalUpload(&s3.PutObjectInput{
222221
Bucket: aws.String(r.bucket),
223-
Metadata: map[string]*string{"X-Docker-Distribution-API-Version": aws.String("registry/2.0")},
222+
Metadata: map[string]string{"X-Docker-Distribution-API-Version": "registry/2.0"},
224223
Body: bytes.NewBufferString(""),
225224
Key: aws.String("/v2/"),
226225
}, "")
@@ -264,7 +263,7 @@ func (s *s3ManifestService) Put(ctx context.Context, manifest distribution.Manif
264263
dgst := godigest.FromBytes(payload)
265264
blob := fmt.Sprintf("/v2/%s/blobs/%s", s.r.repoName, dgst)
266265

267-
if err := s.r.conditionalUpload(&s3manager.UploadInput{
266+
if err := s.r.conditionalUpload(&s3.PutObjectInput{
268267
Bucket: aws.String(s.r.bucket),
269268
ContentType: aws.String(mediaType),
270269
Body: bytes.NewBuffer(payload),
@@ -281,10 +280,10 @@ func (s *s3ManifestService) Put(ctx context.Context, manifest distribution.Manif
281280
}
282281
}
283282
for _, tag := range tags {
284-
if _, err := s.r.s3.CopyObject(&s3.CopyObjectInput{
283+
if _, err := s.r.s3.CopyObject(s.r.ctx, &s3.CopyObjectInput{
285284
Bucket: aws.String(s.r.bucket),
286285
ContentType: aws.String(mediaType),
287-
CopySource: aws.String(path.Join(s.r.bucket, blob)),
286+
CopySource: aws.String(path.Join(s.r.bucket, url.QueryEscape(blob))),
288287
Key: aws.String(fmt.Sprintf("/v2/%s/manifests/%s", s.r.repoName, tag)),
289288
}); err != nil {
290289
return "", err
@@ -328,7 +327,7 @@ func (s *s3BlobStore) Put(ctx context.Context, mediaType string, p []byte) (dist
328327
return distribution.Descriptor{}, err
329328
}
330329
d := godigest.FromBytes(p)
331-
if err := s.r.conditionalUpload(&s3manager.UploadInput{
330+
if err := s.r.conditionalUpload(&s3.PutObjectInput{
332331
Bucket: aws.String(s.r.bucket),
333332
ContentType: aws.String(mediaType),
334333
Body: bytes.NewBuffer(p),
@@ -409,7 +408,8 @@ func (w *writer) ReadFrom(r io.Reader) (int64, error) {
409408
if w.startedAt.IsZero() {
410409
w.startedAt = time.Now()
411410
}
412-
_, err := s3manager.NewUploaderWithClient(w.driver.s3).Upload(&s3manager.UploadInput{
411+
uploader := manager.NewUploader(w.driver.s3)
412+
_, err := uploader.Upload(w.driver.ctx, &s3.PutObjectInput{
413413
Bucket: aws.String(w.driver.bucket),
414414
ContentType: aws.String("application/octet-stream"),
415415
Key: aws.String(w.key),

vendor/github.com/aws/aws-sdk-go-v2/aws/accountid_endpoint_mode.go

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/aws/aws-sdk-go/aws/arn/arn.go renamed to vendor/github.com/aws/aws-sdk-go-v2/aws/arn/arn.go

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)