From f22dc6c17d627c4739d206bb6a0392466c7e5c83 Mon Sep 17 00:00:00 2001 From: tom twinkle Date: Tue, 21 Nov 2023 11:45:35 +0900 Subject: [PATCH] update s3 config --- aws/awss3/awss3.go | 2 +- aws/awss3/awss3_test.go | 12 ++++++------ aws/awss3/options/global/global_test.go | 2 +- aws/awss3/options/s3selectcsv/s3_select_csv.go | 5 +++-- aws/awssqs/client.go | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/aws/awss3/awss3.go b/aws/awss3/awss3.go index de67187..c64e279 100644 --- a/aws/awss3/awss3.go +++ b/aws/awss3/awss3.go @@ -562,7 +562,7 @@ func SelectCSVAll(ctx context.Context, region awsconfig.Region, bucketName Bucke }, }, } - if c.SkipByteSize > 0 { + if c.SkipByteSize != nil { req.ScanRange = &types.ScanRange{Start: c.SkipByteSize} } resp, err := client.SelectObjectContent(ctx, req) diff --git a/aws/awss3/awss3_test.go b/aws/awss3/awss3_test.go index cc02346..1069197 100644 --- a/aws/awss3/awss3_test.go +++ b/aws/awss3/awss3_test.go @@ -67,7 +67,7 @@ func TestHeadObject(t *testing.T) { key := createFixture(100) res, err := awss3.HeadObject(ctx, TestRegion, TestBucket, key) assert.NoError(t, err) - assert.Equal(t, int64(100), res.ContentLength) + assert.Equal(t, aws.Int64(100), res.ContentLength) }) t.Run("not exists object", func(t *testing.T) { t.Parallel() @@ -83,7 +83,7 @@ func TestHeadObject(t *testing.T) { s3head.WithTimeout(5*time.Second), ) assert.NoError(t, err) - assert.Equal(t, int64(100), res.ContentLength) + assert.Equal(t, aws.Int64(100), res.ContentLength) }) t.Run("not exists object use Waiter", func(t *testing.T) { t.Parallel() @@ -781,7 +781,7 @@ func TestSelectCSVAll(t *testing.T) { key := createFixture(ctx, src) var buf bytes.Buffer err := awss3.SelectCSVAll(ctx, TestRegion, TestBucket, key, awss3.SelectCSVAllQuery, &buf, - s3selectcsv.WithCSVInput(types.CSVInput{AllowQuotedRecordDelimiter: true}), + s3selectcsv.WithCSVInput(types.CSVInput{AllowQuotedRecordDelimiter: aws.Bool(true)}), ) if !assert.NoError(t, err) { return @@ -803,7 +803,7 @@ func TestSelectCSVAll(t *testing.T) { key := createFixture(ctx, src) var buf bytes.Buffer err := awss3.SelectCSVAll(ctx, TestRegion, TestBucket, key, awss3.SelectCSVAllQuery, &buf, - s3selectcsv.WithCSVInput(types.CSVInput{AllowQuotedRecordDelimiter: true}), + s3selectcsv.WithCSVInput(types.CSVInput{AllowQuotedRecordDelimiter: aws.Bool(true)}), ) if !assert.NoError(t, err) { return @@ -825,7 +825,7 @@ func TestSelectCSVAll(t *testing.T) { key := createFixture(ctx, src) var buf bytes.Buffer err := awss3.SelectCSVAll(ctx, TestRegion, TestBucket, key, awss3.SelectCSVAllQuery, &buf, - s3selectcsv.WithCSVInput(types.CSVInput{AllowQuotedRecordDelimiter: true}), + s3selectcsv.WithCSVInput(types.CSVInput{AllowQuotedRecordDelimiter: aws.Bool(true)}), ) if !assert.NoError(t, err) { return @@ -847,7 +847,7 @@ func TestSelectCSVAll(t *testing.T) { key := createFixture(ctx, src) var buf bytes.Buffer err := awss3.SelectCSVAll(ctx, TestRegion, TestBucket, key, awss3.SelectCSVAllQuery, &buf, - s3selectcsv.WithCSVInput(types.CSVInput{AllowQuotedRecordDelimiter: true}), + s3selectcsv.WithCSVInput(types.CSVInput{AllowQuotedRecordDelimiter: aws.Bool(true)}), ) if !assert.NoError(t, err) { diff --git a/aws/awss3/options/global/global_test.go b/aws/awss3/options/global/global_test.go index 5ba9a7b..c6387aa 100644 --- a/aws/awss3/options/global/global_test.go +++ b/aws/awss3/options/global/global_test.go @@ -58,6 +58,6 @@ func TestGlobalOptionWithHeadObject(t *testing.T) { awss3.GlobalDialer = dialer res, err := awss3.HeadObject(ctx, TestRegion, TestBucket, key) assert.NoError(t, err) - assert.Equal(t, int64(100), res.ContentLength) + assert.Equal(t, aws.Int64(100), res.ContentLength) }) } diff --git a/aws/awss3/options/s3selectcsv/s3_select_csv.go b/aws/awss3/options/s3selectcsv/s3_select_csv.go index 2012240..6cc97d8 100644 --- a/aws/awss3/options/s3selectcsv/s3_select_csv.go +++ b/aws/awss3/options/s3selectcsv/s3_select_csv.go @@ -7,7 +7,7 @@ type OptionS3SelectCSV interface { } type confS3SelectCSV struct { - SkipByteSize int64 + SkipByteSize *int64 CSVInput types.CSVInput CompressionType types.CompressionType CSVOutput types.CSVOutput @@ -28,7 +28,8 @@ func GetS3SelectCSVConf(opts ...OptionS3SelectCSV) confS3SelectCSV { type OptionSkipByteSize int64 func (o OptionSkipByteSize) Apply(c *confS3SelectCSV) { - c.SkipByteSize = int64(o) + v := int64(o) + c.SkipByteSize = &v } // WithSkipByteSize diff --git a/aws/awssqs/client.go b/aws/awssqs/client.go index 943b2e2..4506054 100644 --- a/aws/awssqs/client.go +++ b/aws/awssqs/client.go @@ -20,7 +20,7 @@ func GetClient(ctx context.Context, region awsconfig.Region) (*sqs.Client, error if localProfile, ok := getLocalEndpoint(ctx); ok { return getClientLocal(ctx, *localProfile) } - // S3 Client + // SQS Client awsCfg, err := awsConfig.LoadDefaultConfig(ctx, awsConfig.WithRegion(region.String())) if err != nil { return nil, fmt.Errorf("unable to load SDK config, %w", err)