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
fdea7252
Commit
fdea7252
authored
Mar 04, 2015
by
Tim Hockin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5001 from brendandburns/api3
Embed VolumeSource in v1beta3 and internal.
parents
3891ad1b
fb90b56b
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
122 additions
and
96 deletions
+122
-96
cassandra-controller.yaml
examples/cassandra/v1beta3/cassandra-controller.yaml
+1
-2
mysql.yaml
examples/mysql-wordpress-pd/v1beta3/mysql.yaml
+4
-6
wordpress.yaml
examples/mysql-wordpress-pd/v1beta3/wordpress.yaml
+4
-6
types.go
pkg/api/types.go
+2
-2
conversion.go
pkg/api/v1beta1/conversion.go
+15
-0
conversion.go
pkg/api/v1beta2/conversion.go
+16
-0
defaults.go
pkg/api/v1beta3/defaults.go
+2
-2
defaults_test.go
pkg/api/v1beta3/defaults_test.go
+1
-1
types.go
pkg/api/v1beta3/types.go
+1
-1
validation.go
pkg/api/validation/validation.go
+3
-3
validation_test.go
pkg/api/validation/validation_test.go
+22
-22
helpers_test.go
pkg/kubectl/cmd/util/helpers_test.go
+4
-4
file_test.go
pkg/kubelet/config/file_test.go
+1
-1
kubelet_test.go
pkg/kubelet/kubelet_test.go
+2
-2
empty_dir.go
pkg/kubelet/volume/empty_dir/empty_dir.go
+2
-2
empty_dir_test.go
pkg/kubelet/volume/empty_dir/empty_dir_test.go
+6
-6
gce_pd.go
pkg/kubelet/volume/gce_pd/gce_pd.go
+6
-6
gce_pd_test.go
pkg/kubelet/volume/gce_pd/gce_pd_test.go
+4
-4
git_repo.go
pkg/kubelet/volume/git_repo/git_repo.go
+3
-3
git_repo_test.go
pkg/kubelet/volume/git_repo/git_repo_test.go
+4
-4
host_path.go
pkg/kubelet/volume/host_path/host_path.go
+2
-2
host_path_test.go
pkg/kubelet/volume/host_path/host_path_test.go
+4
-4
secret.go
pkg/kubelet/volume/secret/secret.go
+2
-2
secret_test.go
pkg/kubelet/volume/secret/secret_test.go
+2
-2
predicates.go
pkg/scheduler/predicates.go
+4
-4
predicates_test.go
pkg/scheduler/predicates_test.go
+2
-2
pd.go
test/e2e/pd.go
+1
-1
secrets.go
test/e2e/secrets.go
+1
-1
service.go
test/e2e/service.go
+1
-1
No files found.
examples/cassandra/v1beta3/cassandra-controller.yaml
View file @
fdea7252
...
...
@@ -38,6 +38,5 @@ spec:
name
:
data
volumes
:
-
name
:
data
source
:
emptyDir
:
{}
emptyDir
:
{}
examples/mysql-wordpress-pd/v1beta3/mysql.yaml
View file @
fdea7252
...
...
@@ -33,10 +33,8 @@ spec:
mountPath
:
/var/lib/mysql
volumes
:
-
name
:
mysql-persistent-storage
source
:
# emptyDir: {}
persistentDisk
:
# This GCE PD must already exist.
pdName
:
mysql-disk
fsType
:
ext4
persistentDisk
:
# This GCE PD must already exist.
pdName
:
mysql-disk
fsType
:
ext4
examples/mysql-wordpress-pd/v1beta3/wordpress.yaml
View file @
fdea7252
...
...
@@ -30,10 +30,8 @@ spec:
mountPath
:
/var/www/html
volumes
:
-
name
:
wordpress-persistent-storage
source
:
# emptyDir: {}
persistentDisk
:
# This GCE PD must already exist.
pdName
:
wordpress-disk
fsType
:
ext4
persistentDisk
:
# This GCE PD must already exist.
pdName
:
wordpress-disk
fsType
:
ext4
pkg/api/types.go
View file @
fdea7252
...
...
@@ -155,10 +155,10 @@ type Volume struct {
// Required: This must be a DNS_LABEL. Each volume in a pod must have
// a unique name.
Name
string
`json:"name"`
// Source represents the location and type of a volume to mount.
//
The Volume
Source represents the location and type of a volume to mount.
// This is optional for now. If not specified, the Volume is implied to be an EmptyDir.
// This implied behavior is deprecated and will be removed in a future version.
Source
VolumeSource
`json:"sourc
e,omitempty"`
VolumeSource
`json:"inlin
e,omitempty"`
}
// VolumeSource represents the source location of a volume to mount.
...
...
pkg/api/v1beta1/conversion.go
View file @
fdea7252
...
...
@@ -1016,6 +1016,21 @@ func init() {
return
nil
},
func
(
in
*
newer
.
Volume
,
out
*
Volume
,
s
conversion
.
Scope
)
error
{
if
err
:=
s
.
Convert
(
&
in
.
VolumeSource
,
&
out
.
Source
,
0
);
err
!=
nil
{
return
err
}
out
.
Name
=
in
.
Name
return
nil
},
func
(
in
*
Volume
,
out
*
newer
.
Volume
,
s
conversion
.
Scope
)
error
{
if
err
:=
s
.
Convert
(
&
in
.
Source
,
&
out
.
VolumeSource
,
0
);
err
!=
nil
{
return
err
}
out
.
Name
=
in
.
Name
return
nil
},
// VolumeSource's HostDir is deprecated in favor of HostPath.
// TODO: It would be great if I could just map field names to
// convert or else maybe say "convert all members of this
...
...
pkg/api/v1beta2/conversion.go
View file @
fdea7252
...
...
@@ -935,6 +935,22 @@ func init() {
}
return
nil
},
func
(
in
*
newer
.
Volume
,
out
*
Volume
,
s
conversion
.
Scope
)
error
{
if
err
:=
s
.
Convert
(
&
in
.
VolumeSource
,
&
out
.
Source
,
0
);
err
!=
nil
{
return
err
}
out
.
Name
=
in
.
Name
return
nil
},
func
(
in
*
Volume
,
out
*
newer
.
Volume
,
s
conversion
.
Scope
)
error
{
if
err
:=
s
.
Convert
(
&
in
.
Source
,
&
out
.
VolumeSource
,
0
);
err
!=
nil
{
return
err
}
out
.
Name
=
in
.
Name
return
nil
},
func
(
in
*
newer
.
VolumeSource
,
out
*
VolumeSource
,
s
conversion
.
Scope
)
error
{
if
err
:=
s
.
Convert
(
&
in
.
EmptyDir
,
&
out
.
EmptyDir
,
0
);
err
!=
nil
{
return
err
...
...
pkg/api/v1beta3/defaults.go
View file @
fdea7252
...
...
@@ -26,8 +26,8 @@ import (
func
init
()
{
api
.
Scheme
.
AddDefaultingFuncs
(
func
(
obj
*
Volume
)
{
if
util
.
AllPtrFieldsNil
(
&
obj
.
Source
)
{
obj
.
Source
=
VolumeSource
{
if
util
.
AllPtrFieldsNil
(
&
obj
.
Volume
Source
)
{
obj
.
Volume
Source
=
VolumeSource
{
EmptyDir
:
&
EmptyDirVolumeSource
{},
}
}
...
...
pkg/api/v1beta3/defaults_test.go
View file @
fdea7252
...
...
@@ -65,7 +65,7 @@ func TestSetDefaulPodSpec(t *testing.T) {
if
policy
.
Never
!=
nil
||
policy
.
OnFailure
!=
nil
||
policy
.
Always
==
nil
{
t
.
Errorf
(
"Expected only policy.Always is set, got: %s"
,
policy
)
}
vsource
:=
bp2
.
Spec
.
Volumes
[
0
]
.
Source
vsource
:=
bp2
.
Spec
.
Volumes
[
0
]
.
Volume
Source
if
vsource
.
EmptyDir
==
nil
{
t
.
Errorf
(
"Expected non-empty volume is set, got: %s"
,
vsource
.
EmptyDir
)
}
...
...
pkg/api/v1beta3/types.go
View file @
fdea7252
...
...
@@ -177,7 +177,7 @@ type Volume struct {
// Source represents the location and type of a volume to mount.
// This is optional for now. If not specified, the Volume is implied to be an EmptyDir.
// This implied behavior is deprecated and will be removed in a future version.
Source
VolumeSource
`json:"sourc
e,omitempty"`
VolumeSource
`json:"inlin
e,omitempty"`
}
// VolumeSource represents the source location of a valume to mount.
...
...
pkg/api/validation/validation.go
View file @
fdea7252
...
...
@@ -233,7 +233,7 @@ func validateVolumes(volumes []api.Volume) (util.StringSet, errs.ValidationError
allNames
:=
util
.
StringSet
{}
for
i
,
vol
:=
range
volumes
{
el
:=
validateSource
(
&
vol
.
Source
)
.
Prefix
(
"source"
)
el
:=
validateSource
(
&
vol
.
Volume
Source
)
.
Prefix
(
"source"
)
if
len
(
vol
.
Name
)
==
0
{
el
=
append
(
el
,
errs
.
NewFieldRequired
(
"name"
,
vol
.
Name
))
}
else
if
!
util
.
IsDNSLabel
(
vol
.
Name
)
{
...
...
@@ -793,8 +793,8 @@ func ValidatePodTemplateSpec(spec *api.PodTemplateSpec, replicas int) errs.Valid
func
ValidateReadOnlyPersistentDisks
(
volumes
[]
api
.
Volume
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
for
_
,
vol
:=
range
volumes
{
if
vol
.
Source
.
GCEPersistentDisk
!=
nil
{
if
vol
.
Source
.
GCEPersistentDisk
.
ReadOnly
==
false
{
if
vol
.
GCEPersistentDisk
!=
nil
{
if
vol
.
GCEPersistentDisk
.
ReadOnly
==
false
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"GCEPersistentDisk.ReadOnly"
,
false
,
"ReadOnly must be true for replicated pods > 1, as GCE PD can only be mounted on multiple machines if it is read-only."
))
}
}
...
...
pkg/api/validation/validation_test.go
View file @
fdea7252
...
...
@@ -147,13 +147,13 @@ func TestValidateAnnotations(t *testing.T) {
func
TestValidateVolumes
(
t
*
testing
.
T
)
{
successCase
:=
[]
api
.
Volume
{
{
Name
:
"abc"
,
Source
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/mnt/path1"
}}},
{
Name
:
"123"
,
Source
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/mnt/path2"
}}},
{
Name
:
"abc-123"
,
Source
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/mnt/path3"
}}},
{
Name
:
"empty"
,
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}},
{
Name
:
"gcepd"
,
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{
"my-PD"
,
"ext4"
,
1
,
false
}}},
{
Name
:
"gitrepo"
,
Source
:
api
.
VolumeSource
{
GitRepo
:
&
api
.
GitRepoVolumeSource
{
"my-repo"
,
"hashstring"
}}},
{
Name
:
"secret"
,
Source
:
api
.
VolumeSource
{
Secret
:
&
api
.
SecretVolumeSource
{
api
.
ObjectReference
{
Namespace
:
api
.
NamespaceDefault
,
Name
:
"my-secret"
,
Kind
:
"Secret"
}}}},
{
Name
:
"abc"
,
Volume
Source
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/mnt/path1"
}}},
{
Name
:
"123"
,
Volume
Source
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/mnt/path2"
}}},
{
Name
:
"abc-123"
,
Volume
Source
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/mnt/path3"
}}},
{
Name
:
"empty"
,
Volume
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}},
{
Name
:
"gcepd"
,
Volume
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{
"my-PD"
,
"ext4"
,
1
,
false
}}},
{
Name
:
"gitrepo"
,
Volume
Source
:
api
.
VolumeSource
{
GitRepo
:
&
api
.
GitRepoVolumeSource
{
"my-repo"
,
"hashstring"
}}},
{
Name
:
"secret"
,
Volume
Source
:
api
.
VolumeSource
{
Secret
:
&
api
.
SecretVolumeSource
{
api
.
ObjectReference
{
Namespace
:
api
.
NamespaceDefault
,
Name
:
"my-secret"
,
Kind
:
"Secret"
}}}},
}
names
,
errs
:=
validateVolumes
(
successCase
)
if
len
(
errs
)
!=
0
{
...
...
@@ -168,10 +168,10 @@ func TestValidateVolumes(t *testing.T) {
T
errors
.
ValidationErrorType
F
string
}{
"zero-length name"
:
{[]
api
.
Volume
{{
Name
:
""
,
Source
:
emptyVS
}},
errors
.
ValidationErrorTypeRequired
,
"[0].name"
},
"name > 63 characters"
:
{[]
api
.
Volume
{{
Name
:
strings
.
Repeat
(
"a"
,
64
),
Source
:
emptyVS
}},
errors
.
ValidationErrorTypeInvalid
,
"[0].name"
},
"name not a DNS label"
:
{[]
api
.
Volume
{{
Name
:
"a.b.c"
,
Source
:
emptyVS
}},
errors
.
ValidationErrorTypeInvalid
,
"[0].name"
},
"name not unique"
:
{[]
api
.
Volume
{{
Name
:
"abc"
,
Source
:
emptyVS
},
{
Name
:
"abc"
,
Source
:
emptyVS
}},
errors
.
ValidationErrorTypeDuplicate
,
"[1].name"
},
"zero-length name"
:
{[]
api
.
Volume
{{
Name
:
""
,
Volume
Source
:
emptyVS
}},
errors
.
ValidationErrorTypeRequired
,
"[0].name"
},
"name > 63 characters"
:
{[]
api
.
Volume
{{
Name
:
strings
.
Repeat
(
"a"
,
64
),
Volume
Source
:
emptyVS
}},
errors
.
ValidationErrorTypeInvalid
,
"[0].name"
},
"name not a DNS label"
:
{[]
api
.
Volume
{{
Name
:
"a.b.c"
,
Volume
Source
:
emptyVS
}},
errors
.
ValidationErrorTypeInvalid
,
"[0].name"
},
"name not unique"
:
{[]
api
.
Volume
{{
Name
:
"abc"
,
VolumeSource
:
emptyVS
},
{
Name
:
"abc"
,
Volume
Source
:
emptyVS
}},
errors
.
ValidationErrorTypeDuplicate
,
"[1].name"
},
}
for
k
,
v
:=
range
errorCases
{
_
,
errs
:=
validateVolumes
(
v
.
V
)
...
...
@@ -648,8 +648,8 @@ func TestValidateManifest(t *testing.T) {
{
Version
:
"v1beta1"
,
ID
:
"abc"
,
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol1"
,
Source
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/mnt/vol1"
}}},
{
Name
:
"vol2"
,
Source
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/mnt/vol2"
}}}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol1"
,
Volume
Source
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/mnt/vol1"
}}},
{
Name
:
"vol2"
,
Volume
Source
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/mnt/vol2"
}}}},
Containers
:
[]
api
.
Container
{
{
Name
:
"abc"
,
...
...
@@ -699,7 +699,7 @@ func TestValidateManifest(t *testing.T) {
"invalid volume name"
:
{
Version
:
"v1beta1"
,
ID
:
"abc"
,
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol.1"
,
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol.1"
,
Volume
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}},
RestartPolicy
:
api
.
RestartPolicy
{
Always
:
&
api
.
RestartPolicyAlways
{}},
DNSPolicy
:
api
.
DNSClusterFirst
,
},
...
...
@@ -722,14 +722,14 @@ func TestValidateManifest(t *testing.T) {
func
TestValidatePodSpec
(
t
*
testing
.
T
)
{
successCases
:=
[]
api
.
PodSpec
{
{
// Populate basic fields, leave defaults for most.
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
,
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
,
Volume
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
ImagePullPolicy
:
"IfNotPresent"
}},
RestartPolicy
:
api
.
RestartPolicy
{
Always
:
&
api
.
RestartPolicyAlways
{}},
DNSPolicy
:
api
.
DNSClusterFirst
,
},
{
// Populate all fields.
Volumes
:
[]
api
.
Volume
{
{
Name
:
"vol"
,
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}},
{
Name
:
"vol"
,
Volume
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}},
},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
ImagePullPolicy
:
"IfNotPresent"
}},
RestartPolicy
:
api
.
RestartPolicy
{
Always
:
&
api
.
RestartPolicyAlways
{}},
...
...
@@ -778,7 +778,7 @@ func TestValidatePod(t *testing.T) {
{
// Basic fields.
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
"ns"
},
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
,
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
,
Volume
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
ImagePullPolicy
:
"IfNotPresent"
}},
RestartPolicy
:
api
.
RestartPolicy
{
Always
:
&
api
.
RestartPolicyAlways
{}},
DNSPolicy
:
api
.
DNSClusterFirst
,
...
...
@@ -788,7 +788,7 @@ func TestValidatePod(t *testing.T) {
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc.123.do-re-mi"
,
Namespace
:
"ns"
},
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{
{
Name
:
"vol"
,
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}},
{
Name
:
"vol"
,
Volume
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}},
},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
ImagePullPolicy
:
"IfNotPresent"
}},
RestartPolicy
:
api
.
RestartPolicy
{
Always
:
&
api
.
RestartPolicyAlways
{}},
...
...
@@ -1080,7 +1080,7 @@ func TestValidateBoundPods(t *testing.T) {
{
// Basic fields.
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"123"
,
Namespace
:
"ns"
},
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
,
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
,
Volume
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
ImagePullPolicy
:
"IfNotPresent"
}},
RestartPolicy
:
api
.
RestartPolicy
{
Always
:
&
api
.
RestartPolicyAlways
{}},
DNSPolicy
:
api
.
DNSClusterFirst
,
...
...
@@ -1090,7 +1090,7 @@ func TestValidateBoundPods(t *testing.T) {
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc.123.do-re-mi"
,
Namespace
:
"ns"
},
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{
{
Name
:
"vol"
,
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}},
{
Name
:
"vol"
,
Volume
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}},
},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
ImagePullPolicy
:
"IfNotPresent"
}},
RestartPolicy
:
api
.
RestartPolicy
{
Always
:
&
api
.
RestartPolicyAlways
{}},
...
...
@@ -1552,7 +1552,7 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
Spec
:
api
.
PodSpec
{
RestartPolicy
:
api
.
RestartPolicy
{
Always
:
&
api
.
RestartPolicyAlways
{}},
DNSPolicy
:
api
.
DNSClusterFirst
,
Volumes
:
[]
api
.
Volume
{{
Name
:
"gcepd"
,
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{
"my-PD"
,
"ext4"
,
1
,
false
}}}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"gcepd"
,
Volume
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{
"my-PD"
,
"ext4"
,
1
,
false
}}}},
},
},
}
...
...
@@ -1710,7 +1710,7 @@ func TestValidateReplicationController(t *testing.T) {
Labels
:
validSelector
,
},
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{{
Name
:
"gcepd"
,
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{
"my-PD"
,
"ext4"
,
1
,
false
}}}},
Volumes
:
[]
api
.
Volume
{{
Name
:
"gcepd"
,
Volume
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{
"my-PD"
,
"ext4"
,
1
,
false
}}}},
RestartPolicy
:
api
.
RestartPolicy
{
Always
:
&
api
.
RestartPolicyAlways
{}},
DNSPolicy
:
api
.
DNSClusterFirst
,
},
...
...
pkg/kubectl/cmd/util/helpers_test.go
View file @
fdea7252
...
...
@@ -88,12 +88,12 @@ func TestMerge(t *testing.T) {
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{
{
Name
:
"v1"
,
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}},
Name
:
"v1"
,
Volume
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}},
},
{
Name
:
"v2"
,
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}},
Name
:
"v2"
,
Volume
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}},
},
},
RestartPolicy
:
api
.
RestartPolicy
{
...
...
pkg/kubelet/config/file_test.go
View file @
fdea7252
...
...
@@ -67,7 +67,7 @@ func ExampleManifestAndPod(id string) (v1beta1.ContainerManifest, api.BoundPod)
Volumes
:
[]
api
.
Volume
{
{
Name
:
"host-dir"
,
Source
:
api
.
VolumeSource
{
Volume
Source
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/dir/path"
},
},
},
...
...
pkg/kubelet/kubelet_test.go
View file @
fdea7252
...
...
@@ -1018,8 +1018,8 @@ func TestMountExternalVolumes(t *testing.T) {
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{
{
Name
:
"vol1"
,
Source
:
api
.
VolumeSource
{},
Name
:
"vol1"
,
Volume
Source
:
api
.
VolumeSource
{},
},
},
},
...
...
pkg/kubelet/volume/empty_dir/empty_dir.go
View file @
fdea7252
...
...
@@ -60,10 +60,10 @@ func (plugin *emptyDirPlugin) CanSupport(spec *api.Volume) bool {
return
false
}
if
util
.
AllPtrFieldsNil
(
&
spec
.
Source
)
{
if
util
.
AllPtrFieldsNil
(
&
spec
.
Volume
Source
)
{
return
true
}
if
spec
.
Source
.
EmptyDir
!=
nil
{
if
spec
.
EmptyDir
!=
nil
{
return
true
}
return
false
...
...
pkg/kubelet/volume/empty_dir/empty_dir_test.go
View file @
fdea7252
...
...
@@ -36,10 +36,10 @@ func TestCanSupport(t *testing.T) {
if
plug
.
Name
()
!=
"kubernetes.io/empty-dir"
{
t
.
Errorf
(
"Wrong name: %s"
,
plug
.
Name
())
}
if
!
plug
.
CanSupport
(
&
api
.
Volume
{
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}})
{
if
!
plug
.
CanSupport
(
&
api
.
Volume
{
Volume
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}})
{
t
.
Errorf
(
"Expected true"
)
}
if
!
plug
.
CanSupport
(
&
api
.
Volume
{
Source
:
api
.
VolumeSource
{}})
{
if
!
plug
.
CanSupport
(
&
api
.
Volume
{
Volume
Source
:
api
.
VolumeSource
{}})
{
t
.
Errorf
(
"Expected true"
)
}
}
...
...
@@ -53,8 +53,8 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"Can't find the plugin by name"
)
}
spec
:=
&
api
.
Volume
{
Name
:
"vol1"
,
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}},
Name
:
"vol1"
,
Volume
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}},
}
builder
,
err
:=
plug
.
NewBuilder
(
spec
,
types
.
UID
(
"poduid"
))
if
err
!=
nil
{
...
...
@@ -134,11 +134,11 @@ func TestPluginLegacy(t *testing.T) {
if
plug
.
Name
()
!=
"empty"
{
t
.
Errorf
(
"Wrong name: %s"
,
plug
.
Name
())
}
if
plug
.
CanSupport
(
&
api
.
Volume
{
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}})
{
if
plug
.
CanSupport
(
&
api
.
Volume
{
Volume
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}})
{
t
.
Errorf
(
"Expected false"
)
}
if
_
,
err
:=
plug
.
NewBuilder
(
&
api
.
Volume
{
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}},
types
.
UID
(
"poduid"
));
err
==
nil
{
if
_
,
err
:=
plug
.
NewBuilder
(
&
api
.
Volume
{
Volume
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}},
types
.
UID
(
"poduid"
));
err
==
nil
{
t
.
Errorf
(
"Expected failiure"
)
}
...
...
pkg/kubelet/volume/gce_pd/gce_pd.go
View file @
fdea7252
...
...
@@ -64,7 +64,7 @@ func (plugin *gcePersistentDiskPlugin) CanSupport(spec *api.Volume) bool {
return
false
}
if
spec
.
Source
.
GCEPersistentDisk
!=
nil
{
if
spec
.
GCEPersistentDisk
!=
nil
{
return
true
}
return
false
...
...
@@ -81,13 +81,13 @@ func (plugin *gcePersistentDiskPlugin) newBuilderInternal(spec *api.Volume, podU
return
nil
,
fmt
.
Errorf
(
"legacy mode: can not create new instances"
)
}
pdName
:=
spec
.
Source
.
GCEPersistentDisk
.
PDName
fsType
:=
spec
.
Source
.
GCEPersistentDisk
.
FSType
pdName
:=
spec
.
GCEPersistentDisk
.
PDName
fsType
:=
spec
.
GCEPersistentDisk
.
FSType
partition
:=
""
if
spec
.
Source
.
GCEPersistentDisk
.
Partition
!=
0
{
partition
=
strconv
.
Itoa
(
spec
.
Source
.
GCEPersistentDisk
.
Partition
)
if
spec
.
GCEPersistentDisk
.
Partition
!=
0
{
partition
=
strconv
.
Itoa
(
spec
.
GCEPersistentDisk
.
Partition
)
}
readOnly
:=
spec
.
Source
.
GCEPersistentDisk
.
ReadOnly
readOnly
:=
spec
.
GCEPersistentDisk
.
ReadOnly
return
&
gcePersistentDisk
{
podUID
:
podUID
,
...
...
pkg/kubelet/volume/gce_pd/gce_pd_test.go
View file @
fdea7252
...
...
@@ -36,7 +36,7 @@ func TestCanSupport(t *testing.T) {
if
plug
.
Name
()
!=
"kubernetes.io/gce-pd"
{
t
.
Errorf
(
"Wrong name: %s"
,
plug
.
Name
())
}
if
!
plug
.
CanSupport
(
&
api
.
Volume
{
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{}}})
{
if
!
plug
.
CanSupport
(
&
api
.
Volume
{
Volume
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{}}})
{
t
.
Errorf
(
"Expected true"
)
}
}
...
...
@@ -73,7 +73,7 @@ func TestPlugin(t *testing.T) {
}
spec
:=
&
api
.
Volume
{
Name
:
"vol1"
,
Source
:
api
.
VolumeSource
{
Volume
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{
PDName
:
"pd"
,
FSType
:
"ext4"
,
...
...
@@ -140,11 +140,11 @@ func TestPluginLegacy(t *testing.T) {
if
plug
.
Name
()
!=
"gce-pd"
{
t
.
Errorf
(
"Wrong name: %s"
,
plug
.
Name
())
}
if
plug
.
CanSupport
(
&
api
.
Volume
{
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{}}})
{
if
plug
.
CanSupport
(
&
api
.
Volume
{
Volume
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{}}})
{
t
.
Errorf
(
"Expected false"
)
}
if
_
,
err
:=
plug
.
NewBuilder
(
&
api
.
Volume
{
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{}}},
types
.
UID
(
"poduid"
));
err
==
nil
{
if
_
,
err
:=
plug
.
NewBuilder
(
&
api
.
Volume
{
Volume
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{}}},
types
.
UID
(
"poduid"
));
err
==
nil
{
t
.
Errorf
(
"Expected failiure"
)
}
...
...
pkg/kubelet/volume/git_repo/git_repo.go
View file @
fdea7252
...
...
@@ -63,7 +63,7 @@ func (plugin *gitRepoPlugin) CanSupport(spec *api.Volume) bool {
return
false
}
if
spec
.
Source
.
GitRepo
!=
nil
{
if
spec
.
GitRepo
!=
nil
{
return
true
}
return
false
...
...
@@ -77,8 +77,8 @@ func (plugin *gitRepoPlugin) NewBuilder(spec *api.Volume, podUID types.UID) (vol
return
&
gitRepo
{
podUID
:
podUID
,
volName
:
spec
.
Name
,
source
:
spec
.
Source
.
GitRepo
.
Repository
,
revision
:
spec
.
Source
.
GitRepo
.
Revision
,
source
:
spec
.
GitRepo
.
Repository
,
revision
:
spec
.
GitRepo
.
Revision
,
exec
:
exec
.
New
(),
plugin
:
plugin
,
legacyMode
:
false
,
...
...
pkg/kubelet/volume/git_repo/git_repo_test.go
View file @
fdea7252
...
...
@@ -49,7 +49,7 @@ func TestCanSupport(t *testing.T) {
if
plug
.
Name
()
!=
"kubernetes.io/git-repo"
{
t
.
Errorf
(
"Wrong name: %s"
,
plug
.
Name
())
}
if
!
plug
.
CanSupport
(
&
api
.
Volume
{
Source
:
api
.
VolumeSource
{
GitRepo
:
&
api
.
GitRepoVolumeSource
{}}})
{
if
!
plug
.
CanSupport
(
&
api
.
Volume
{
Volume
Source
:
api
.
VolumeSource
{
GitRepo
:
&
api
.
GitRepoVolumeSource
{}}})
{
t
.
Errorf
(
"Expected true"
)
}
}
...
...
@@ -110,7 +110,7 @@ func TestPlugin(t *testing.T) {
}
spec
:=
&
api
.
Volume
{
Name
:
"vol1"
,
Source
:
api
.
VolumeSource
{
Volume
Source
:
api
.
VolumeSource
{
GitRepo
:
&
api
.
GitRepoVolumeSource
{
Repository
:
"https://github.com/GoogleCloudPlatform/kubernetes.git"
,
Revision
:
"2a30ce65c5ab586b98916d83385c5983edd353a1"
,
...
...
@@ -168,11 +168,11 @@ func TestPluginLegacy(t *testing.T) {
if
plug
.
Name
()
!=
"git"
{
t
.
Errorf
(
"Wrong name: %s"
,
plug
.
Name
())
}
if
plug
.
CanSupport
(
&
api
.
Volume
{
Source
:
api
.
VolumeSource
{
GitRepo
:
&
api
.
GitRepoVolumeSource
{}}})
{
if
plug
.
CanSupport
(
&
api
.
Volume
{
Volume
Source
:
api
.
VolumeSource
{
GitRepo
:
&
api
.
GitRepoVolumeSource
{}}})
{
t
.
Errorf
(
"Expected false"
)
}
if
_
,
err
:=
plug
.
NewBuilder
(
&
api
.
Volume
{
Source
:
api
.
VolumeSource
{
GitRepo
:
&
api
.
GitRepoVolumeSource
{}}},
types
.
UID
(
"poduid"
));
err
==
nil
{
if
_
,
err
:=
plug
.
NewBuilder
(
&
api
.
Volume
{
Volume
Source
:
api
.
VolumeSource
{
GitRepo
:
&
api
.
GitRepoVolumeSource
{}}},
types
.
UID
(
"poduid"
));
err
==
nil
{
t
.
Errorf
(
"Expected failiure"
)
}
...
...
pkg/kubelet/volume/host_path/host_path.go
View file @
fdea7252
...
...
@@ -46,14 +46,14 @@ func (plugin *hostPathPlugin) Name() string {
}
func
(
plugin
*
hostPathPlugin
)
CanSupport
(
spec
*
api
.
Volume
)
bool
{
if
spec
.
Source
.
HostPath
!=
nil
{
if
spec
.
HostPath
!=
nil
{
return
true
}
return
false
}
func
(
plugin
*
hostPathPlugin
)
NewBuilder
(
spec
*
api
.
Volume
,
podUID
types
.
UID
)
(
volume
.
Builder
,
error
)
{
return
&
hostPath
{
spec
.
Source
.
HostPath
.
Path
},
nil
return
&
hostPath
{
spec
.
HostPath
.
Path
},
nil
}
func
(
plugin
*
hostPathPlugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Cleaner
,
error
)
{
...
...
pkg/kubelet/volume/host_path/host_path_test.go
View file @
fdea7252
...
...
@@ -35,10 +35,10 @@ func TestCanSupport(t *testing.T) {
if
plug
.
Name
()
!=
"kubernetes.io/host-path"
{
t
.
Errorf
(
"Wrong name: %s"
,
plug
.
Name
())
}
if
!
plug
.
CanSupport
(
&
api
.
Volume
{
Source
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{}}})
{
if
!
plug
.
CanSupport
(
&
api
.
Volume
{
Volume
Source
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{}}})
{
t
.
Errorf
(
"Expected true"
)
}
if
plug
.
CanSupport
(
&
api
.
Volume
{
Source
:
api
.
VolumeSource
{}})
{
if
plug
.
CanSupport
(
&
api
.
Volume
{
Volume
Source
:
api
.
VolumeSource
{}})
{
t
.
Errorf
(
"Expected false"
)
}
}
...
...
@@ -52,8 +52,8 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"Can't find the plugin by name"
)
}
spec
:=
&
api
.
Volume
{
Name
:
"vol1"
,
Source
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/vol1"
}},
Name
:
"vol1"
,
Volume
Source
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
"/vol1"
}},
}
builder
,
err
:=
plug
.
NewBuilder
(
spec
,
types
.
UID
(
"poduid"
))
if
err
!=
nil
{
...
...
pkg/kubelet/volume/secret/secret.go
View file @
fdea7252
...
...
@@ -51,7 +51,7 @@ func (plugin *secretPlugin) Name() string {
}
func
(
plugin
*
secretPlugin
)
CanSupport
(
spec
*
api
.
Volume
)
bool
{
if
spec
.
S
ource
.
S
ecret
!=
nil
{
if
spec
.
Secret
!=
nil
{
return
true
}
...
...
@@ -63,7 +63,7 @@ func (plugin *secretPlugin) NewBuilder(spec *api.Volume, podUID types.UID) (volu
}
func
(
plugin
*
secretPlugin
)
newBuilderInternal
(
spec
*
api
.
Volume
,
podUID
types
.
UID
)
(
volume
.
Builder
,
error
)
{
return
&
secretVolume
{
spec
.
Name
,
podUID
,
plugin
,
&
spec
.
S
ource
.
S
ecret
.
Target
},
nil
return
&
secretVolume
{
spec
.
Name
,
podUID
,
plugin
,
&
spec
.
Secret
.
Target
},
nil
}
func
(
plugin
*
secretPlugin
)
NewCleaner
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Cleaner
,
error
)
{
...
...
pkg/kubelet/volume/secret/secret_test.go
View file @
fdea7252
...
...
@@ -50,7 +50,7 @@ func TestCanSupport(t *testing.T) {
if
plugin
.
Name
()
!=
secretPluginName
{
t
.
Errorf
(
"Wrong name: %s"
,
plugin
.
Name
())
}
if
!
plugin
.
CanSupport
(
&
api
.
Volume
{
Source
:
api
.
VolumeSource
{
Secret
:
&
api
.
SecretVolumeSource
{
Target
:
api
.
ObjectReference
{}}}})
{
if
!
plugin
.
CanSupport
(
&
api
.
Volume
{
Volume
Source
:
api
.
VolumeSource
{
Secret
:
&
api
.
SecretVolumeSource
{
Target
:
api
.
ObjectReference
{}}}})
{
t
.
Errorf
(
"Expected true"
)
}
}
...
...
@@ -65,7 +65,7 @@ func TestPlugin(t *testing.T) {
volumeSpec
:=
&
api
.
Volume
{
Name
:
testVolumeName
,
Source
:
api
.
VolumeSource
{
Volume
Source
:
api
.
VolumeSource
{
Secret
:
&
api
.
SecretVolumeSource
{
Target
:
api
.
ObjectReference
{
Namespace
:
testNamespace
,
...
...
pkg/scheduler/predicates.go
View file @
fdea7252
...
...
@@ -51,15 +51,15 @@ func (nodes ClientNodeInfo) GetNodeInfo(nodeID string) (*api.Node, error) {
}
func
isVolumeConflict
(
volume
api
.
Volume
,
pod
*
api
.
Pod
)
bool
{
if
volume
.
Source
.
GCEPersistentDisk
==
nil
{
if
volume
.
GCEPersistentDisk
==
nil
{
return
false
}
pdName
:=
volume
.
Source
.
GCEPersistentDisk
.
PDName
pdName
:=
volume
.
GCEPersistentDisk
.
PDName
manifest
:=
&
(
pod
.
Spec
)
for
ix
:=
range
manifest
.
Volumes
{
if
manifest
.
Volumes
[
ix
]
.
Source
.
GCEPersistentDisk
!=
nil
&&
manifest
.
Volumes
[
ix
]
.
Source
.
GCEPersistentDisk
.
PDName
==
pdName
{
if
manifest
.
Volumes
[
ix
]
.
GCEPersistentDisk
!=
nil
&&
manifest
.
Volumes
[
ix
]
.
GCEPersistentDisk
.
PDName
==
pdName
{
return
true
}
}
...
...
pkg/scheduler/predicates_test.go
View file @
fdea7252
...
...
@@ -276,7 +276,7 @@ func TestDiskConflicts(t *testing.T) {
volState
:=
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{
{
Source
:
api
.
VolumeSource
{
Volume
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{
PDName
:
"foo"
,
},
...
...
@@ -287,7 +287,7 @@ func TestDiskConflicts(t *testing.T) {
volState2
:=
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{
{
Source
:
api
.
VolumeSource
{
Volume
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{
PDName
:
"bar"
,
},
...
...
test/e2e/pd.go
View file @
fdea7252
...
...
@@ -192,7 +192,7 @@ func testPDPod(diskName, targetHost string, readOnly bool) *api.Pod {
Volumes
:
[]
api
.
Volume
{
{
Name
:
"testpd"
,
Source
:
api
.
VolumeSource
{
Volume
Source
:
api
.
VolumeSource
{
GCEPersistentDisk
:
&
api
.
GCEPersistentDiskVolumeSource
{
PDName
:
diskName
,
FSType
:
"ext4"
,
...
...
test/e2e/secrets.go
View file @
fdea7252
...
...
@@ -79,7 +79,7 @@ var _ = Describe("Secrets", func() {
Volumes
:
[]
api
.
Volume
{
{
Name
:
volumeName
,
Source
:
api
.
VolumeSource
{
Volume
Source
:
api
.
VolumeSource
{
Secret
:
&
api
.
SecretVolumeSource
{
Target
:
api
.
ObjectReference
{
Kind
:
"Secret"
,
...
...
test/e2e/service.go
View file @
fdea7252
...
...
@@ -75,7 +75,7 @@ var _ = Describe("Services", func() {
Volumes
:
[]
api
.
Volume
{
{
Name
:
"results"
,
Source
:
api
.
VolumeSource
{
Volume
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{},
},
},
...
...
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