mirror of
https://github.com/nabbar/golib.git
synced 2025-09-26 20:01:15 +08:00
Package AWS:
- bump dependencies aws sdk go v2 with checksum calulation when supported by default - add function in config interface to allow changing checksum calculation - set checksum calculation as 'when required' with custom config - set checksum calcultation as 'when supported' with aws config Other: - bump dependencies
This commit is contained in:
@@ -49,6 +49,10 @@ func NewConfigJsonUnmashal(p []byte) (libaws.Config, error) {
|
||||
return &awsModel{
|
||||
Model: c,
|
||||
retryer: nil,
|
||||
checksum: checksumOptions{
|
||||
Request: sdkaws.RequestChecksumCalculationWhenSupported,
|
||||
Response: sdkaws.ResponseChecksumValidationWhenSupported,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -61,6 +65,10 @@ func NewConfigStatusJsonUnmashal(p []byte) (libaws.Config, error) {
|
||||
return &awsModel{
|
||||
Model: c.Config,
|
||||
retryer: nil,
|
||||
checksum: checksumOptions{
|
||||
Request: sdkaws.RequestChecksumCalculationWhenSupported,
|
||||
Response: sdkaws.ResponseChecksumValidationWhenSupported,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -73,6 +81,10 @@ func NewConfig(bucket, accessKey, secretKey, region string) libaws.Config {
|
||||
Bucket: bucket,
|
||||
},
|
||||
retryer: nil,
|
||||
checksum: checksumOptions{
|
||||
Request: sdkaws.RequestChecksumCalculationWhenSupported,
|
||||
Response: sdkaws.ResponseChecksumValidationWhenSupported,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +97,10 @@ func (c *awsModel) Clone() libaws.Config {
|
||||
Bucket: c.Bucket,
|
||||
},
|
||||
retryer: c.retryer,
|
||||
checksum: checksumOptions{
|
||||
Request: c.checksum.Request,
|
||||
Response: c.checksum.Response,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +127,18 @@ func (c *awsModel) GetConfig(ctx context.Context, cli libhtc.HttpClient) (*sdkaw
|
||||
cfg.HTTPClient = cli
|
||||
}
|
||||
|
||||
if c.checksum.Request != sdkaws.RequestChecksumCalculationWhenRequired {
|
||||
cfg.RequestChecksumCalculation = sdkaws.RequestChecksumCalculationWhenSupported
|
||||
} else {
|
||||
cfg.RequestChecksumCalculation = sdkaws.RequestChecksumCalculationWhenRequired
|
||||
}
|
||||
|
||||
if c.checksum.Response != sdkaws.ResponseChecksumValidationWhenRequired {
|
||||
cfg.ResponseChecksumValidation = sdkaws.ResponseChecksumValidationWhenSupported
|
||||
} else {
|
||||
cfg.ResponseChecksumValidation = sdkaws.ResponseChecksumValidationWhenRequired
|
||||
}
|
||||
|
||||
return &cfg, nil
|
||||
}
|
||||
|
||||
@@ -125,3 +153,10 @@ func (c *awsModel) SetBucketName(bucket string) {
|
||||
func (c *awsModel) JSON() ([]byte, error) {
|
||||
return json.MarshalIndent(c, "", " ")
|
||||
}
|
||||
|
||||
func (c *awsModel) SetChecksumValidation(req sdkaws.RequestChecksumCalculation, rsp sdkaws.ResponseChecksumValidation) {
|
||||
c.checksum = checksumOptions{
|
||||
Request: req,
|
||||
Response: rsp,
|
||||
}
|
||||
}
|
||||
|
@@ -50,9 +50,15 @@ type ModelStatus struct {
|
||||
Monitor libreq.OptionsHealth `json:"health" yaml:"health" toml:"health" mapstructure:"health" validate:""`
|
||||
}
|
||||
|
||||
type checksumOptions struct {
|
||||
Request sdkaws.RequestChecksumCalculation
|
||||
Response sdkaws.ResponseChecksumValidation
|
||||
}
|
||||
|
||||
type awsModel struct {
|
||||
Model
|
||||
retryer func() sdkaws.Retryer
|
||||
retryer func() sdkaws.Retryer
|
||||
checksum checksumOptions
|
||||
}
|
||||
|
||||
func validateBucketS3(fl libval.FieldLevel) bool {
|
||||
|
@@ -50,7 +50,12 @@ func NewConfigJsonUnmashal(p []byte) (libaws.Config, error) {
|
||||
return &awsModel{
|
||||
Model: c,
|
||||
retryer: nil,
|
||||
endpoint: nil,
|
||||
mapRegion: nil,
|
||||
checksum: checksumOptions{
|
||||
Request: sdkaws.RequestChecksumCalculationWhenRequired,
|
||||
Response: sdkaws.ResponseChecksumValidationWhenRequired,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -64,6 +69,10 @@ func NewConfigStatusJsonUnmashal(p []byte) (libaws.Config, error) {
|
||||
Model: c.Config,
|
||||
retryer: nil,
|
||||
mapRegion: nil,
|
||||
checksum: checksumOptions{
|
||||
Request: sdkaws.RequestChecksumCalculationWhenRequired,
|
||||
Response: sdkaws.ResponseChecksumValidationWhenRequired,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -79,6 +88,10 @@ func NewConfig(bucket, accessKey, secretKey string, endpoint *url.URL, region st
|
||||
endpoint: endpoint,
|
||||
retryer: nil,
|
||||
mapRegion: make(map[string]*url.URL),
|
||||
checksum: checksumOptions{
|
||||
Request: sdkaws.RequestChecksumCalculationWhenRequired,
|
||||
Response: sdkaws.ResponseChecksumValidationWhenRequired,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +113,10 @@ func (c *awsModel) Clone() libaws.Config {
|
||||
retryer: c.retryer,
|
||||
endpoint: c.endpoint,
|
||||
mapRegion: m,
|
||||
checksum: checksumOptions{
|
||||
Request: c.checksum.Request,
|
||||
Response: c.checksum.Response,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +139,18 @@ func (c *awsModel) GetConfig(ctx context.Context, cli libhtc.HttpClient) (*sdkaw
|
||||
cfg.HTTPClient = cli
|
||||
}
|
||||
|
||||
if c.checksum.Request != sdkaws.RequestChecksumCalculationWhenSupported {
|
||||
cfg.RequestChecksumCalculation = sdkaws.RequestChecksumCalculationWhenRequired
|
||||
} else {
|
||||
cfg.RequestChecksumCalculation = sdkaws.RequestChecksumCalculationWhenSupported
|
||||
}
|
||||
|
||||
if c.checksum.Response != sdkaws.ResponseChecksumValidationWhenSupported {
|
||||
cfg.ResponseChecksumValidation = sdkaws.ResponseChecksumValidationWhenRequired
|
||||
} else {
|
||||
cfg.ResponseChecksumValidation = sdkaws.ResponseChecksumValidationWhenSupported
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
@@ -136,3 +165,10 @@ func (c *awsModel) SetBucketName(bucket string) {
|
||||
func (c *awsModel) JSON() ([]byte, error) {
|
||||
return json.MarshalIndent(c, "", " ")
|
||||
}
|
||||
|
||||
func (c *awsModel) SetChecksumValidation(req sdkaws.RequestChecksumCalculation, rsp sdkaws.ResponseChecksumValidation) {
|
||||
c.checksum = checksumOptions{
|
||||
Request: req,
|
||||
Response: rsp,
|
||||
}
|
||||
}
|
||||
|
@@ -52,12 +52,18 @@ type ModelStatus struct {
|
||||
Monitor libreq.OptionsHealth `json:"health" yaml:"health" toml:"health" mapstructure:"health" validate:""`
|
||||
}
|
||||
|
||||
type checksumOptions struct {
|
||||
Request sdkaws.RequestChecksumCalculation
|
||||
Response sdkaws.ResponseChecksumValidation
|
||||
}
|
||||
|
||||
type awsModel struct {
|
||||
Model
|
||||
|
||||
retryer func() sdkaws.Retryer
|
||||
endpoint *url.URL
|
||||
mapRegion map[string]*url.URL
|
||||
checksum checksumOptions
|
||||
}
|
||||
|
||||
func validateBucketS3(fl libval.FieldLevel) bool {
|
||||
|
@@ -73,6 +73,8 @@ type Config interface {
|
||||
|
||||
GetBucketName() string
|
||||
SetBucketName(bucket string)
|
||||
|
||||
SetChecksumValidation(req sdkaws.RequestChecksumCalculation, rsp sdkaws.ResponseChecksumValidation)
|
||||
}
|
||||
|
||||
type AWS interface {
|
||||
|
83
go.mod
83
go.mod
@@ -5,13 +5,13 @@ go 1.23
|
||||
toolchain go1.23.3
|
||||
|
||||
require (
|
||||
github.com/aws/aws-sdk-go v1.55.5
|
||||
github.com/aws/aws-sdk-go-v2 v1.32.7
|
||||
github.com/aws/aws-sdk-go-v2/config v1.28.7
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.17.48
|
||||
github.com/aws/aws-sdk-go-v2/service/iam v1.38.3
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.72.0
|
||||
github.com/aws/smithy-go v1.22.1
|
||||
github.com/aws/aws-sdk-go v1.55.6
|
||||
github.com/aws/aws-sdk-go-v2 v1.34.0
|
||||
github.com/aws/aws-sdk-go-v2/config v1.29.2
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.17.55
|
||||
github.com/aws/aws-sdk-go-v2/service/iam v1.38.8
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.74.1
|
||||
github.com/aws/smithy-go v1.22.2
|
||||
github.com/bits-and-blooms/bitset v1.20.0
|
||||
github.com/c-bata/go-prompt v0.2.6
|
||||
github.com/dsnet/compress v0.0.1
|
||||
@@ -20,7 +20,7 @@ require (
|
||||
github.com/fxamacker/cbor/v2 v2.7.0
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/go-ldap/ldap/v3 v3.4.10
|
||||
github.com/go-playground/validator/v10 v10.23.0
|
||||
github.com/go-playground/validator/v10 v10.24.0
|
||||
github.com/google/go-github/v33 v33.0.0
|
||||
github.com/hashicorp/go-hclog v1.6.3
|
||||
github.com/hashicorp/go-retryablehttp v0.7.7
|
||||
@@ -28,11 +28,11 @@ require (
|
||||
github.com/hashicorp/go-version v1.7.0
|
||||
github.com/jlaffaye/ftp v0.2.0
|
||||
github.com/matcornic/hermes/v2 v2.1.0
|
||||
github.com/mattn/go-colorable v0.1.13
|
||||
github.com/mattn/go-colorable v0.1.14
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
github.com/nats-io/jwt/v2 v2.7.3
|
||||
github.com/nats-io/nats-server/v2 v2.10.24
|
||||
github.com/nats-io/nats-server/v2 v2.10.25
|
||||
github.com/nats-io/nats.go v1.38.0
|
||||
github.com/onsi/ginkgo/v2 v2.22.2
|
||||
github.com/onsi/gomega v1.36.2
|
||||
@@ -47,10 +47,10 @@ require (
|
||||
github.com/spf13/viper v1.19.0
|
||||
github.com/ugorji/go/codec v1.2.12
|
||||
github.com/ulikunitz/xz v0.5.12
|
||||
github.com/vbauerster/mpb/v8 v8.8.3
|
||||
github.com/vbauerster/mpb/v8 v8.9.1
|
||||
github.com/xanzy/go-gitlab v0.115.0
|
||||
github.com/xhit/go-simple-mail v2.2.2+incompatible
|
||||
golang.org/x/net v0.33.0
|
||||
golang.org/x/net v0.34.0
|
||||
golang.org/x/oauth2 v0.25.0
|
||||
golang.org/x/sync v0.10.0
|
||||
golang.org/x/sys v0.29.0
|
||||
@@ -68,7 +68,7 @@ require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
|
||||
github.com/ClickHouse/ch-go v0.63.1 // indirect
|
||||
github.com/ClickHouse/clickhouse-go/v2 v2.30.0 // indirect
|
||||
github.com/ClickHouse/clickhouse-go/v2 v2.30.1 // indirect
|
||||
github.com/Masterminds/goutils v1.1.1 // indirect
|
||||
github.com/Masterminds/semver v1.5.0 // indirect
|
||||
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
|
||||
@@ -77,37 +77,36 @@ require (
|
||||
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
|
||||
github.com/andybalholm/brotli v1.1.1 // indirect
|
||||
github.com/andybalholm/cascadia v1.3.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.26 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.7 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.24.8 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.33.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.8 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.25 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.29 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.29 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.2 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.29 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.2 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.5.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.10 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.10 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.24.12 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.11 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.33.10 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bytedance/sonic v1.12.6 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.1 // indirect
|
||||
github.com/bytedance/sonic v1.12.8 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.3 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/cloudwego/base64x v0.1.4 // indirect
|
||||
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||
github.com/cloudwego/base64x v0.1.5 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
|
||||
github.com/gin-contrib/sse v1.0.0 // indirect
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.7 // indirect
|
||||
github.com/go-faster/city v1.0.1 // indirect
|
||||
github.com/go-faster/errors v0.7.1 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
||||
github.com/goccy/go-json v0.10.4 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
|
||||
github.com/golang-sql/sqlexp v0.1.0 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
@@ -153,16 +152,16 @@ require (
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pkg/term v1.2.0-beta.2 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.55.0 // indirect
|
||||
github.com/prometheus/common v0.62.0 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/sagikazarmark/locafero v0.6.0 // indirect
|
||||
github.com/sagikazarmark/locafero v0.7.0 // indirect
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||
github.com/segmentio/asm v1.2.0 // indirect
|
||||
github.com/shopspring/decimal v1.4.0 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/spf13/afero v1.11.0 // indirect
|
||||
github.com/spf13/afero v1.12.0 // indirect
|
||||
github.com/spf13/cast v1.7.1 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
|
||||
@@ -171,16 +170,16 @@ require (
|
||||
github.com/vanng822/css v1.0.1 // indirect
|
||||
github.com/vanng822/go-premailer v1.22.0 // indirect
|
||||
github.com/x448/float16 v0.8.4 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.3 // indirect
|
||||
go.opentelemetry.io/otel v1.33.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.33.0 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||
go.opentelemetry.io/otel v1.34.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.34.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/arch v0.13.0 // indirect
|
||||
golang.org/x/crypto v0.31.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20250103183323-7d7fa50e5329 // indirect
|
||||
golang.org/x/crypto v0.32.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20250128144449-3edf0e91c1ae // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
golang.org/x/time v0.9.0 // indirect
|
||||
golang.org/x/tools v0.28.0 // indirect
|
||||
google.golang.org/protobuf v1.36.1 // indirect
|
||||
golang.org/x/tools v0.29.0 // indirect
|
||||
google.golang.org/protobuf v1.36.4 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
)
|
||||
|
Reference in New Issue
Block a user