mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Replace minio-go with aws-sdk-go for s3-compatible log backend (#670)
* Logs should support specifying region when using S3-compatible object store * Use aws-sdk-go client for s3 backed logstore * fixes vendor with aws-sdk-go dependencies
This commit is contained in:
committed by
Reed Allman
parent
930d1e8dcc
commit
60d2e92c9a
69719
vendor/github.com/aws/aws-sdk-go/service/ec2/api.go
generated
vendored
Normal file
69719
vendor/github.com/aws/aws-sdk-go/service/ec2/api.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
67
vendor/github.com/aws/aws-sdk-go/service/ec2/customizations.go
generated
vendored
Normal file
67
vendor/github.com/aws/aws-sdk-go/service/ec2/customizations.go
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
package ec2
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awsutil"
|
||||
"github.com/aws/aws-sdk-go/aws/endpoints"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
)
|
||||
|
||||
func init() {
|
||||
initRequest = func(r *request.Request) {
|
||||
if r.Operation.Name == opCopySnapshot { // fill the PresignedURL parameter
|
||||
r.Handlers.Build.PushFront(fillPresignedURL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func fillPresignedURL(r *request.Request) {
|
||||
if !r.ParamsFilled() {
|
||||
return
|
||||
}
|
||||
|
||||
origParams := r.Params.(*CopySnapshotInput)
|
||||
|
||||
// Stop if PresignedURL/DestinationRegion is set
|
||||
if origParams.PresignedUrl != nil || origParams.DestinationRegion != nil {
|
||||
return
|
||||
}
|
||||
|
||||
origParams.DestinationRegion = r.Config.Region
|
||||
newParams := awsutil.CopyOf(r.Params).(*CopySnapshotInput)
|
||||
|
||||
// Create a new request based on the existing request. We will use this to
|
||||
// presign the CopySnapshot request against the source region.
|
||||
cfg := r.Config.Copy(aws.NewConfig().
|
||||
WithEndpoint("").
|
||||
WithRegion(aws.StringValue(origParams.SourceRegion)))
|
||||
|
||||
clientInfo := r.ClientInfo
|
||||
resolved, err := r.Config.EndpointResolver.EndpointFor(
|
||||
clientInfo.ServiceName, aws.StringValue(cfg.Region),
|
||||
func(opt *endpoints.Options) {
|
||||
opt.DisableSSL = aws.BoolValue(cfg.DisableSSL)
|
||||
opt.UseDualStack = aws.BoolValue(cfg.UseDualStack)
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
r.Error = err
|
||||
return
|
||||
}
|
||||
|
||||
clientInfo.Endpoint = resolved.URL
|
||||
clientInfo.SigningRegion = resolved.SigningRegion
|
||||
|
||||
// Presign a CopySnapshot request with modified params
|
||||
req := request.New(*cfg, clientInfo, r.Handlers, r.Retryer, r.Operation, newParams, r.Data)
|
||||
url, err := req.Presign(5 * time.Minute) // 5 minutes should be enough.
|
||||
if err != nil { // bubble error back up to original request
|
||||
r.Error = err
|
||||
return
|
||||
}
|
||||
|
||||
// We have our URL, set it on params
|
||||
origParams.PresignedUrl = &url
|
||||
}
|
||||
48
vendor/github.com/aws/aws-sdk-go/service/ec2/customizations_test.go
generated
vendored
Normal file
48
vendor/github.com/aws/aws-sdk-go/service/ec2/customizations_test.go
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
package ec2_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/awstesting/unit"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
)
|
||||
|
||||
func TestCopySnapshotPresignedURL(t *testing.T) {
|
||||
svc := ec2.New(unit.Session, &aws.Config{Region: aws.String("us-west-2")})
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
t.Fatalf("expect CopySnapshotRequest with nill")
|
||||
}
|
||||
}()
|
||||
// Doesn't panic on nil input
|
||||
req, _ := svc.CopySnapshotRequest(nil)
|
||||
req.Sign()
|
||||
}()
|
||||
|
||||
req, _ := svc.CopySnapshotRequest(&ec2.CopySnapshotInput{
|
||||
SourceRegion: aws.String("us-west-1"),
|
||||
SourceSnapshotId: aws.String("snap-id"),
|
||||
})
|
||||
req.Sign()
|
||||
|
||||
b, _ := ioutil.ReadAll(req.HTTPRequest.Body)
|
||||
q, _ := url.ParseQuery(string(b))
|
||||
u, _ := url.QueryUnescape(q.Get("PresignedUrl"))
|
||||
if e, a := "us-west-2", q.Get("DestinationRegion"); e != a {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
if e, a := "us-west-1", q.Get("SourceRegion"); e != a {
|
||||
t.Errorf("expect %v, got %v", e, a)
|
||||
}
|
||||
|
||||
r := regexp.MustCompile(`^https://ec2\.us-west-1\.amazonaws\.com/.+&DestinationRegion=us-west-2`)
|
||||
if !r.MatchString(u) {
|
||||
t.Errorf("expect %v to match, got %v", r.String(), u)
|
||||
}
|
||||
}
|
||||
31
vendor/github.com/aws/aws-sdk-go/service/ec2/doc.go
generated
vendored
Normal file
31
vendor/github.com/aws/aws-sdk-go/service/ec2/doc.go
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package ec2 provides the client and types for making API
|
||||
// requests to Amazon Elastic Compute Cloud.
|
||||
//
|
||||
// Amazon Elastic Compute Cloud (Amazon EC2) provides resizable computing capacity
|
||||
// in the Amazon Web Services (AWS) cloud. Using Amazon EC2 eliminates your
|
||||
// need to invest in hardware up front, so you can develop and deploy applications
|
||||
// faster.
|
||||
//
|
||||
// See https://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15 for more information on this service.
|
||||
//
|
||||
// See ec2 package documentation for more information.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/
|
||||
//
|
||||
// Using the Client
|
||||
//
|
||||
// To contact Amazon Elastic Compute Cloud 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 Amazon Elastic Compute Cloud client EC2 for more
|
||||
// information on creating client for this service.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#New
|
||||
package ec2
|
||||
1254
vendor/github.com/aws/aws-sdk-go/service/ec2/ec2iface/interface.go
generated
vendored
Normal file
1254
vendor/github.com/aws/aws-sdk-go/service/ec2/ec2iface/interface.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3
vendor/github.com/aws/aws-sdk-go/service/ec2/errors.go
generated
vendored
Normal file
3
vendor/github.com/aws/aws-sdk-go/service/ec2/errors.go
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package ec2
|
||||
4201
vendor/github.com/aws/aws-sdk-go/service/ec2/examples_test.go
generated
vendored
Normal file
4201
vendor/github.com/aws/aws-sdk-go/service/ec2/examples_test.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
93
vendor/github.com/aws/aws-sdk-go/service/ec2/service.go
generated
vendored
Normal file
93
vendor/github.com/aws/aws-sdk-go/service/ec2/service.go
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package ec2
|
||||
|
||||
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/ec2query"
|
||||
)
|
||||
|
||||
// EC2 provides the API operation methods for making requests to
|
||||
// Amazon Elastic Compute Cloud. See this package's package overview docs
|
||||
// for details on the service.
|
||||
//
|
||||
// EC2 methods are safe to use concurrently. It is not safe to
|
||||
// modify mutate any of the struct's properties though.
|
||||
type EC2 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 = "ec2" // Service endpoint prefix API calls made to.
|
||||
EndpointsID = ServiceName // Service ID for Regions and Endpoints metadata.
|
||||
)
|
||||
|
||||
// New creates a new instance of the EC2 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 EC2 client from just a session.
|
||||
// svc := ec2.New(mySession)
|
||||
//
|
||||
// // Create a EC2 client with additional configuration
|
||||
// svc := ec2.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
|
||||
func New(p client.ConfigProvider, cfgs ...*aws.Config) *EC2 {
|
||||
c := p.ClientConfig(EndpointsID, cfgs...)
|
||||
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) *EC2 {
|
||||
svc := &EC2{
|
||||
Client: client.New(
|
||||
cfg,
|
||||
metadata.ClientInfo{
|
||||
ServiceName: ServiceName,
|
||||
SigningName: signingName,
|
||||
SigningRegion: signingRegion,
|
||||
Endpoint: endpoint,
|
||||
APIVersion: "2016-11-15",
|
||||
},
|
||||
handlers,
|
||||
),
|
||||
}
|
||||
|
||||
// Handlers
|
||||
svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
|
||||
svc.Handlers.Build.PushBackNamed(ec2query.BuildHandler)
|
||||
svc.Handlers.Unmarshal.PushBackNamed(ec2query.UnmarshalHandler)
|
||||
svc.Handlers.UnmarshalMeta.PushBackNamed(ec2query.UnmarshalMetaHandler)
|
||||
svc.Handlers.UnmarshalError.PushBackNamed(ec2query.UnmarshalErrorHandler)
|
||||
|
||||
// Run custom client initialization if present
|
||||
if initClient != nil {
|
||||
initClient(svc.Client)
|
||||
}
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
// newRequest creates a new request for a EC2 operation and runs any
|
||||
// custom request initialization.
|
||||
func (c *EC2) 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
|
||||
}
|
||||
1626
vendor/github.com/aws/aws-sdk-go/service/ec2/waiters.go
generated
vendored
Normal file
1626
vendor/github.com/aws/aws-sdk-go/service/ec2/waiters.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user