mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
Update Go AWS SDK to the latest version
This commit is contained in:
committed by
Andrey Smirnov
parent
d08be990ef
commit
94a72b23ff
+3328
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
// +build integration
|
||||
|
||||
package s3control_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/s3control"
|
||||
)
|
||||
|
||||
func TestInteg_PublicAccessBlock(t *testing.T) {
|
||||
_, err := svc.GetPublicAccessBlock(&s3control.GetPublicAccessBlockInput{
|
||||
AccountId: aws.String(accountID),
|
||||
})
|
||||
if err != nil {
|
||||
aerr := err.(awserr.RequestFailure)
|
||||
// Only no such configuration is valid error to receive.
|
||||
if e, a := s3control.ErrCodeNoSuchPublicAccessBlockConfiguration, aerr.Code(); e != a {
|
||||
t.Fatalf("expected no error, or no such configuration, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
_, err = svc.PutPublicAccessBlock(&s3control.PutPublicAccessBlockInput{
|
||||
AccountId: aws.String(accountID),
|
||||
PublicAccessBlockConfiguration: &s3control.PublicAccessBlockConfiguration{
|
||||
IgnorePublicAcls: aws.Bool(true),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, got %v", err)
|
||||
}
|
||||
|
||||
_, err = svc.DeletePublicAccessBlock(&s3control.DeletePublicAccessBlockInput{
|
||||
AccountId: aws.String(accountID),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("expect no error, got %v", err)
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
// +build integration
|
||||
|
||||
package s3control_test
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/awstesting/integration"
|
||||
"github.com/aws/aws-sdk-go/service/s3control"
|
||||
"github.com/aws/aws-sdk-go/service/sts"
|
||||
)
|
||||
|
||||
var (
|
||||
svc *s3control.S3Control
|
||||
s3ControlEndpoint, stsEndpoint string
|
||||
accountID string
|
||||
insecureTLS, useDualstack bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&stsEndpoint, "sts-endpoint", "",
|
||||
"The optional `URL` endpoint for the STS service.",
|
||||
)
|
||||
flag.StringVar(&s3ControlEndpoint, "s3-control-endpoint", "",
|
||||
"The optional `URL` endpoint for the S3 Control service.",
|
||||
)
|
||||
flag.BoolVar(&insecureTLS, "insecure-tls", false,
|
||||
"Disables TLS validation on request endpoints.",
|
||||
)
|
||||
flag.BoolVar(&useDualstack, "dualstack", false,
|
||||
"Enables usage of dualstack endpoints.",
|
||||
)
|
||||
flag.StringVar(&accountID, "account", "",
|
||||
"The AWS account `ID`.",
|
||||
)
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
setup()
|
||||
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
// Create a bucket for testing
|
||||
func setup() {
|
||||
tlsCfg := &tls.Config{}
|
||||
if insecureTLS {
|
||||
tlsCfg.InsecureSkipVerify = true
|
||||
}
|
||||
|
||||
sess := integration.SessionWithDefaultRegion("us-west-2")
|
||||
sess.Copy(&aws.Config{
|
||||
HTTPClient: &http.Client{
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: tlsCfg,
|
||||
},
|
||||
},
|
||||
UseDualStack: aws.Bool(useDualstack),
|
||||
})
|
||||
|
||||
if len(accountID) == 0 {
|
||||
stsSvc := sts.New(sess, &aws.Config{
|
||||
Endpoint: &stsEndpoint,
|
||||
})
|
||||
identity, err := stsSvc.GetCallerIdentity(&sts.GetCallerIdentityInput{})
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to get accountID, %v", err))
|
||||
}
|
||||
accountID = aws.StringValue(identity.Account)
|
||||
}
|
||||
|
||||
svc = s3control.New(sess, &aws.Config{
|
||||
Endpoint: &s3ControlEndpoint,
|
||||
})
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package s3control
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws/client"
|
||||
"github.com/aws/aws-sdk-go/internal/s3err"
|
||||
)
|
||||
|
||||
func init() {
|
||||
initClient = defaultInitClientFn
|
||||
}
|
||||
|
||||
func defaultInitClientFn(c *client.Client) {
|
||||
c.Handlers.UnmarshalError.PushBackNamed(s3err.RequestFailureWrapperHandler())
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package s3control provides the client and types for making API
|
||||
// requests to AWS S3 Control.
|
||||
//
|
||||
// AWS S3 Control provides access to Amazon S3 control plane operations.
|
||||
//
|
||||
// See https://docs.aws.amazon.com/goto/WebAPI/s3control-2018-08-20 for more information on this service.
|
||||
//
|
||||
// See s3control package documentation for more information.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/s3control/
|
||||
//
|
||||
// Using the Client
|
||||
//
|
||||
// To contact AWS S3 Control with the SDK use the New function to create
|
||||
// a new service client. With that client you can make API requests to the service.
|
||||
// These clients are safe to use concurrently.
|
||||
//
|
||||
// See the SDK's documentation for more information on how to use the SDK.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/
|
||||
//
|
||||
// See aws.Config documentation for more information on configuring SDK clients.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config
|
||||
//
|
||||
// See the AWS S3 Control client S3Control for more
|
||||
// information on creating client for this service.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/s3control/#New
|
||||
package s3control
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package s3control
|
||||
|
||||
const (
|
||||
|
||||
// ErrCodeBadRequestException for service response error code
|
||||
// "BadRequestException".
|
||||
ErrCodeBadRequestException = "BadRequestException"
|
||||
|
||||
// ErrCodeIdempotencyException for service response error code
|
||||
// "IdempotencyException".
|
||||
ErrCodeIdempotencyException = "IdempotencyException"
|
||||
|
||||
// ErrCodeInternalServiceException for service response error code
|
||||
// "InternalServiceException".
|
||||
ErrCodeInternalServiceException = "InternalServiceException"
|
||||
|
||||
// ErrCodeInvalidNextTokenException for service response error code
|
||||
// "InvalidNextTokenException".
|
||||
ErrCodeInvalidNextTokenException = "InvalidNextTokenException"
|
||||
|
||||
// ErrCodeInvalidRequestException for service response error code
|
||||
// "InvalidRequestException".
|
||||
ErrCodeInvalidRequestException = "InvalidRequestException"
|
||||
|
||||
// ErrCodeJobStatusException for service response error code
|
||||
// "JobStatusException".
|
||||
ErrCodeJobStatusException = "JobStatusException"
|
||||
|
||||
// ErrCodeNoSuchPublicAccessBlockConfiguration for service response error code
|
||||
// "NoSuchPublicAccessBlockConfiguration".
|
||||
ErrCodeNoSuchPublicAccessBlockConfiguration = "NoSuchPublicAccessBlockConfiguration"
|
||||
|
||||
// ErrCodeNotFoundException for service response error code
|
||||
// "NotFoundException".
|
||||
ErrCodeNotFoundException = "NotFoundException"
|
||||
|
||||
// ErrCodeTooManyRequestsException for service response error code
|
||||
// "TooManyRequestsException".
|
||||
ErrCodeTooManyRequestsException = "TooManyRequestsException"
|
||||
)
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package s3controliface provides an interface to enable mocking the AWS S3 Control service client
|
||||
// for testing your code.
|
||||
//
|
||||
// It is important to note that this interface will have breaking changes
|
||||
// when the service model is updated and adds new API operations, paginators,
|
||||
// and waiters.
|
||||
package s3controliface
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/service/s3control"
|
||||
)
|
||||
|
||||
// S3ControlAPI provides an interface to enable mocking the
|
||||
// s3control.S3Control service client's API operation,
|
||||
// paginators, and waiters. This make unit testing your code that calls out
|
||||
// to the SDK's service client's calls easier.
|
||||
//
|
||||
// The best way to use this interface is so the SDK's service client's calls
|
||||
// can be stubbed out for unit testing your code with the SDK without needing
|
||||
// to inject custom request handlers into the SDK's request pipeline.
|
||||
//
|
||||
// // myFunc uses an SDK service client to make a request to
|
||||
// // AWS S3 Control.
|
||||
// func myFunc(svc s3controliface.S3ControlAPI) bool {
|
||||
// // Make svc.CreateJob request
|
||||
// }
|
||||
//
|
||||
// func main() {
|
||||
// sess := session.New()
|
||||
// svc := s3control.New(sess)
|
||||
//
|
||||
// myFunc(svc)
|
||||
// }
|
||||
//
|
||||
// In your _test.go file:
|
||||
//
|
||||
// // Define a mock struct to be used in your unit tests of myFunc.
|
||||
// type mockS3ControlClient struct {
|
||||
// s3controliface.S3ControlAPI
|
||||
// }
|
||||
// func (m *mockS3ControlClient) CreateJob(input *s3control.CreateJobInput) (*s3control.CreateJobOutput, error) {
|
||||
// // mock response/functionality
|
||||
// }
|
||||
//
|
||||
// func TestMyFunc(t *testing.T) {
|
||||
// // Setup Test
|
||||
// mockSvc := &mockS3ControlClient{}
|
||||
//
|
||||
// myfunc(mockSvc)
|
||||
//
|
||||
// // Verify myFunc's functionality
|
||||
// }
|
||||
//
|
||||
// It is important to note that this interface will have breaking changes
|
||||
// when the service model is updated and adds new API operations, paginators,
|
||||
// and waiters. Its suggested to use the pattern above for testing, or using
|
||||
// tooling to generate mocks to satisfy the interfaces.
|
||||
type S3ControlAPI interface {
|
||||
CreateJob(*s3control.CreateJobInput) (*s3control.CreateJobOutput, error)
|
||||
CreateJobWithContext(aws.Context, *s3control.CreateJobInput, ...request.Option) (*s3control.CreateJobOutput, error)
|
||||
CreateJobRequest(*s3control.CreateJobInput) (*request.Request, *s3control.CreateJobOutput)
|
||||
|
||||
DeletePublicAccessBlock(*s3control.DeletePublicAccessBlockInput) (*s3control.DeletePublicAccessBlockOutput, error)
|
||||
DeletePublicAccessBlockWithContext(aws.Context, *s3control.DeletePublicAccessBlockInput, ...request.Option) (*s3control.DeletePublicAccessBlockOutput, error)
|
||||
DeletePublicAccessBlockRequest(*s3control.DeletePublicAccessBlockInput) (*request.Request, *s3control.DeletePublicAccessBlockOutput)
|
||||
|
||||
DescribeJob(*s3control.DescribeJobInput) (*s3control.DescribeJobOutput, error)
|
||||
DescribeJobWithContext(aws.Context, *s3control.DescribeJobInput, ...request.Option) (*s3control.DescribeJobOutput, error)
|
||||
DescribeJobRequest(*s3control.DescribeJobInput) (*request.Request, *s3control.DescribeJobOutput)
|
||||
|
||||
GetPublicAccessBlock(*s3control.GetPublicAccessBlockInput) (*s3control.GetPublicAccessBlockOutput, error)
|
||||
GetPublicAccessBlockWithContext(aws.Context, *s3control.GetPublicAccessBlockInput, ...request.Option) (*s3control.GetPublicAccessBlockOutput, error)
|
||||
GetPublicAccessBlockRequest(*s3control.GetPublicAccessBlockInput) (*request.Request, *s3control.GetPublicAccessBlockOutput)
|
||||
|
||||
ListJobs(*s3control.ListJobsInput) (*s3control.ListJobsOutput, error)
|
||||
ListJobsWithContext(aws.Context, *s3control.ListJobsInput, ...request.Option) (*s3control.ListJobsOutput, error)
|
||||
ListJobsRequest(*s3control.ListJobsInput) (*request.Request, *s3control.ListJobsOutput)
|
||||
|
||||
ListJobsPages(*s3control.ListJobsInput, func(*s3control.ListJobsOutput, bool) bool) error
|
||||
ListJobsPagesWithContext(aws.Context, *s3control.ListJobsInput, func(*s3control.ListJobsOutput, bool) bool, ...request.Option) error
|
||||
|
||||
PutPublicAccessBlock(*s3control.PutPublicAccessBlockInput) (*s3control.PutPublicAccessBlockOutput, error)
|
||||
PutPublicAccessBlockWithContext(aws.Context, *s3control.PutPublicAccessBlockInput, ...request.Option) (*s3control.PutPublicAccessBlockOutput, error)
|
||||
PutPublicAccessBlockRequest(*s3control.PutPublicAccessBlockInput) (*request.Request, *s3control.PutPublicAccessBlockOutput)
|
||||
|
||||
UpdateJobPriority(*s3control.UpdateJobPriorityInput) (*s3control.UpdateJobPriorityOutput, error)
|
||||
UpdateJobPriorityWithContext(aws.Context, *s3control.UpdateJobPriorityInput, ...request.Option) (*s3control.UpdateJobPriorityOutput, error)
|
||||
UpdateJobPriorityRequest(*s3control.UpdateJobPriorityInput) (*request.Request, *s3control.UpdateJobPriorityOutput)
|
||||
|
||||
UpdateJobStatus(*s3control.UpdateJobStatusInput) (*s3control.UpdateJobStatusOutput, error)
|
||||
UpdateJobStatusWithContext(aws.Context, *s3control.UpdateJobStatusInput, ...request.Option) (*s3control.UpdateJobStatusOutput, error)
|
||||
UpdateJobStatusRequest(*s3control.UpdateJobStatusInput) (*request.Request, *s3control.UpdateJobStatusOutput)
|
||||
}
|
||||
|
||||
var _ S3ControlAPI = (*s3control.S3Control)(nil)
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package s3control
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/client"
|
||||
"github.com/aws/aws-sdk-go/aws/client/metadata"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/aws/signer/v4"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/restxml"
|
||||
)
|
||||
|
||||
// S3Control provides the API operation methods for making requests to
|
||||
// AWS S3 Control. See this package's package overview docs
|
||||
// for details on the service.
|
||||
//
|
||||
// S3Control methods are safe to use concurrently. It is not safe to
|
||||
// modify mutate any of the struct's properties though.
|
||||
type S3Control struct {
|
||||
*client.Client
|
||||
}
|
||||
|
||||
// Used for custom client initialization logic
|
||||
var initClient func(*client.Client)
|
||||
|
||||
// Used for custom request initialization logic
|
||||
var initRequest func(*request.Request)
|
||||
|
||||
// Service information constants
|
||||
const (
|
||||
ServiceName = "S3 Control" // Name of service.
|
||||
EndpointsID = "s3-control" // ID to lookup a service endpoint with.
|
||||
ServiceID = "S3 Control" // ServiceID is a unique identifer of a specific service.
|
||||
)
|
||||
|
||||
// New creates a new instance of the S3Control client with a session.
|
||||
// If additional configuration is needed for the client instance use the optional
|
||||
// aws.Config parameter to add your extra config.
|
||||
//
|
||||
// Example:
|
||||
// // Create a S3Control client from just a session.
|
||||
// svc := s3control.New(mySession)
|
||||
//
|
||||
// // Create a S3Control client with additional configuration
|
||||
// svc := s3control.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
|
||||
func New(p client.ConfigProvider, cfgs ...*aws.Config) *S3Control {
|
||||
c := p.ClientConfig(EndpointsID, cfgs...)
|
||||
if c.SigningNameDerived || len(c.SigningName) == 0 {
|
||||
c.SigningName = "s3"
|
||||
}
|
||||
return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName)
|
||||
}
|
||||
|
||||
// newClient creates, initializes and returns a new service client instance.
|
||||
func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *S3Control {
|
||||
svc := &S3Control{
|
||||
Client: client.New(
|
||||
cfg,
|
||||
metadata.ClientInfo{
|
||||
ServiceName: ServiceName,
|
||||
ServiceID: ServiceID,
|
||||
SigningName: signingName,
|
||||
SigningRegion: signingRegion,
|
||||
Endpoint: endpoint,
|
||||
APIVersion: "2018-08-20",
|
||||
},
|
||||
handlers,
|
||||
),
|
||||
}
|
||||
|
||||
// Handlers
|
||||
svc.Handlers.Sign.PushBackNamed(v4.BuildNamedHandler(v4.SignRequestHandler.Name, func(s *v4.Signer) {
|
||||
s.DisableURIPathEscaping = true
|
||||
}))
|
||||
svc.Handlers.Build.PushBackNamed(restxml.BuildHandler)
|
||||
svc.Handlers.Unmarshal.PushBackNamed(restxml.UnmarshalHandler)
|
||||
svc.Handlers.UnmarshalMeta.PushBackNamed(restxml.UnmarshalMetaHandler)
|
||||
svc.Handlers.UnmarshalError.PushBackNamed(restxml.UnmarshalErrorHandler)
|
||||
|
||||
// Run custom client initialization if present
|
||||
if initClient != nil {
|
||||
initClient(svc.Client)
|
||||
}
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
// newRequest creates a new request for a S3Control operation and runs any
|
||||
// custom request initialization.
|
||||
func (c *S3Control) newRequest(op *request.Operation, params, data interface{}) *request.Request {
|
||||
req := c.NewRequest(op, params, data)
|
||||
|
||||
// Run custom request initialization if present
|
||||
if initRequest != nil {
|
||||
initRequest(req)
|
||||
}
|
||||
|
||||
return req
|
||||
}
|
||||
Reference in New Issue
Block a user