Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
bae91aed
Commit
bae91aed
authored
Mar 20, 2015
by
Victor Marmol
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5711 from justinsb/add_goamz_elb_2
(Re)add dependency on ELB functionality of goamz
parents
3e91fc52
d8a2d030
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
459 additions
and
0 deletions
+459
-0
Godeps.json
Godeps/Godeps.json
+4
-0
elb.go
Godeps/_workspace/src/github.com/mitchellh/goamz/elb/elb.go
+0
-0
elb_test.go
..._workspace/src/github.com/mitchellh/goamz/elb/elb_test.go
+235
-0
responses_test.go
...pace/src/github.com/mitchellh/goamz/elb/responses_test.go
+182
-0
sign.go
Godeps/_workspace/src/github.com/mitchellh/goamz/elb/sign.go
+38
-0
No files found.
Godeps/Godeps.json
View file @
bae91aed
...
...
@@ -325,6 +325,10 @@
"Rev"
:
"703cfb45985762869e465f37ed030ff01615ff1e"
},
{
"ImportPath"
:
"github.com/mitchellh/goamz/elb"
,
"Rev"
:
"703cfb45985762869e465f37ed030ff01615ff1e"
},
{
"ImportPath"
:
"github.com/mitchellh/mapstructure"
,
"Rev"
:
"740c764bc6149d3f1806231418adb9f52c11bcbf"
},
...
...
Godeps/_workspace/src/github.com/mitchellh/goamz/elb/elb.go
0 → 100644
View file @
bae91aed
This diff is collapsed.
Click to expand it.
Godeps/_workspace/src/github.com/mitchellh/goamz/elb/elb_test.go
0 → 100644
View file @
bae91aed
package
elb_test
import
(
"github.com/mitchellh/goamz/aws"
"github.com/mitchellh/goamz/elb"
"github.com/mitchellh/goamz/testutil"
.
"github.com/motain/gocheck"
"testing"
)
func
Test
(
t
*
testing
.
T
)
{
TestingT
(
t
)
}
type
S
struct
{
elb
*
elb
.
ELB
}
var
_
=
Suite
(
&
S
{})
var
testServer
=
testutil
.
NewHTTPServer
()
func
(
s
*
S
)
SetUpSuite
(
c
*
C
)
{
testServer
.
Start
()
auth
:=
aws
.
Auth
{
"abc"
,
"123"
,
""
}
s
.
elb
=
elb
.
NewWithClient
(
auth
,
aws
.
Region
{
ELBEndpoint
:
testServer
.
URL
},
testutil
.
DefaultClient
)
}
func
(
s
*
S
)
TearDownTest
(
c
*
C
)
{
testServer
.
Flush
()
}
func
(
s
*
S
)
TestAddTags
(
c
*
C
)
{
testServer
.
Response
(
200
,
nil
,
AddTagsExample
)
options
:=
elb
.
AddTags
{
LoadBalancerNames
:
[]
string
{
"foobar"
},
Tags
:
[]
elb
.
Tag
{
{
Key
:
"hello"
,
Value
:
"world"
,
},
},
}
resp
,
err
:=
s
.
elb
.
AddTags
(
&
options
)
req
:=
testServer
.
WaitRequest
()
c
.
Assert
(
req
.
Form
[
"Action"
],
DeepEquals
,
[]
string
{
"AddTags"
})
c
.
Assert
(
req
.
Form
[
"LoadBalancerNames.member.1"
],
DeepEquals
,
[]
string
{
"foobar"
})
c
.
Assert
(
req
.
Form
[
"Tags.member.1.Key"
],
DeepEquals
,
[]
string
{
"hello"
})
c
.
Assert
(
req
.
Form
[
"Tags.member.1.Value"
],
DeepEquals
,
[]
string
{
"world"
})
c
.
Assert
(
err
,
IsNil
)
c
.
Assert
(
resp
.
RequestId
,
Equals
,
"360e81f7-1100-11e4-b6ed-0f30EXAMPLE"
)
}
func
(
s
*
S
)
TestRemoveTags
(
c
*
C
)
{
testServer
.
Response
(
200
,
nil
,
RemoveTagsExample
)
options
:=
elb
.
RemoveTags
{
LoadBalancerNames
:
[]
string
{
"foobar"
},
TagKeys
:
[]
string
{
"hello"
},
}
resp
,
err
:=
s
.
elb
.
RemoveTags
(
&
options
)
req
:=
testServer
.
WaitRequest
()
c
.
Assert
(
req
.
Form
[
"Action"
],
DeepEquals
,
[]
string
{
"RemoveTags"
})
c
.
Assert
(
req
.
Form
[
"LoadBalancerNames.member.1"
],
DeepEquals
,
[]
string
{
"foobar"
})
c
.
Assert
(
req
.
Form
[
"Tags.member.1.Key"
],
DeepEquals
,
[]
string
{
"hello"
})
c
.
Assert
(
err
,
IsNil
)
c
.
Assert
(
resp
.
RequestId
,
Equals
,
"83c88b9d-12b7-11e3-8b82-87b12EXAMPLE"
)
}
func
(
s
*
S
)
TestCreateLoadBalancer
(
c
*
C
)
{
testServer
.
Response
(
200
,
nil
,
CreateLoadBalancerExample
)
options
:=
elb
.
CreateLoadBalancer
{
AvailZone
:
[]
string
{
"us-east-1a"
},
Listeners
:
[]
elb
.
Listener
{
elb
.
Listener
{
InstancePort
:
80
,
InstanceProtocol
:
"http"
,
SSLCertificateId
:
"needToAddASSLCertToYourAWSAccount"
,
LoadBalancerPort
:
80
,
Protocol
:
"http"
,
},
},
LoadBalancerName
:
"foobar"
,
Internal
:
false
,
SecurityGroups
:
[]
string
{
"sg1"
},
Subnets
:
[]
string
{
"sn1"
},
}
resp
,
err
:=
s
.
elb
.
CreateLoadBalancer
(
&
options
)
req
:=
testServer
.
WaitRequest
()
c
.
Assert
(
req
.
Form
[
"Action"
],
DeepEquals
,
[]
string
{
"CreateLoadBalancer"
})
c
.
Assert
(
req
.
Form
[
"LoadBalancerName"
],
DeepEquals
,
[]
string
{
"foobar"
})
c
.
Assert
(
err
,
IsNil
)
c
.
Assert
(
resp
.
RequestId
,
Equals
,
"1549581b-12b7-11e3-895e-1334aEXAMPLE"
)
}
func
(
s
*
S
)
TestDeleteLoadBalancer
(
c
*
C
)
{
testServer
.
Response
(
200
,
nil
,
DeleteLoadBalancerExample
)
options
:=
elb
.
DeleteLoadBalancer
{
LoadBalancerName
:
"foobar"
,
}
resp
,
err
:=
s
.
elb
.
DeleteLoadBalancer
(
&
options
)
req
:=
testServer
.
WaitRequest
()
c
.
Assert
(
req
.
Form
[
"Action"
],
DeepEquals
,
[]
string
{
"DeleteLoadBalancer"
})
c
.
Assert
(
req
.
Form
[
"LoadBalancerName"
],
DeepEquals
,
[]
string
{
"foobar"
})
c
.
Assert
(
err
,
IsNil
)
c
.
Assert
(
resp
.
RequestId
,
Equals
,
"1549581b-12b7-11e3-895e-1334aEXAMPLE"
)
}
func
(
s
*
S
)
TestDescribeLoadBalancers
(
c
*
C
)
{
testServer
.
Response
(
200
,
nil
,
DescribeLoadBalancersExample
)
options
:=
elb
.
DescribeLoadBalancer
{
Names
:
[]
string
{
"foobar"
},
}
resp
,
err
:=
s
.
elb
.
DescribeLoadBalancers
(
&
options
)
req
:=
testServer
.
WaitRequest
()
c
.
Assert
(
req
.
Form
[
"Action"
],
DeepEquals
,
[]
string
{
"DescribeLoadBalancers"
})
c
.
Assert
(
err
,
IsNil
)
c
.
Assert
(
resp
.
RequestId
,
Equals
,
"83c88b9d-12b7-11e3-8b82-87b12EXAMPLE"
)
c
.
Assert
(
resp
.
LoadBalancers
[
0
]
.
LoadBalancerName
,
Equals
,
"MyLoadBalancer"
)
c
.
Assert
(
resp
.
LoadBalancers
[
0
]
.
Listeners
[
0
]
.
Protocol
,
Equals
,
"HTTP"
)
c
.
Assert
(
resp
.
LoadBalancers
[
0
]
.
Instances
[
0
]
.
InstanceId
,
Equals
,
"i-e4cbe38d"
)
c
.
Assert
(
resp
.
LoadBalancers
[
0
]
.
AvailabilityZones
[
0
]
.
AvailabilityZone
,
Equals
,
"us-east-1a"
)
c
.
Assert
(
resp
.
LoadBalancers
[
0
]
.
Scheme
,
Equals
,
"internet-facing"
)
c
.
Assert
(
resp
.
LoadBalancers
[
0
]
.
DNSName
,
Equals
,
"MyLoadBalancer-123456789.us-east-1.elb.amazonaws.com"
)
c
.
Assert
(
resp
.
LoadBalancers
[
0
]
.
HealthCheck
.
HealthyThreshold
,
Equals
,
int64
(
2
))
c
.
Assert
(
resp
.
LoadBalancers
[
0
]
.
HealthCheck
.
UnhealthyThreshold
,
Equals
,
int64
(
10
))
c
.
Assert
(
resp
.
LoadBalancers
[
0
]
.
HealthCheck
.
Interval
,
Equals
,
int64
(
90
))
c
.
Assert
(
resp
.
LoadBalancers
[
0
]
.
HealthCheck
.
Target
,
Equals
,
"HTTP:80/"
)
c
.
Assert
(
resp
.
LoadBalancers
[
0
]
.
HealthCheck
.
Timeout
,
Equals
,
int64
(
60
))
}
func
(
s
*
S
)
TestRegisterInstancesWithLoadBalancer
(
c
*
C
)
{
testServer
.
Response
(
200
,
nil
,
RegisterInstancesWithLoadBalancerExample
)
options
:=
elb
.
RegisterInstancesWithLoadBalancer
{
LoadBalancerName
:
"foobar"
,
Instances
:
[]
string
{
"instance-1"
,
"instance-2"
},
}
resp
,
err
:=
s
.
elb
.
RegisterInstancesWithLoadBalancer
(
&
options
)
req
:=
testServer
.
WaitRequest
()
c
.
Assert
(
req
.
Form
[
"Action"
],
DeepEquals
,
[]
string
{
"RegisterInstancesWithLoadBalancer"
})
c
.
Assert
(
req
.
Form
[
"LoadBalancerName"
],
DeepEquals
,
[]
string
{
"foobar"
})
c
.
Assert
(
req
.
Form
[
"Instances.member.1.InstanceId"
],
DeepEquals
,
[]
string
{
"instance-1"
})
c
.
Assert
(
req
.
Form
[
"Instances.member.2.InstanceId"
],
DeepEquals
,
[]
string
{
"instance-2"
})
c
.
Assert
(
err
,
IsNil
)
c
.
Assert
(
resp
.
Instances
[
0
]
.
InstanceId
,
Equals
,
"i-315b7e51"
)
c
.
Assert
(
resp
.
RequestId
,
Equals
,
"83c88b9d-12b7-11e3-8b82-87b12EXAMPLE"
)
}
func
(
s
*
S
)
TestDeregisterInstancesFromLoadBalancer
(
c
*
C
)
{
testServer
.
Response
(
200
,
nil
,
DeregisterInstancesFromLoadBalancerExample
)
options
:=
elb
.
DeregisterInstancesFromLoadBalancer
{
LoadBalancerName
:
"foobar"
,
Instances
:
[]
string
{
"instance-1"
,
"instance-2"
},
}
resp
,
err
:=
s
.
elb
.
DeregisterInstancesFromLoadBalancer
(
&
options
)
req
:=
testServer
.
WaitRequest
()
c
.
Assert
(
req
.
Form
[
"Action"
],
DeepEquals
,
[]
string
{
"DeregisterInstancesFromLoadBalancer"
})
c
.
Assert
(
req
.
Form
[
"LoadBalancerName"
],
DeepEquals
,
[]
string
{
"foobar"
})
c
.
Assert
(
req
.
Form
[
"Instances.member.1.InstanceId"
],
DeepEquals
,
[]
string
{
"instance-1"
})
c
.
Assert
(
req
.
Form
[
"Instances.member.2.InstanceId"
],
DeepEquals
,
[]
string
{
"instance-2"
})
c
.
Assert
(
err
,
IsNil
)
c
.
Assert
(
resp
.
Instances
[
0
]
.
InstanceId
,
Equals
,
"i-6ec63d59"
)
c
.
Assert
(
resp
.
RequestId
,
Equals
,
"83c88b9d-12b7-11e3-8b82-87b12EXAMPLE"
)
}
func
(
s
*
S
)
TestConfigureHealthCheck
(
c
*
C
)
{
testServer
.
Response
(
200
,
nil
,
ConfigureHealthCheckExample
)
options
:=
elb
.
ConfigureHealthCheck
{
LoadBalancerName
:
"foobar"
,
Check
:
elb
.
HealthCheck
{
HealthyThreshold
:
2
,
UnhealthyThreshold
:
2
,
Interval
:
30
,
Target
:
"HTTP:80/ping"
,
Timeout
:
3
,
},
}
resp
,
err
:=
s
.
elb
.
ConfigureHealthCheck
(
&
options
)
req
:=
testServer
.
WaitRequest
()
c
.
Assert
(
req
.
Form
[
"Action"
],
DeepEquals
,
[]
string
{
"ConfigureHealthCheck"
})
c
.
Assert
(
req
.
Form
[
"LoadBalancerName"
],
DeepEquals
,
[]
string
{
"foobar"
})
c
.
Assert
(
err
,
IsNil
)
c
.
Assert
(
resp
.
Check
.
HealthyThreshold
,
Equals
,
int64
(
2
))
c
.
Assert
(
resp
.
Check
.
UnhealthyThreshold
,
Equals
,
int64
(
2
))
c
.
Assert
(
resp
.
Check
.
Interval
,
Equals
,
int64
(
30
))
c
.
Assert
(
resp
.
Check
.
Target
,
Equals
,
"HTTP:80/ping"
)
c
.
Assert
(
resp
.
Check
.
Timeout
,
Equals
,
int64
(
3
))
c
.
Assert
(
resp
.
RequestId
,
Equals
,
"83c88b9d-12b7-11e3-8b82-87b12EXAMPLE"
)
}
func
(
s
*
S
)
TestDescribeInstanceHealth
(
c
*
C
)
{
testServer
.
Response
(
200
,
nil
,
DescribeInstanceHealthExample
)
options
:=
elb
.
DescribeInstanceHealth
{
LoadBalancerName
:
"foobar"
,
}
resp
,
err
:=
s
.
elb
.
DescribeInstanceHealth
(
&
options
)
req
:=
testServer
.
WaitRequest
()
c
.
Assert
(
req
.
Form
[
"Action"
],
DeepEquals
,
[]
string
{
"DescribeInstanceHealth"
})
c
.
Assert
(
req
.
Form
[
"LoadBalancerName"
],
DeepEquals
,
[]
string
{
"foobar"
})
c
.
Assert
(
err
,
IsNil
)
c
.
Assert
(
resp
.
InstanceStates
[
0
]
.
InstanceId
,
Equals
,
"i-90d8c2a5"
)
c
.
Assert
(
resp
.
InstanceStates
[
0
]
.
State
,
Equals
,
"InService"
)
c
.
Assert
(
resp
.
InstanceStates
[
1
]
.
InstanceId
,
Equals
,
"i-06ea3e60"
)
c
.
Assert
(
resp
.
InstanceStates
[
1
]
.
State
,
Equals
,
"OutOfService"
)
c
.
Assert
(
resp
.
RequestId
,
Equals
,
"1549581b-12b7-11e3-895e-1334aEXAMPLE"
)
}
Godeps/_workspace/src/github.com/mitchellh/goamz/elb/responses_test.go
0 → 100644
View file @
bae91aed
package
elb_test
var
ErrorDump
=
`
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>UnsupportedOperation</Code>
<Message></Message>
</Error></Errors><RequestID>0503f4e9-bbd6-483c-b54f-c4ae9f3b30f4</RequestID></Response>
`
// http://goo.gl/OkMdtJ
var
AddTagsExample
=
`
<AddTagsResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<AddTagsResult/>
<ResponseMetadata>
<RequestId>360e81f7-1100-11e4-b6ed-0f30EXAMPLE</RequestId>
</ResponseMetadata>
</AddTagsResponse>
`
// http://goo.gl/nT2E89
var
RemoveTagsExample
=
`
<RemoveTagsResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<RemoveTagsResult/>
<ResponseMetadata>
<RequestId>83c88b9d-12b7-11e3-8b82-87b12EXAMPLE</RequestId>
</ResponseMetadata>
</RemoveTagsResponse>
`
// http://goo.gl/gQRD2H
var
CreateLoadBalancerExample
=
`
<CreateLoadBalancerResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<CreateLoadBalancerResult>
<DNSName>MyLoadBalancer-1234567890.us-east-1.elb.amazonaws.com</DNSName>
</CreateLoadBalancerResult>
<ResponseMetadata>
<RequestId>1549581b-12b7-11e3-895e-1334aEXAMPLE</RequestId>
</ResponseMetadata>
</CreateLoadBalancerResponse>
`
// http://goo.gl/GLZeBN
var
DeleteLoadBalancerExample
=
`
<DeleteLoadBalancerResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<ResponseMetadata>
<RequestId>1549581b-12b7-11e3-895e-1334aEXAMPLE</RequestId>
</ResponseMetadata>
</DeleteLoadBalancerResponse>
`
// http://goo.gl/8UgpQ8
var
DescribeLoadBalancersExample
=
`
<DescribeLoadBalancersResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<DescribeLoadBalancersResult>
<LoadBalancerDescriptions>
<member>
<SecurityGroups/>
<LoadBalancerName>MyLoadBalancer</LoadBalancerName>
<CreatedTime>2013-05-24T21:15:31.280Z</CreatedTime>
<HealthCheck>
<Interval>90</Interval>
<Target>HTTP:80/</Target>
<HealthyThreshold>2</HealthyThreshold>
<Timeout>60</Timeout>
<UnhealthyThreshold>10</UnhealthyThreshold>
</HealthCheck>
<ListenerDescriptions>
<member>
<PolicyNames/>
<Listener>
<Protocol>HTTP</Protocol>
<LoadBalancerPort>80</LoadBalancerPort>
<InstanceProtocol>HTTP</InstanceProtocol>
<SSLCertificateId>needToAddASSLCertToYourAWSAccount</SSLCertificateId>
<InstancePort>80</InstancePort>
</Listener>
</member>
</ListenerDescriptions>
<Instances>
<member>
<InstanceId>i-e4cbe38d</InstanceId>
</member>
</Instances>
<Policies>
<AppCookieStickinessPolicies/>
<OtherPolicies/>
<LBCookieStickinessPolicies/>
</Policies>
<AvailabilityZones>
<member>us-east-1a</member>
</AvailabilityZones>
<CanonicalHostedZoneNameID>ZZZZZZZZZZZ123X</CanonicalHostedZoneNameID>
<CanonicalHostedZoneName>MyLoadBalancer-123456789.us-east-1.elb.amazonaws.com</CanonicalHostedZoneName>
<Scheme>internet-facing</Scheme>
<SourceSecurityGroup>
<OwnerAlias>amazon-elb</OwnerAlias>
<GroupName>amazon-elb-sg</GroupName>
</SourceSecurityGroup>
<DNSName>MyLoadBalancer-123456789.us-east-1.elb.amazonaws.com</DNSName>
<BackendServerDescriptions/>
<Subnets/>
</member>
</LoadBalancerDescriptions>
</DescribeLoadBalancersResult>
<ResponseMetadata>
<RequestId>83c88b9d-12b7-11e3-8b82-87b12EXAMPLE</RequestId>
</ResponseMetadata>
</DescribeLoadBalancersResponse>
`
// http://goo.gl/Uz1N66
var
RegisterInstancesWithLoadBalancerExample
=
`
<RegisterInstancesWithLoadBalancerResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<RegisterInstancesWithLoadBalancerResult>
<Instances>
<member>
<InstanceId>i-315b7e51</InstanceId>
</member>
</Instances>
</RegisterInstancesWithLoadBalancerResult>
<ResponseMetadata>
<RequestId>83c88b9d-12b7-11e3-8b82-87b12EXAMPLE</RequestId>
</ResponseMetadata>
</RegisterInstancesWithLoadBalancerResponse>
`
// http://goo.gl/5OMv62
var
DeregisterInstancesFromLoadBalancerExample
=
`
<DeregisterInstancesFromLoadBalancerResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<DeregisterInstancesFromLoadBalancerResult>
<Instances>
<member>
<InstanceId>i-6ec63d59</InstanceId>
</member>
</Instances>
</DeregisterInstancesFromLoadBalancerResult>
<ResponseMetadata>
<RequestId>83c88b9d-12b7-11e3-8b82-87b12EXAMPLE</RequestId>
</ResponseMetadata>
</DeregisterInstancesFromLoadBalancerResponse>
`
// http://docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_ConfigureHealthCheck.html
var
ConfigureHealthCheckExample
=
`
<ConfigureHealthCheckResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<ConfigureHealthCheckResult>
<HealthCheck>
<Interval>30</Interval>
<Target>HTTP:80/ping</Target>
<HealthyThreshold>2</HealthyThreshold>
<Timeout>3</Timeout>
<UnhealthyThreshold>2</UnhealthyThreshold>
</HealthCheck>
</ConfigureHealthCheckResult>
<ResponseMetadata>
<RequestId>83c88b9d-12b7-11e3-8b82-87b12EXAMPLE</RequestId>
</ResponseMetadata>
</ConfigureHealthCheckResponse>`
// http://goo.gl/cGNxfj
var
DescribeInstanceHealthExample
=
`
<DescribeInstanceHealthResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<DescribeInstanceHealthResult>
<InstanceStates>
<member>
<Description>N/A</Description>
<InstanceId>i-90d8c2a5</InstanceId>
<State>InService</State>
<ReasonCode>N/A</ReasonCode>
</member>
<member>
<Description>N/A</Description>
<InstanceId>i-06ea3e60</InstanceId>
<State>OutOfService</State>
<ReasonCode>N/A</ReasonCode>
</member>
</InstanceStates>
</DescribeInstanceHealthResult>
<ResponseMetadata>
<RequestId>1549581b-12b7-11e3-895e-1334aEXAMPLE</RequestId>
</ResponseMetadata>
</DescribeInstanceHealthResponse>`
Godeps/_workspace/src/github.com/mitchellh/goamz/elb/sign.go
0 → 100644
View file @
bae91aed
package
elb
import
(
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"github.com/mitchellh/goamz/aws"
"sort"
"strings"
)
// ----------------------------------------------------------------------------
// Version 2 signing (http://goo.gl/RSRp5)
var
b64
=
base64
.
StdEncoding
func
sign
(
auth
aws
.
Auth
,
method
,
path
string
,
params
map
[
string
]
string
,
host
string
)
{
params
[
"AWSAccessKeyId"
]
=
auth
.
AccessKey
params
[
"SignatureVersion"
]
=
"2"
params
[
"SignatureMethod"
]
=
"HmacSHA256"
if
auth
.
Token
!=
""
{
params
[
"SecurityToken"
]
=
auth
.
Token
}
var
sarray
[]
string
for
k
,
v
:=
range
params
{
sarray
=
append
(
sarray
,
aws
.
Encode
(
k
)
+
"="
+
aws
.
Encode
(
v
))
}
sort
.
StringSlice
(
sarray
)
.
Sort
()
joined
:=
strings
.
Join
(
sarray
,
"&"
)
payload
:=
method
+
"
\n
"
+
host
+
"
\n
"
+
path
+
"
\n
"
+
joined
hash
:=
hmac
.
New
(
sha256
.
New
,
[]
byte
(
auth
.
SecretKey
))
hash
.
Write
([]
byte
(
payload
))
signature
:=
make
([]
byte
,
b64
.
EncodedLen
(
hash
.
Size
()))
b64
.
Encode
(
signature
,
hash
.
Sum
(
nil
))
params
[
"Signature"
]
=
string
(
signature
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment