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
8fde691a
Commit
8fde691a
authored
Mar 26, 2015
by
Justin Santa Barbara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests
parent
edf0292d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
7 deletions
+34
-7
aws.go
pkg/cloudprovider/aws/aws.go
+9
-5
aws_test.go
pkg/cloudprovider/aws/aws_test.go
+20
-0
aws_pd_test.go
pkg/volume/aws_pd/aws_pd_test.go
+5
-2
No files found.
pkg/cloudprovider/aws/aws.go
View file @
8fde691a
...
@@ -216,7 +216,8 @@ func getAvailabilityZone(metadata AWSMetadata) (string, error) {
...
@@ -216,7 +216,8 @@ func getAvailabilityZone(metadata AWSMetadata) (string, error) {
}
}
// newAWSCloud creates a new instance of AWSCloud.
// newAWSCloud creates a new instance of AWSCloud.
func
newAWSCloud
(
config
io
.
Reader
,
authFunc
AuthFunc
,
metadata
AWSMetadata
)
(
*
AWSCloud
,
error
)
{
// authFunc and instanceId are primarily for tests
func
newAWSCloud
(
config
io
.
Reader
,
authFunc
AuthFunc
,
instanceId
string
,
metadata
AWSMetadata
)
(
*
AWSCloud
,
error
)
{
cfg
,
err
:=
readAWSCloudConfig
(
config
,
metadata
)
cfg
,
err
:=
readAWSCloudConfig
(
config
,
metadata
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"unable to read AWS cloud provider config file: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"unable to read AWS cloud provider config file: %v"
,
err
)
...
@@ -240,9 +241,12 @@ func newAWSCloud(config io.Reader, authFunc AuthFunc, metadata AWSMetadata) (*AW
...
@@ -240,9 +241,12 @@ func newAWSCloud(config io.Reader, authFunc AuthFunc, metadata AWSMetadata) (*AW
ec2
:=
&
goamzEC2
{
ec2
:
ec2
.
New
(
auth
,
region
)}
ec2
:=
&
goamzEC2
{
ec2
:
ec2
.
New
(
auth
,
region
)}
instanceId
,
err
:=
ec2
.
GetMetaData
(
"instance-id"
)
if
instanceId
==
""
{
if
err
!=
nil
{
instanceIdBytes
,
err
:=
ec2
.
GetMetaData
(
"instance-id"
)
return
nil
,
fmt
.
Errorf
(
"error fetching instance-id from ec2 metadata service: %v"
,
err
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error fetching instance-id from ec2 metadata service: %v"
,
err
)
}
instanceId
=
string
(
instanceIdBytes
)
}
}
awsCloud
:=
&
AWSCloud
{
awsCloud
:=
&
AWSCloud
{
...
@@ -252,7 +256,7 @@ func newAWSCloud(config io.Reader, authFunc AuthFunc, metadata AWSMetadata) (*AW
...
@@ -252,7 +256,7 @@ func newAWSCloud(config io.Reader, authFunc AuthFunc, metadata AWSMetadata) (*AW
availabilityZone
:
zone
,
availabilityZone
:
zone
,
}
}
awsCloud
.
selfAwsInstance
=
newAwsInstance
(
ec2
,
string
(
instanceId
)
)
awsCloud
.
selfAwsInstance
=
newAwsInstance
(
ec2
,
instanceId
)
return
awsCloud
,
nil
return
awsCloud
,
nil
}
}
...
...
pkg/cloudprovider/aws/aws_test.go
View file @
8fde691a
...
@@ -188,6 +188,26 @@ func (self *FakeMetadata) GetMetaData(key string) ([]byte, error) {
...
@@ -188,6 +188,26 @@ func (self *FakeMetadata) GetMetaData(key string) ([]byte, error) {
}
}
}
}
func
(
ec2
*
FakeEC2
)
AttachVolume
(
volumeId
string
,
instanceId
string
,
mountDevice
string
)
(
resp
*
ec2
.
AttachVolumeResp
,
err
error
)
{
panic
(
"Not implemented"
)
}
func
(
ec2
*
FakeEC2
)
DetachVolume
(
volumeId
string
)
(
resp
*
ec2
.
SimpleResp
,
err
error
)
{
panic
(
"Not implemented"
)
}
func
(
ec2
*
FakeEC2
)
Volumes
(
volumeIds
[]
string
,
filter
*
ec2
.
Filter
)
(
resp
*
ec2
.
VolumesResp
,
err
error
)
{
panic
(
"Not implemented"
)
}
func
(
ec2
*
FakeEC2
)
CreateVolume
(
request
*
ec2
.
CreateVolume
)
(
resp
*
ec2
.
CreateVolumeResp
,
err
error
)
{
panic
(
"Not implemented"
)
}
func
(
ec2
*
FakeEC2
)
DeleteVolume
(
volumeId
string
)
(
resp
*
ec2
.
SimpleResp
,
err
error
)
{
panic
(
"Not implemented"
)
}
func
mockInstancesResp
(
instances
[]
ec2
.
Instance
)
(
aws
*
AWSCloud
)
{
func
mockInstancesResp
(
instances
[]
ec2
.
Instance
)
(
aws
*
AWSCloud
)
{
availabilityZone
:=
"us-west-2d"
availabilityZone
:=
"us-west-2d"
return
&
AWSCloud
{
return
&
AWSCloud
{
...
...
pkg/volume/aws_pd/aws_pd_test.go
View file @
8fde691a
...
@@ -50,8 +50,11 @@ func TestGetAccessModes(t *testing.T) {
...
@@ -50,8 +50,11 @@ func TestGetAccessModes(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Can't find the plugin by name"
)
t
.
Errorf
(
"Can't find the plugin by name"
)
}
}
if
!
contains
(
plug
.
GetAccessModes
(),
api
.
ReadWriteOnce
)
||
!
contains
(
plug
.
GetAccessModes
(),
api
.
ReadOnlyMany
)
{
if
!
contains
(
plug
.
GetAccessModes
(),
api
.
ReadWriteOnce
)
{
t
.
Errorf
(
"Expected two AccessModeTypes: %s and %s"
,
api
.
ReadWriteOnce
,
api
.
ReadOnlyMany
)
t
.
Errorf
(
"Expected to find AccessMode: %s"
,
api
.
ReadWriteOnce
)
}
if
len
(
plug
.
GetAccessModes
())
!=
1
{
t
.
Errorf
(
"Expected to find exactly one AccessMode"
)
}
}
}
}
...
...
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