This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 9bab304cb refactor(kiro): migrate from aws-sdk-go v1 to aws-sdk-go-v2
(#9233)
9bab304cb is described below
commit 9bab304cb284f4de152007064834c584bbd90bb8
Author: ay5399 <[email protected]>
AuthorDate: Thu Oct 22 10:26:57 2026 +0900
refactor(kiro): migrate from aws-sdk-go v1 to aws-sdk-go-v2 (#9233)
aws-sdk-go v1 reached end-of-support on 2025-07-31 and its last release
deprecates every package. The kiro plugin was its only consumer.
- Build S3 and Identity Store clients from config.LoadDefaultConfig with
the connection's region and static credentials, as before.
- Adapt the S3API and IdentityStoreAPI interfaces and the test doubles
to the v2 method signatures, which take a context.Context. The S3
collector passes the subtask context; other call sites use
context.Background(), matching v1's behaviour.
- Listing results are value slices in v2 (types.Object,
types.CommonPrefix); MaxKeys is now an int32.
With no remaining importer, go mod tidy drops github.com/aws/aws-sdk-go
(and github.com/jmespath/go-jmespath) from go.mod, which the "go.mod is
tidy" CI check requires.
Refs #9195
Co-authored-by: Yasuhiro Aihara <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
backend/go.mod | 21 +++++++++-
backend/go.sum | 46 ++++++++++++++++++----
backend/plugins/kiro/api/test_connection.go | 9 +++--
backend/plugins/kiro/tasks/discovery_test.go | 14 ++++---
backend/plugins/kiro/tasks/identity_client.go | 26 ++++++------
backend/plugins/kiro/tasks/s3_client.go | 29 +++++++-------
backend/plugins/kiro/tasks/s3_client_test.go | 11 +++---
backend/plugins/kiro/tasks/s3_file_collector.go | 6 +--
.../plugins/kiro/tasks/s3_file_collector_test.go | 11 +++---
9 files changed, 114 insertions(+), 59 deletions(-)
diff --git a/backend/go.mod b/backend/go.mod
index 81ca3192e..5b00420c0 100644
--- a/backend/go.mod
+++ b/backend/go.mod
@@ -3,7 +3,6 @@ module github.com/apache/devlake
go 1.26.0
require (
- github.com/aws/aws-sdk-go v1.55.8
github.com/cockroachdb/errors v1.14.0
// github.com/gin-contrib/cors v1.6.0
github.com/gin-gonic/gin v1.12.0
@@ -40,6 +39,11 @@ require (
)
require (
+ github.com/aws/aws-sdk-go-v2 v1.47.3
+ github.com/aws/aws-sdk-go-v2/config v1.33.9
+ github.com/aws/aws-sdk-go-v2/credentials v1.20.9
+ github.com/aws/aws-sdk-go-v2/service/identitystore v1.49.1
+ github.com/aws/aws-sdk-go-v2/service/s3 v1.114.3
github.com/chainguard-dev/git-urls v1.0.2
github.com/coreos/go-oidc/v3 v3.21.0
github.com/go-sql-driver/mysql v1.10.1
@@ -57,6 +61,20 @@ require (
github.com/ProtonMail/go-crypto v1.1.6 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 //
indirect
+ github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.22 //
indirect
+ github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.3 // indirect
+ github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.6 // indirect
+ github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.6 // indirect
+ github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.6 // indirect
+ github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.21
// indirect
+ github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.7 //
indirect
+ github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.6 //
indirect
+ github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.6 //
indirect
+ github.com/aws/aws-sdk-go-v2/service/signin v1.10.4 // indirect
+ github.com/aws/aws-sdk-go-v2/service/sso v1.38.4 // indirect
+ github.com/aws/aws-sdk-go-v2/service/ssooidc v1.43.4 // indirect
+ github.com/aws/aws-sdk-go-v2/service/sts v1.51.4 // indirect
+ github.com/aws/smithy-go v1.28.5 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/bytedance/sonic v1.15.0 // indirect
github.com/bytedance/sonic/loader v0.5.0 // indirect
@@ -90,7 +108,6 @@ require (
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 //
indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
- github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
diff --git a/backend/go.sum b/backend/go.sum
index 4f81d9186..fc1f4c13c 100644
--- a/backend/go.sum
+++ b/backend/go.sum
@@ -17,8 +17,44 @@ github.com/anmitsu/go-shlex
v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod
h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod
h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
-github.com/aws/aws-sdk-go v1.55.8
h1:JRmEUbU52aJQZ2AjX4q4Wu7t4uZjOu71uyNmaWlUkJQ=
-github.com/aws/aws-sdk-go v1.55.8/go.mod
h1:ZkViS9AqA6otK+JBBNH2++sx1sgxrPKcSzPPvQkUtXk=
+github.com/aws/aws-sdk-go-v2 v1.47.3
h1:HRoT/MkNi3bjO5xF4dCzLzvVmkvRGHj3/cLINDnJejk=
+github.com/aws/aws-sdk-go-v2 v1.47.3/go.mod
h1:xSl+OSI5ZUw6bSMupWc218zE5Pl+65MCCu3ySWFY99A=
+github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.22
h1:oiEmPz/YMMeh/JvAE8xSxNCIsvWE6lpFe4ZPlyFykQI=
+github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.22/go.mod
h1:QWUDuRi9PFjBHIU2iH1Pkldbe7zqLfXJC4wWLbF8nuQ=
+github.com/aws/aws-sdk-go-v2/config v1.33.9
h1:Hv6bcQUJVnmuWaKjqD6Ot8sE75NrWsWV20oGT5aWle0=
+github.com/aws/aws-sdk-go-v2/config v1.33.9/go.mod
h1:ivowmrZNfBQLcg4QkaItgi5wae4Bzot9RzIdbY1hfTg=
+github.com/aws/aws-sdk-go-v2/credentials v1.20.9
h1:SNO55PnWhaDafsOcv16lCA0kdoFMl/YlegWoVsU02s0=
+github.com/aws/aws-sdk-go-v2/credentials v1.20.9/go.mod
h1:+2reOTRtdD3VSBqpRDNwrZIYy8yMCYa7oK3WKTJ/I1I=
+github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.3
h1:gr3b87OLB29jymWPzp/CAyXwQRJVE+sC4Wm0qBIKHsk=
+github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.3/go.mod
h1:BRjf4L/Yx2hY54o+ZibPbLJyMMeSwqYQXwcJfqW66a8=
+github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.6
h1:CqL8NN3p4I0JTwwV5MEoatIl4Y2amZ2X9dRD+0hbRL0=
+github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.6/go.mod
h1:exdJ32hMqXl0Wyo6NwqEC5yIhtua3+PDaKE8P29m4qE=
+github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.6
h1:FpBq24TG6WVSObTNhQOv7Q0088rounUUlwn3zlNItkM=
+github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.6/go.mod
h1:ONzdPVYC95oBOu0VWNEsKEntcoemP3xVKjT+qWml1s4=
+github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.6
h1:Qmn60RWuk9+bd2ddvJJqwf3Cpac3VvGMOdbGemtUhX4=
+github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.6/go.mod
h1:h/YJhe4AVyQxEUMluph10iqV7mjajH7A9L+BHF5ppis=
+github.com/aws/aws-sdk-go-v2/service/identitystore v1.49.1
h1:2v1fGLwkCChJvo00f0GEEUwGc1V1AwkhyXvw/HswJO8=
+github.com/aws/aws-sdk-go-v2/service/identitystore v1.49.1/go.mod
h1:UrQ4m81lBEG41VhRuqEa/+Y0LVZvBD4UdTrJNUAXXQc=
+github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.21
h1:e6YW5uME30TkrElR+4/xcY7NB6CCj2dcv7vtmGXhfhQ=
+github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.21/go.mod
h1:obpHAMP693+f3/A8PkLhIqfK1C+NWWn8zXzqD3OH520=
+github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.7
h1:CwvFlKw0uUScfgOMflXSRZa+ayXgOf6wk7lhyMemQYU=
+github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.7/go.mod
h1:4SbD8BB+p+QEnG0aX6DoWwrtk9SufyYXRsUv0nve8LE=
+github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.6
h1:LHHdobjo5le1sjJdolitV7uVvYg3wkaeM1Ju2fDgeZQ=
+github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.6/go.mod
h1:CBGB0evAiaMD3Lk4wPO7LQCcCZLuhzL5Qf/wfEUHQ5w=
+github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.6
h1:mYViDr2azcgxOpRrObZOl631bvavqILoE/L+Kxgbwys=
+github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.6/go.mod
h1:OXVdAo9jNhggB+hJRGOyy7WolGTKB6Rg7IIulDeSzPM=
+github.com/aws/aws-sdk-go-v2/service/s3 v1.114.3
h1:NyeuyXkZL476uoAowNActm4XJO1QPKf7aassgXHpiqA=
+github.com/aws/aws-sdk-go-v2/service/s3 v1.114.3/go.mod
h1:GfoBeKMDJecgRUsGf/0RGdx0NJAh81ObTd922h8pQys=
+github.com/aws/aws-sdk-go-v2/service/signin v1.10.4
h1:tvpDjuUvgKURf3Yk4hOaGbZ4QdY+070OWcA5d6LUv2A=
+github.com/aws/aws-sdk-go-v2/service/signin v1.10.4/go.mod
h1:3ibVKg5Ng82Zby8++jELTD2nHxiPk2DJRLEeW/LKp8M=
+github.com/aws/aws-sdk-go-v2/service/sso v1.38.4
h1:ChCtagixSFOxltv0o6E3NT8F7ksvZtZGPwUBynO5Nmk=
+github.com/aws/aws-sdk-go-v2/service/sso v1.38.4/go.mod
h1:+FEO9jrVMpc9oN3CdAxJbtlQEu3z8UddDPSedpeM3PY=
+github.com/aws/aws-sdk-go-v2/service/ssooidc v1.43.4
h1:j6c+HA4AoS0EBEjArPjavFEBrucJEryfrQU0TffmACk=
+github.com/aws/aws-sdk-go-v2/service/ssooidc v1.43.4/go.mod
h1:RhghaXUk9q66VtOQUX1FdPddQuHnqQZzbB0fEYXmPRA=
+github.com/aws/aws-sdk-go-v2/service/sts v1.51.4
h1:OKEfbf2tcfsF2pBk/S9QqNpo6alaAtiBs4hysCsBjPw=
+github.com/aws/aws-sdk-go-v2/service/sts v1.51.4/go.mod
h1:mCd6qGo9b8hTtfjgsmNkFlzwjyce4owd7HDVFnCLXhM=
+github.com/aws/smithy-go v1.28.5
h1:OqbqKtzY9NUnr2yAe9+hiTdFb20tNaK/lI0PMOGXX9k=
+github.com/aws/smithy-go v1.28.5/go.mod
h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
github.com/bytedance/gopkg v0.1.3
h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
github.com/bytedance/gopkg v0.1.3/go.mod
h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
github.com/bytedance/sonic v1.15.0
h1:/PXeWFaR5ElNcVE84U0dOHjiMHQOwNIx3K4ymzh/uSE=
@@ -139,10 +175,6 @@ github.com/jinzhu/inflection v1.0.0
h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
github.com/jinzhu/inflection v1.0.0/go.mod
h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod
h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
-github.com/jmespath/go-jmespath v0.4.0
h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
-github.com/jmespath/go-jmespath v0.4.0/go.mod
h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
-github.com/jmespath/go-jmespath/internal/testify v1.5.1
h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
-github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod
h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/josharian/intern v1.0.0
h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod
h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12
h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
@@ -198,7 +230,6 @@ github.com/pjbgf/sha1cd v0.7.0/go.mod
h1:pKR5Li+qTCo+ebqITZfwPlJGoCFCvSO00qxjbNt
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod
h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod
h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
-github.com/pmezard/go-difflib v1.0.0
h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod
h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
github.com/quic-go/qpack v0.6.0/go.mod
h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
@@ -371,7 +402,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod
h1:JHkPIbrfpd72SG/EV
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod
h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod
h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/backend/plugins/kiro/api/test_connection.go
b/backend/plugins/kiro/api/test_connection.go
index 75117ed28..c04dd2a71 100644
--- a/backend/plugins/kiro/api/test_connection.go
+++ b/backend/plugins/kiro/api/test_connection.go
@@ -18,11 +18,12 @@ limitations under the License.
package api
import (
+ "context"
"fmt"
"net/http"
- "github.com/aws/aws-sdk-go/aws"
- "github.com/aws/aws-sdk-go/service/s3"
+ "github.com/aws/aws-sdk-go-v2/aws"
+ "github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/apache/devlake/core/errors"
"github.com/apache/devlake/core/plugin"
@@ -203,9 +204,9 @@ func testConnection(connection *models.KiroConnection)
errors.Error {
if bucket == clients.PromptLog.Bucket {
client = clients.PromptLog
}
- if _, listErr := client.S3.ListObjectsV2(&s3.ListObjectsV2Input{
+ if _, listErr := client.S3.ListObjectsV2(context.Background(),
&s3.ListObjectsV2Input{
Bucket: aws.String(bucket),
- MaxKeys: aws.Int64(1),
+ MaxKeys: aws.Int32(1),
}); listErr != nil {
return errors.BadInput.Wrap(listErr, "cannot access s3
bucket "+bucket)
}
diff --git a/backend/plugins/kiro/tasks/discovery_test.go
b/backend/plugins/kiro/tasks/discovery_test.go
index be316ef1c..73bee1812 100644
--- a/backend/plugins/kiro/tasks/discovery_test.go
+++ b/backend/plugins/kiro/tasks/discovery_test.go
@@ -18,10 +18,12 @@ limitations under the License.
package tasks
import (
+ "context"
"testing"
- "github.com/aws/aws-sdk-go/aws"
- "github.com/aws/aws-sdk-go/service/s3"
+ "github.com/aws/aws-sdk-go-v2/aws"
+ "github.com/aws/aws-sdk-go-v2/service/s3"
+ "github.com/aws/aws-sdk-go-v2/service/s3/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -39,7 +41,7 @@ type prefixMockS3 struct {
seenPrefix []string
}
-func (m *prefixMockS3) ListObjectsV2(input *s3.ListObjectsV2Input)
(*s3.ListObjectsV2Output, error) {
+func (m *prefixMockS3) ListObjectsV2(_ context.Context, input
*s3.ListObjectsV2Input, _ ...func(*s3.Options)) (*s3.ListObjectsV2Output,
error) {
prefix := ""
if input.Prefix != nil {
prefix = *input.Prefix
@@ -54,15 +56,15 @@ func (m *prefixMockS3) ListObjectsV2(input
*s3.ListObjectsV2Input) (*s3.ListObje
out := &s3.ListObjectsV2Output{IsTruncated: aws.Bool(false)}
for _, child := range m.commonPrefixes[prefix] {
full := prefix + child + "/"
- out.CommonPrefixes = append(out.CommonPrefixes,
&s3.CommonPrefix{Prefix: aws.String(full)})
+ out.CommonPrefixes = append(out.CommonPrefixes,
types.CommonPrefix{Prefix: aws.String(full)})
}
for _, key := range m.objects[prefix] {
- out.Contents = append(out.Contents, &s3.Object{Key:
aws.String(prefix + key)})
+ out.Contents = append(out.Contents, types.Object{Key:
aws.String(prefix + key)})
}
return out, nil
}
-func (m *prefixMockS3) GetObject(*s3.GetObjectInput) (*s3.GetObjectOutput,
error) {
+func (m *prefixMockS3) GetObject(context.Context, *s3.GetObjectInput,
...func(*s3.Options)) (*s3.GetObjectOutput, error) {
return nil, nil
}
diff --git a/backend/plugins/kiro/tasks/identity_client.go
b/backend/plugins/kiro/tasks/identity_client.go
index 953a16b37..c902f1e10 100644
--- a/backend/plugins/kiro/tasks/identity_client.go
+++ b/backend/plugins/kiro/tasks/identity_client.go
@@ -18,17 +18,19 @@ limitations under the License.
package tasks
import (
- "github.com/aws/aws-sdk-go/aws"
- "github.com/aws/aws-sdk-go/aws/credentials"
- "github.com/aws/aws-sdk-go/aws/session"
- "github.com/aws/aws-sdk-go/service/identitystore"
+ "context"
+
+ "github.com/aws/aws-sdk-go-v2/aws"
+ "github.com/aws/aws-sdk-go-v2/config"
+ "github.com/aws/aws-sdk-go-v2/credentials"
+ "github.com/aws/aws-sdk-go-v2/service/identitystore"
"github.com/apache/devlake/plugins/kiro/models"
)
// IdentityStoreAPI is the subset of the Identity Store API used here.
type IdentityStoreAPI interface {
- DescribeUser(input *identitystore.DescribeUserInput)
(*identitystore.DescribeUserOutput, error)
+ DescribeUser(ctx context.Context, params
*identitystore.DescribeUserInput, optFns ...func(*identitystore.Options))
(*identitystore.DescribeUserOutput, error)
}
// KiroIdentityClient resolves user ids to human-readable display names.
@@ -48,20 +50,20 @@ func NewKiroIdentityClient(connection
*models.KiroConnection) (*KiroIdentityClie
return nil, nil
}
- sess, err := session.NewSession(&aws.Config{
- Region: aws.String(connection.IdentityStoreRegion),
- Credentials: credentials.NewStaticCredentials(
+ cfg, err := config.LoadDefaultConfig(context.Background(),
+ config.WithRegion(connection.IdentityStoreRegion),
+
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(
connection.AccessKeyId,
connection.SecretAccessKey,
"",
- ),
- })
+ )),
+ )
if err != nil {
return nil, err
}
return &KiroIdentityClient{
- IdentityStore: identitystore.New(sess),
+ IdentityStore: identitystore.NewFromConfig(cfg),
StoreId: connection.IdentityStoreId,
}, nil
}
@@ -76,7 +78,7 @@ func (client *KiroIdentityClient) ResolveDisplayName(userId
string) (*string, er
return nil, nil
}
- result, err :=
client.IdentityStore.DescribeUser(&identitystore.DescribeUserInput{
+ result, err := client.IdentityStore.DescribeUser(context.Background(),
&identitystore.DescribeUserInput{
IdentityStoreId: aws.String(client.StoreId),
UserId: aws.String(userId),
})
diff --git a/backend/plugins/kiro/tasks/s3_client.go
b/backend/plugins/kiro/tasks/s3_client.go
index 16837259e..30159b8f2 100644
--- a/backend/plugins/kiro/tasks/s3_client.go
+++ b/backend/plugins/kiro/tasks/s3_client.go
@@ -18,14 +18,15 @@ limitations under the License.
package tasks
import (
+ "context"
"io"
"sort"
"strings"
- "github.com/aws/aws-sdk-go/aws"
- "github.com/aws/aws-sdk-go/aws/credentials"
- "github.com/aws/aws-sdk-go/aws/session"
- "github.com/aws/aws-sdk-go/service/s3"
+ "github.com/aws/aws-sdk-go-v2/aws"
+ "github.com/aws/aws-sdk-go-v2/config"
+ "github.com/aws/aws-sdk-go-v2/credentials"
+ "github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/apache/devlake/core/errors"
"github.com/apache/devlake/plugins/kiro/models"
@@ -34,8 +35,8 @@ import (
// S3API is the subset of the S3 API this plugin uses, declared as an interface
// so collectors and extractors can be tested without AWS.
type S3API interface {
- ListObjectsV2(input *s3.ListObjectsV2Input) (*s3.ListObjectsV2Output,
error)
- GetObject(input *s3.GetObjectInput) (*s3.GetObjectOutput, error)
+ ListObjectsV2(ctx context.Context, params *s3.ListObjectsV2Input,
optFns ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)
+ GetObject(ctx context.Context, params *s3.GetObjectInput, optFns
...func(*s3.Options)) (*s3.GetObjectOutput, error)
}
// KiroS3Client is bound to exactly one bucket.
@@ -60,17 +61,17 @@ type KiroS3Clients struct {
// NewKiroS3Clients builds the client pair for a connection.
func NewKiroS3Clients(connection *models.KiroConnection) (*KiroS3Clients,
errors.Error) {
- sess, err := session.NewSession(&aws.Config{
- Region: aws.String(connection.Region),
- Credentials:
credentials.NewStaticCredentials(connection.AccessKeyId,
connection.SecretAccessKey, ""),
- })
+ cfg, err := config.LoadDefaultConfig(context.Background(),
+ config.WithRegion(connection.Region),
+
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(connection.AccessKeyId,
connection.SecretAccessKey, "")),
+ )
if err != nil {
return nil, errors.Convert(err)
}
// A single S3 service client can address both buckets; the split is at
the
// KiroS3Client level, which pins the bucket name.
- svc := s3.New(sess)
+ svc := s3.NewFromConfig(cfg)
return &KiroS3Clients{
Report: &KiroS3Client{S3: svc, Bucket: connection.Bucket},
@@ -113,7 +114,7 @@ func (c *KiroS3Client) ListSubPrefixes(prefix string)
([]string, errors.Error) {
var names []string
var continuationToken *string
for {
- output, err := c.S3.ListObjectsV2(&s3.ListObjectsV2Input{
+ output, err := c.S3.ListObjectsV2(context.Background(),
&s3.ListObjectsV2Input{
Bucket: aws.String(c.Bucket),
Prefix: aws.String(prefix),
Delimiter: aws.String("/"),
@@ -161,7 +162,7 @@ func (c *KiroS3Client) CountObjects(prefix string, limit
int) (int, bool, errors
count := 0
var continuationToken *string
for {
- output, err := c.S3.ListObjectsV2(&s3.ListObjectsV2Input{
+ output, err := c.S3.ListObjectsV2(context.Background(),
&s3.ListObjectsV2Input{
Bucket: aws.String(c.Bucket),
Prefix: aws.String(prefix),
ContinuationToken: continuationToken,
@@ -200,7 +201,7 @@ func (c *KiroS3Client) CountObjects(prefix string, limit
int) (int, bool, errors
// completion log, and under 1 KB for a report CSV - so streaming would add
// complexity without saving memory.
func (c *KiroS3Client) GetObjectBytes(key string) ([]byte, errors.Error) {
- output, err := c.S3.GetObject(&s3.GetObjectInput{
+ output, err := c.S3.GetObject(context.Background(), &s3.GetObjectInput{
Bucket: aws.String(c.Bucket),
Key: aws.String(key),
})
diff --git a/backend/plugins/kiro/tasks/s3_client_test.go
b/backend/plugins/kiro/tasks/s3_client_test.go
index ad38af0ae..de2f8a49a 100644
--- a/backend/plugins/kiro/tasks/s3_client_test.go
+++ b/backend/plugins/kiro/tasks/s3_client_test.go
@@ -19,12 +19,13 @@ package tasks
import (
"bytes"
+ "context"
"errors"
"io"
"testing"
- "github.com/aws/aws-sdk-go/service/identitystore"
- "github.com/aws/aws-sdk-go/service/s3"
+ "github.com/aws/aws-sdk-go-v2/service/identitystore"
+ "github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -43,7 +44,7 @@ type mockS3 struct {
seenGetKeys []string
}
-func (m *mockS3) GetObject(input *s3.GetObjectInput) (*s3.GetObjectOutput,
error) {
+func (m *mockS3) GetObject(_ context.Context, input *s3.GetObjectInput, _
...func(*s3.Options)) (*s3.GetObjectOutput, error) {
m.seenGetBuckets = append(m.seenGetBuckets, *input.Bucket)
m.seenGetKeys = append(m.seenGetKeys, *input.Key)
if m.getObjectErr != nil {
@@ -54,7 +55,7 @@ func (m *mockS3) GetObject(input *s3.GetObjectInput)
(*s3.GetObjectOutput, error
}, nil
}
-func (m *mockS3) ListObjectsV2(input *s3.ListObjectsV2Input)
(*s3.ListObjectsV2Output, error) {
+func (m *mockS3) ListObjectsV2(_ context.Context, input
*s3.ListObjectsV2Input, _ ...func(*s3.Options)) (*s3.ListObjectsV2Output,
error) {
m.seenListBuckets = append(m.seenListBuckets, *input.Bucket)
if m.listCallIdx >= len(m.listOutputs) {
return &s3.ListObjectsV2Output{}, nil
@@ -162,7 +163,7 @@ type mockIdentityStore struct {
err error
}
-func (m *mockIdentityStore) DescribeUser(*identitystore.DescribeUserInput)
(*identitystore.DescribeUserOutput, error) {
+func (m *mockIdentityStore) DescribeUser(context.Context,
*identitystore.DescribeUserInput, ...func(*identitystore.Options))
(*identitystore.DescribeUserOutput, error) {
if m.err != nil {
return nil, m.err
}
diff --git a/backend/plugins/kiro/tasks/s3_file_collector.go
b/backend/plugins/kiro/tasks/s3_file_collector.go
index 5555ee7ac..3132ab041 100644
--- a/backend/plugins/kiro/tasks/s3_file_collector.go
+++ b/backend/plugins/kiro/tasks/s3_file_collector.go
@@ -21,8 +21,8 @@ import (
"path"
"strings"
- "github.com/aws/aws-sdk-go/aws"
- "github.com/aws/aws-sdk-go/service/s3"
+ "github.com/aws/aws-sdk-go-v2/aws"
+ "github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/apache/devlake/core/dal"
"github.com/apache/devlake/core/errors"
@@ -65,7 +65,7 @@ func CollectKiroS3Files(taskCtx plugin.SubTaskContext)
errors.Error {
var continuationToken *string
for {
- output, listErr :=
client.S3.ListObjectsV2(&s3.ListObjectsV2Input{
+ output, listErr :=
client.S3.ListObjectsV2(taskCtx.GetContext(), &s3.ListObjectsV2Input{
Bucket: aws.String(client.Bucket),
Prefix: aws.String(prefix),
ContinuationToken: continuationToken,
diff --git a/backend/plugins/kiro/tasks/s3_file_collector_test.go
b/backend/plugins/kiro/tasks/s3_file_collector_test.go
index 5e6069dca..a75b00e01 100644
--- a/backend/plugins/kiro/tasks/s3_file_collector_test.go
+++ b/backend/plugins/kiro/tasks/s3_file_collector_test.go
@@ -22,8 +22,9 @@ import (
"regexp"
"testing"
- "github.com/aws/aws-sdk-go/aws"
- "github.com/aws/aws-sdk-go/service/s3"
+ "github.com/aws/aws-sdk-go-v2/aws"
+ "github.com/aws/aws-sdk-go-v2/service/s3"
+ "github.com/aws/aws-sdk-go-v2/service/s3/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -31,10 +32,10 @@ import (
)
func listOutput(truncated bool, keys ...string) *s3.ListObjectsV2Output {
- contents := make([]*s3.Object, 0, len(keys))
+ contents := make([]types.Object, 0, len(keys))
for _, k := range keys {
key := k
- contents = append(contents, &s3.Object{Key: &key})
+ contents = append(contents, types.Object{Key: &key})
}
return &s3.ListObjectsV2Output{
Contents: contents,
@@ -88,7 +89,7 @@ func TestCollectCandidates_FileFiltering(t *testing.T) {
t.Run("nil key is skipped", func(t *testing.T) {
output := &s3.ListObjectsV2Output{
- Contents: []*s3.Object{{Key: nil}, {Key:
aws.String("p/a.csv")}},
+ Contents: []types.Object{{Key: nil}, {Key:
aws.String("p/a.csv")}},
IsTruncated: aws.Bool(false),
}
candidates := collectCandidates(output, "bkt", spec, options)