aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn
diff options
context:
space:
mode:
authorvitalyisaev <vitalyisaev@ydb.tech>2023-12-12 21:55:07 +0300
committervitalyisaev <vitalyisaev@ydb.tech>2023-12-12 22:25:10 +0300
commit4967f99474a4040ba150eb04995de06342252718 (patch)
treec9c118836513a8fab6e9fcfb25be5d404338bca7 /vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn
parent2ce9cccb9b0bdd4cd7a3491dc5cbf8687cda51de (diff)
downloadydb-4967f99474a4040ba150eb04995de06342252718.tar.gz
YQ Connector: prepare code base for S3 integration
1. Кодовая база Коннектора переписана с помощью Go дженериков так, чтобы добавление нового источника данных (в частности S3 + csv) максимально переиспользовало имеющийся код (чтобы сохранялась логика нарезания на блоки данных, учёт трафика и пр.) 2. API Connector расширено для работы с S3, но ещё пока не протестировано.
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn')
-rw-r--r--vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/accesspoint_arn.go53
-rw-r--r--vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/accesspoint_arn_test.go118
-rw-r--r--vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/arn.go85
-rw-r--r--vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/arn_member.go32
-rw-r--r--vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/arn_test.go170
-rw-r--r--vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/gotest/ya.make5
-rw-r--r--vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/outpost_arn.go128
-rw-r--r--vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/outpost_arn_test.go291
-rw-r--r--vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/s3_object_lambda_arn.go15
-rw-r--r--vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/ya.make23
10 files changed, 920 insertions, 0 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/accesspoint_arn.go b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/accesspoint_arn.go
new file mode 100644
index 0000000000..ec290b2135
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/accesspoint_arn.go
@@ -0,0 +1,53 @@
+package arn
+
+import (
+ "strings"
+
+ "github.com/aws/aws-sdk-go-v2/aws/arn"
+)
+
+// AccessPointARN provides representation
+type AccessPointARN struct {
+ arn.ARN
+ AccessPointName string
+}
+
+// GetARN returns the base ARN for the Access Point resource
+func (a AccessPointARN) GetARN() arn.ARN {
+ return a.ARN
+}
+
+// ParseAccessPointResource attempts to parse the ARN's resource as an
+// AccessPoint resource.
+//
+// Supported Access point resource format:
+// - Access point format: arn:{partition}:s3:{region}:{accountId}:accesspoint/{accesspointName}
+// - example: arn:aws:s3:us-west-2:012345678901:accesspoint/myaccesspoint
+func ParseAccessPointResource(a arn.ARN, resParts []string) (AccessPointARN, error) {
+ if isFIPS(a.Region) {
+ return AccessPointARN{}, InvalidARNError{ARN: a, Reason: "FIPS region not allowed in ARN"}
+ }
+ if len(a.AccountID) == 0 {
+ return AccessPointARN{}, InvalidARNError{ARN: a, Reason: "account-id not set"}
+ }
+ if len(resParts) == 0 {
+ return AccessPointARN{}, InvalidARNError{ARN: a, Reason: "resource-id not set"}
+ }
+ if len(resParts) > 1 {
+ return AccessPointARN{}, InvalidARNError{ARN: a, Reason: "sub resource not supported"}
+ }
+
+ resID := resParts[0]
+ if len(strings.TrimSpace(resID)) == 0 {
+ return AccessPointARN{}, InvalidARNError{ARN: a, Reason: "resource-id not set"}
+ }
+
+ return AccessPointARN{
+ ARN: a,
+ AccessPointName: resID,
+ }, nil
+}
+
+func isFIPS(region string) bool {
+ return strings.HasPrefix(region, "fips-") || strings.HasSuffix(region, "-fips")
+}
diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/accesspoint_arn_test.go b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/accesspoint_arn_test.go
new file mode 100644
index 0000000000..51221b20f3
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/accesspoint_arn_test.go
@@ -0,0 +1,118 @@
+package arn
+
+import (
+ "reflect"
+ "strings"
+ "testing"
+
+ "github.com/aws/aws-sdk-go-v2/aws/arn"
+)
+
+func TestParseAccessPointResource(t *testing.T) {
+ cases := map[string]struct {
+ ARN arn.ARN
+ ExpectErr string
+ ExpectARN AccessPointARN
+ }{
+ "account-id not set": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3",
+ Region: "us-west-2",
+ Resource: "accesspoint/myendpoint",
+ },
+ ExpectErr: "account-id not set",
+ },
+ "resource-id not set": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "accesspoint",
+ },
+ ExpectErr: "resource-id not set",
+ },
+ "resource-id empty": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "accesspoint:",
+ },
+ ExpectErr: "resource-id not set",
+ },
+ "resource not supported": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "accesspoint/endpoint/object/key",
+ },
+ ExpectErr: "sub resource not supported",
+ },
+ "valid resource-id": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "accesspoint/endpoint",
+ },
+ ExpectARN: AccessPointARN{
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "accesspoint/endpoint",
+ },
+ AccessPointName: "endpoint",
+ },
+ },
+ "invalid FIPS pseudo region in ARN (prefix)": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3",
+ Region: "fips-us-west-2",
+ AccountID: "012345678901",
+ Resource: "accesspoint/endpoint",
+ },
+ ExpectErr: "FIPS region not allowed in ARN",
+ },
+ "invalid FIPS pseudo region in ARN (suffix)": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3",
+ Region: "us-west-2-fips",
+ AccountID: "012345678901",
+ Resource: "accesspoint/endpoint",
+ },
+ ExpectErr: "FIPS region not allowed in ARN",
+ },
+ }
+
+ for name, c := range cases {
+ t.Run(name, func(t *testing.T) {
+ resParts := SplitResource(c.ARN.Resource)
+ a, err := ParseAccessPointResource(c.ARN, resParts[1:])
+
+ if len(c.ExpectErr) == 0 && err != nil {
+ t.Fatalf("expect no error but got %v", err)
+ } else if len(c.ExpectErr) != 0 && err == nil {
+ t.Fatalf("expect error %q, but got nil", c.ExpectErr)
+ } else if len(c.ExpectErr) != 0 && err != nil {
+ if e, a := c.ExpectErr, err.Error(); !strings.Contains(a, e) {
+ t.Fatalf("expect error %q, got %q", e, a)
+ }
+ return
+ }
+
+ if e, a := c.ExpectARN, a; !reflect.DeepEqual(e, a) {
+ t.Errorf("expect %v, got %v", e, a)
+ }
+ })
+ }
+}
diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/arn.go b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/arn.go
new file mode 100644
index 0000000000..06e1a3addd
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/arn.go
@@ -0,0 +1,85 @@
+package arn
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/aws/aws-sdk-go-v2/aws/arn"
+)
+
+var supportedServiceARN = []string{
+ "s3",
+ "s3-outposts",
+ "s3-object-lambda",
+}
+
+func isSupportedServiceARN(service string) bool {
+ for _, name := range supportedServiceARN {
+ if name == service {
+ return true
+ }
+ }
+ return false
+}
+
+// Resource provides the interfaces abstracting ARNs of specific resource
+// types.
+type Resource interface {
+ GetARN() arn.ARN
+ String() string
+}
+
+// ResourceParser provides the function for parsing an ARN's resource
+// component into a typed resource.
+type ResourceParser func(arn.ARN) (Resource, error)
+
+// ParseResource parses an AWS ARN into a typed resource for the S3 API.
+func ParseResource(a arn.ARN, resParser ResourceParser) (resARN Resource, err error) {
+ if len(a.Partition) == 0 {
+ return nil, InvalidARNError{ARN: a, Reason: "partition not set"}
+ }
+
+ if !isSupportedServiceARN(a.Service) {
+ return nil, InvalidARNError{ARN: a, Reason: "service is not supported"}
+ }
+
+ if len(a.Resource) == 0 {
+ return nil, InvalidARNError{ARN: a, Reason: "resource not set"}
+ }
+
+ return resParser(a)
+}
+
+// SplitResource splits the resource components by the ARN resource delimiters.
+func SplitResource(v string) []string {
+ var parts []string
+ var offset int
+
+ for offset <= len(v) {
+ idx := strings.IndexAny(v[offset:], "/:")
+ if idx < 0 {
+ parts = append(parts, v[offset:])
+ break
+ }
+ parts = append(parts, v[offset:idx+offset])
+ offset += idx + 1
+ }
+
+ return parts
+}
+
+// IsARN returns whether the given string is an ARN
+func IsARN(s string) bool {
+ return arn.IsARN(s)
+}
+
+// InvalidARNError provides the error for an invalid ARN error.
+type InvalidARNError struct {
+ ARN arn.ARN
+ Reason string
+}
+
+// Error returns a string denoting the occurred InvalidARNError
+func (e InvalidARNError) Error() string {
+ return fmt.Sprintf("invalid Amazon %s ARN, %s, %s", e.ARN.Service, e.Reason, e.ARN.String())
+}
diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/arn_member.go b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/arn_member.go
new file mode 100644
index 0000000000..9a3258e15a
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/arn_member.go
@@ -0,0 +1,32 @@
+package arn
+
+import "fmt"
+
+// arnable is implemented by the relevant S3/S3Control
+// operations which have members that may need ARN
+// processing.
+type arnable interface {
+ SetARNMember(string) error
+ GetARNMember() (*string, bool)
+}
+
+// GetARNField would be called during middleware execution
+// to retrieve a member value that is an ARN in need of
+// processing.
+func GetARNField(input interface{}) (*string, bool) {
+ v, ok := input.(arnable)
+ if !ok {
+ return nil, false
+ }
+ return v.GetARNMember()
+}
+
+// SetARNField would called during middleware exeuction
+// to set a member value that required ARN processing.
+func SetARNField(input interface{}, v string) error {
+ params, ok := input.(arnable)
+ if !ok {
+ return fmt.Errorf("Params does not contain arn field member")
+ }
+ return params.SetARNMember(v)
+}
diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/arn_test.go b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/arn_test.go
new file mode 100644
index 0000000000..db7beaaf8f
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/arn_test.go
@@ -0,0 +1,170 @@
+package arn
+
+import (
+ "reflect"
+ "strings"
+ "testing"
+
+ "github.com/aws/aws-sdk-go-v2/aws/arn"
+)
+
+func TestParseResource(t *testing.T) {
+ cases := map[string]struct {
+ Input string
+ MappedResources map[string]func(arn.ARN, []string) (Resource, error)
+ Expect Resource
+ ExpectErr string
+ }{
+ "Empty ARN": {
+ Input: "",
+ ExpectErr: "arn: invalid prefix",
+ },
+ "No Partition": {
+ Input: "arn::sqs:us-west-2:012345678901:accesspoint",
+ ExpectErr: "partition not set",
+ },
+ "Not S3 ARN": {
+ Input: "arn:aws:sqs:us-west-2:012345678901:accesspoint",
+ ExpectErr: "service is not supported",
+ },
+ "No Resource": {
+ Input: "arn:aws:s3:us-west-2:012345678901:",
+ ExpectErr: "resource not set",
+ },
+ "Unknown Resource Type": {
+ Input: "arn:aws:s3:us-west-2:012345678901:myresource",
+ ExpectErr: "unknown resource type",
+ },
+ "Unknown BucketARN Resource Type": {
+ Input: "arn:aws:s3:us-west-2:012345678901:bucket_name:mybucket",
+ ExpectErr: "unknown resource type",
+ },
+ "Unknown Resource Type with Resource and Sub-Resource": {
+ Input: "arn:aws:s3:us-west-2:012345678901:somethingnew:myresource/subresource",
+ ExpectErr: "unknown resource type",
+ },
+ "Access Point with sub resource": {
+ Input: "arn:aws:s3:us-west-2:012345678901:accesspoint:myresource/subresource",
+ MappedResources: map[string]func(arn.ARN, []string) (Resource, error){
+ "accesspoint": func(a arn.ARN, parts []string) (Resource, error) {
+ return ParseAccessPointResource(a, parts)
+ },
+ },
+ ExpectErr: "resource not supported",
+ },
+ "AccessPoint Resource Type": {
+ Input: "arn:aws:s3:us-west-2:012345678901:accesspoint:myendpoint",
+ MappedResources: map[string]func(arn.ARN, []string) (Resource, error){
+ "accesspoint": func(a arn.ARN, parts []string) (Resource, error) {
+ return ParseAccessPointResource(a, parts)
+ },
+ },
+ Expect: AccessPointARN{
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "accesspoint:myendpoint",
+ },
+ AccessPointName: "myendpoint",
+ },
+ },
+ "AccessPoint Resource Type With Path Syntax": {
+ Input: "arn:aws:s3:us-west-2:012345678901:accesspoint/myendpoint",
+ MappedResources: map[string]func(arn.ARN, []string) (Resource, error){
+ "accesspoint": func(a arn.ARN, parts []string) (Resource, error) {
+ return ParseAccessPointResource(a, parts)
+ },
+ },
+ Expect: AccessPointARN{
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "accesspoint/myendpoint",
+ },
+ AccessPointName: "myendpoint",
+ },
+ },
+ }
+
+ for name, c := range cases {
+ t.Run(name, func(t *testing.T) {
+ var parsed Resource
+ arn, err := arn.Parse(c.Input)
+ if err == nil {
+ parsed, err = ParseResource(arn, mappedResourceParser(c.MappedResources))
+ }
+
+ if len(c.ExpectErr) == 0 && err != nil {
+ t.Fatalf("expect no error but got %v", err)
+ } else if len(c.ExpectErr) != 0 && err == nil {
+ t.Fatalf("expect error but got nil")
+ } else if len(c.ExpectErr) != 0 && err != nil {
+ if e, a := c.ExpectErr, err.Error(); !strings.Contains(a, e) {
+ t.Fatalf("expect error %q, got %q", e, a)
+ }
+ return
+ }
+
+ if e, a := c.Expect, parsed; !reflect.DeepEqual(e, a) {
+ t.Errorf("Expect %v, got %v", e, a)
+ }
+ })
+ }
+}
+
+func mappedResourceParser(kinds map[string]func(arn.ARN, []string) (Resource, error)) ResourceParser {
+ return func(a arn.ARN) (Resource, error) {
+ parts := SplitResource(a.Resource)
+
+ fn, ok := kinds[parts[0]]
+ if !ok {
+ return nil, InvalidARNError{ARN: a, Reason: "unknown resource type"}
+ }
+ return fn(a, parts[1:])
+ }
+}
+
+func TestSplitResource(t *testing.T) {
+ cases := []struct {
+ Input string
+ Expect []string
+ }{
+ {
+ Input: "accesspoint:myendpoint",
+ Expect: []string{"accesspoint", "myendpoint"},
+ },
+ {
+ Input: "accesspoint/myendpoint",
+ Expect: []string{"accesspoint", "myendpoint"},
+ },
+ {
+ Input: "accesspoint",
+ Expect: []string{"accesspoint"},
+ },
+ {
+ Input: "accesspoint:",
+ Expect: []string{"accesspoint", ""},
+ },
+ {
+ Input: "accesspoint: ",
+ Expect: []string{"accesspoint", " "},
+ },
+ {
+ Input: "accesspoint:endpoint/object/key",
+ Expect: []string{"accesspoint", "endpoint", "object", "key"},
+ },
+ }
+
+ for _, c := range cases {
+ t.Run(c.Input, func(t *testing.T) {
+ parts := SplitResource(c.Input)
+ if e, a := c.Expect, parts; !reflect.DeepEqual(e, a) {
+ t.Errorf("expect %v, got %v", e, a)
+ }
+ })
+ }
+}
diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/gotest/ya.make b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/gotest/ya.make
new file mode 100644
index 0000000000..0db9a0c5c8
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/gotest/ya.make
@@ -0,0 +1,5 @@
+GO_TEST_FOR(vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn)
+
+LICENSE(Apache-2.0)
+
+END()
diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/outpost_arn.go b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/outpost_arn.go
new file mode 100644
index 0000000000..e06a302857
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/outpost_arn.go
@@ -0,0 +1,128 @@
+package arn
+
+import (
+ "strings"
+
+ "github.com/aws/aws-sdk-go-v2/aws/arn"
+)
+
+// OutpostARN interface that should be satisfied by outpost ARNs
+type OutpostARN interface {
+ Resource
+ GetOutpostID() string
+}
+
+// ParseOutpostARNResource will parse a provided ARNs resource using the appropriate ARN format
+// and return a specific OutpostARN type
+//
+// Currently supported outpost ARN formats:
+// * Outpost AccessPoint ARN format:
+// - ARN format: arn:{partition}:s3-outposts:{region}:{accountId}:outpost/{outpostId}/accesspoint/{accesspointName}
+// - example: arn:aws:s3-outposts:us-west-2:012345678901:outpost/op-1234567890123456/accesspoint/myaccesspoint
+//
+// * Outpost Bucket ARN format:
+// - ARN format: arn:{partition}:s3-outposts:{region}:{accountId}:outpost/{outpostId}/bucket/{bucketName}
+// - example: arn:aws:s3-outposts:us-west-2:012345678901:outpost/op-1234567890123456/bucket/mybucket
+//
+// Other outpost ARN formats may be supported and added in the future.
+func ParseOutpostARNResource(a arn.ARN, resParts []string) (OutpostARN, error) {
+ if len(a.Region) == 0 {
+ return nil, InvalidARNError{ARN: a, Reason: "region not set"}
+ }
+
+ if isFIPS(a.Region) {
+ return nil, InvalidARNError{ARN: a, Reason: "FIPS region not allowed in ARN"}
+ }
+
+ if len(a.AccountID) == 0 {
+ return nil, InvalidARNError{ARN: a, Reason: "account-id not set"}
+ }
+
+ // verify if outpost id is present and valid
+ if len(resParts) == 0 || len(strings.TrimSpace(resParts[0])) == 0 {
+ return nil, InvalidARNError{ARN: a, Reason: "outpost resource-id not set"}
+ }
+
+ // verify possible resource type exists
+ if len(resParts) < 3 {
+ return nil, InvalidARNError{
+ ARN: a, Reason: "incomplete outpost resource type. Expected bucket or access-point resource to be present",
+ }
+ }
+
+ // Since we know this is a OutpostARN fetch outpostID
+ outpostID := strings.TrimSpace(resParts[0])
+
+ switch resParts[1] {
+ case "accesspoint":
+ accesspointARN, err := ParseAccessPointResource(a, resParts[2:])
+ if err != nil {
+ return OutpostAccessPointARN{}, err
+ }
+ return OutpostAccessPointARN{
+ AccessPointARN: accesspointARN,
+ OutpostID: outpostID,
+ }, nil
+
+ case "bucket":
+ bucketName, err := parseBucketResource(a, resParts[2:])
+ if err != nil {
+ return nil, err
+ }
+ return OutpostBucketARN{
+ ARN: a,
+ BucketName: bucketName,
+ OutpostID: outpostID,
+ }, nil
+
+ default:
+ return nil, InvalidARNError{ARN: a, Reason: "unknown resource set for outpost ARN"}
+ }
+}
+
+// OutpostAccessPointARN represents outpost access point ARN.
+type OutpostAccessPointARN struct {
+ AccessPointARN
+ OutpostID string
+}
+
+// GetOutpostID returns the outpost id of outpost access point arn
+func (o OutpostAccessPointARN) GetOutpostID() string {
+ return o.OutpostID
+}
+
+// OutpostBucketARN represents the outpost bucket ARN.
+type OutpostBucketARN struct {
+ arn.ARN
+ BucketName string
+ OutpostID string
+}
+
+// GetOutpostID returns the outpost id of outpost bucket arn
+func (o OutpostBucketARN) GetOutpostID() string {
+ return o.OutpostID
+}
+
+// GetARN retrives the base ARN from outpost bucket ARN resource
+func (o OutpostBucketARN) GetARN() arn.ARN {
+ return o.ARN
+}
+
+// parseBucketResource attempts to parse the ARN's bucket resource and retrieve the
+// bucket resource id.
+//
+// parseBucketResource only parses the bucket resource id.
+func parseBucketResource(a arn.ARN, resParts []string) (bucketName string, err error) {
+ if len(resParts) == 0 {
+ return bucketName, InvalidARNError{ARN: a, Reason: "bucket resource-id not set"}
+ }
+ if len(resParts) > 1 {
+ return bucketName, InvalidARNError{ARN: a, Reason: "sub resource not supported"}
+ }
+
+ bucketName = strings.TrimSpace(resParts[0])
+ if len(bucketName) == 0 {
+ return bucketName, InvalidARNError{ARN: a, Reason: "bucket resource-id not set"}
+ }
+ return bucketName, err
+}
diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/outpost_arn_test.go b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/outpost_arn_test.go
new file mode 100644
index 0000000000..b21d4bd5d7
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/outpost_arn_test.go
@@ -0,0 +1,291 @@
+package arn
+
+import (
+ "reflect"
+ "strings"
+ "testing"
+
+ "github.com/aws/aws-sdk-go-v2/aws/arn"
+)
+
+func TestParseOutpostAccessPointARNResource(t *testing.T) {
+ cases := map[string]struct {
+ ARN arn.ARN
+ ExpectErr string
+ ExpectARN OutpostAccessPointARN
+ }{
+ "region not set": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ AccountID: "012345678901",
+ Resource: "outpost/myoutpost/accesspoint/myendpoint",
+ },
+ ExpectErr: "region not set",
+ },
+ "account-id not set": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ Region: "us-west-2",
+ Resource: "outpost/myoutpost/accesspoint/myendpoint",
+ },
+ ExpectErr: "account-id not set",
+ },
+ "resource-id not set": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "myoutpost",
+ },
+ ExpectErr: "resource-id not set",
+ },
+ "resource-id empty": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "outpost:",
+ },
+ ExpectErr: "resource-id not set",
+ },
+ "resource not supported": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "outpost/myoutpost/accesspoint/endpoint/object/key",
+ },
+ ExpectErr: "sub resource not supported",
+ },
+ "access-point not defined": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "outpost/myoutpost/endpoint/object/key",
+ },
+ ExpectErr: "unknown resource set for outpost ARN",
+ },
+ "valid resource-id": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "outpost/myoutpost/accesspoint/myaccesspoint",
+ },
+ ExpectARN: OutpostAccessPointARN{
+ AccessPointARN: AccessPointARN{
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "outpost/myoutpost/accesspoint/myaccesspoint",
+ },
+ AccessPointName: "myaccesspoint",
+ },
+ OutpostID: "myoutpost",
+ },
+ },
+ "invalid FIPS pseudo region in ARN (prefix)": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ Region: "fips-us-west-2",
+ AccountID: "012345678901",
+ Resource: "outpost/myoutpost/accesspoint/myendpoint",
+ },
+ ExpectErr: "FIPS region not allowed in ARN",
+ },
+ "invalid FIPS pseudo region in ARN (suffix)": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ Region: "us-west-2-fips",
+ AccountID: "012345678901",
+ Resource: "outpost/myoutpost/accesspoint/myendpoint",
+ },
+ ExpectErr: "FIPS region not allowed in ARN",
+ },
+ }
+
+ for name, c := range cases {
+ t.Run(name, func(t *testing.T) {
+ resParts := SplitResource(c.ARN.Resource)
+ a, err := ParseOutpostARNResource(c.ARN, resParts[1:])
+
+ if len(c.ExpectErr) == 0 && err != nil {
+ t.Fatalf("expect no error but got %v", err)
+ } else if len(c.ExpectErr) != 0 && err == nil {
+ t.Fatalf("expect error %q, but got nil", c.ExpectErr)
+ } else if len(c.ExpectErr) != 0 && err != nil {
+ if e, a := c.ExpectErr, err.Error(); !strings.Contains(a, e) {
+ t.Fatalf("expect error %q, got %q", e, a)
+ }
+ return
+ }
+
+ if e, a := c.ExpectARN, a; !reflect.DeepEqual(e, a) {
+ t.Errorf("expect %v, got %v", e, a)
+ }
+ })
+ }
+}
+
+func TestParseOutpostBucketARNResource(t *testing.T) {
+ cases := map[string]struct {
+ ARN arn.ARN
+ ExpectErr string
+ ExpectARN OutpostBucketARN
+ }{
+ "region not set": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ AccountID: "012345678901",
+ Resource: "outpost/myoutpost/bucket/mybucket",
+ },
+ ExpectErr: "region not set",
+ },
+ "resource-id empty": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "outpost:",
+ },
+ ExpectErr: "resource-id not set",
+ },
+ "resource not supported": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "outpost/myoutpost/bucket/mybucket/object/key",
+ },
+ ExpectErr: "sub resource not supported",
+ },
+ "bucket not defined": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "outpost/myoutpost/endpoint/object/key",
+ },
+ ExpectErr: "unknown resource set for outpost ARN",
+ },
+ "valid resource-id": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "outpost/myoutpost/bucket/mybucket",
+ },
+ ExpectARN: OutpostBucketARN{
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3-outposts",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "outpost/myoutpost/bucket/mybucket",
+ },
+ BucketName: "mybucket",
+ OutpostID: "myoutpost",
+ },
+ },
+ }
+
+ for name, c := range cases {
+ t.Run(name, func(t *testing.T) {
+ resParts := SplitResource(c.ARN.Resource)
+ a, err := ParseOutpostARNResource(c.ARN, resParts[1:])
+
+ if len(c.ExpectErr) == 0 && err != nil {
+ t.Fatalf("expect no error but got %v", err)
+ } else if len(c.ExpectErr) != 0 && err == nil {
+ t.Fatalf("expect error %q, but got nil", c.ExpectErr)
+ } else if len(c.ExpectErr) != 0 && err != nil {
+ if e, a := c.ExpectErr, err.Error(); !strings.Contains(a, e) {
+ t.Fatalf("expect error %q, got %q", e, a)
+ }
+ return
+ }
+
+ if e, a := c.ExpectARN, a; !reflect.DeepEqual(e, a) {
+ t.Errorf("expect %v, got %v", e, a)
+ }
+ })
+ }
+}
+
+func TestParseBucketResource(t *testing.T) {
+ cases := map[string]struct {
+ ARN arn.ARN
+ ExpectErr string
+ ExpectBucketName string
+ }{
+ "resource-id empty": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "bucket:",
+ },
+ ExpectErr: "bucket resource-id not set",
+ },
+ "resource not supported": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "bucket/mybucket/object/key",
+ },
+ ExpectErr: "sub resource not supported",
+ },
+ "valid resource-id": {
+ ARN: arn.ARN{
+ Partition: "aws",
+ Service: "s3",
+ Region: "us-west-2",
+ AccountID: "012345678901",
+ Resource: "bucket/mybucket",
+ },
+ ExpectBucketName: "mybucket",
+ },
+ }
+
+ for name, c := range cases {
+ t.Run(name, func(t *testing.T) {
+ resParts := SplitResource(c.ARN.Resource)
+ a, err := parseBucketResource(c.ARN, resParts[1:])
+
+ if len(c.ExpectErr) == 0 && err != nil {
+ t.Fatalf("expect no error but got %v", err)
+ } else if len(c.ExpectErr) != 0 && err == nil {
+ t.Fatalf("expect error %q, but got nil", c.ExpectErr)
+ } else if len(c.ExpectErr) != 0 && err != nil {
+ if e, a := c.ExpectErr, err.Error(); !strings.Contains(a, e) {
+ t.Fatalf("expect error %q, got %q", e, a)
+ }
+ return
+ }
+
+ if e, a := c.ExpectBucketName, a; !reflect.DeepEqual(e, a) {
+ t.Errorf("expect %v, got %v", e, a)
+ }
+ })
+ }
+}
diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/s3_object_lambda_arn.go b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/s3_object_lambda_arn.go
new file mode 100644
index 0000000000..513154cc0e
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/s3_object_lambda_arn.go
@@ -0,0 +1,15 @@
+package arn
+
+// S3ObjectLambdaARN represents an ARN for the s3-object-lambda service
+type S3ObjectLambdaARN interface {
+ Resource
+
+ isS3ObjectLambdasARN()
+}
+
+// S3ObjectLambdaAccessPointARN is an S3ObjectLambdaARN for the Access Point resource type
+type S3ObjectLambdaAccessPointARN struct {
+ AccessPointARN
+}
+
+func (s S3ObjectLambdaAccessPointARN) isS3ObjectLambdasARN() {}
diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/ya.make b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/ya.make
new file mode 100644
index 0000000000..5e1a74cbc2
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn/ya.make
@@ -0,0 +1,23 @@
+GO_LIBRARY()
+
+LICENSE(Apache-2.0)
+
+SRCS(
+ accesspoint_arn.go
+ arn.go
+ arn_member.go
+ outpost_arn.go
+ s3_object_lambda_arn.go
+)
+
+GO_TEST_SRCS(
+ accesspoint_arn_test.go
+ arn_test.go
+ outpost_arn_test.go
+)
+
+END()
+
+RECURSE(
+ gotest
+)