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
e443277d
Commit
e443277d
authored
Apr 14, 2017
by
NickrenREN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Define const annotation variable once
Move annotation to package imported by both pkg/volume and pkg/volume/validation
parent
5dd91438
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
17 additions
and
10 deletions
+17
-10
types.go
pkg/api/types.go
+3
-0
types.go
pkg/api/v1/types.go
+3
-0
plugins.go
pkg/volume/plugins.go
+0
-2
util.go
pkg/volume/util.go
+1
-1
util_test.go
pkg/volume/util_test.go
+1
-1
pv_validation.go
pkg/volume/validation/pv_validation.go
+2
-5
pv_validation_test.go
pkg/volume/validation/pv_validation_test.go
+1
-1
types.go
staging/src/k8s.io/client-go/pkg/api/types.go
+3
-0
types.go
staging/src/k8s.io/client-go/pkg/api/v1/types.go
+3
-0
No files found.
pkg/api/types.go
View file @
e443277d
...
@@ -385,6 +385,9 @@ const (
...
@@ -385,6 +385,9 @@ const (
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
// It's currently still used and will be held for backwards compatibility
// It's currently still used and will be held for backwards compatibility
BetaStorageClassAnnotation
=
"volume.beta.kubernetes.io/storage-class"
BetaStorageClassAnnotation
=
"volume.beta.kubernetes.io/storage-class"
// MountOptionAnnotation defines mount option annotation used in PVs
MountOptionAnnotation
=
"volume.beta.kubernetes.io/mount-options"
)
)
// +genclient=true
// +genclient=true
...
...
pkg/api/v1/types.go
View file @
e443277d
...
@@ -434,6 +434,9 @@ const (
...
@@ -434,6 +434,9 @@ const (
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
// It's currently still used and will be held for backwards compatibility
// It's currently still used and will be held for backwards compatibility
BetaStorageClassAnnotation
=
"volume.beta.kubernetes.io/storage-class"
BetaStorageClassAnnotation
=
"volume.beta.kubernetes.io/storage-class"
// MountOptionAnnotation defines mount option annotation used in PVs
MountOptionAnnotation
=
"volume.beta.kubernetes.io/mount-options"
)
)
// +genclient=true
// +genclient=true
...
...
pkg/volume/plugins.go
View file @
e443277d
...
@@ -156,8 +156,6 @@ const (
...
@@ -156,8 +156,6 @@ const (
// Name of a volume in external cloud that is being provisioned and thus
// Name of a volume in external cloud that is being provisioned and thus
// should be ignored by rest of Kubernetes.
// should be ignored by rest of Kubernetes.
ProvisionedVolumeName
=
"placeholder-for-provisioning"
ProvisionedVolumeName
=
"placeholder-for-provisioning"
// Mount options annotations
MountOptionAnnotation
=
"volume.beta.kubernetes.io/mount-options"
)
)
// ProvisionableVolumePlugin is an extended interface of VolumePlugin and is
// ProvisionableVolumePlugin is an extended interface of VolumePlugin and is
...
...
pkg/volume/util.go
View file @
e443277d
...
@@ -386,7 +386,7 @@ func MountOptionFromSpec(spec *Spec, options ...string) []string {
...
@@ -386,7 +386,7 @@ func MountOptionFromSpec(spec *Spec, options ...string) []string {
pv
:=
spec
.
PersistentVolume
pv
:=
spec
.
PersistentVolume
if
pv
!=
nil
{
if
pv
!=
nil
{
if
mo
,
ok
:=
pv
.
Annotations
[
MountOptionAnnotation
];
ok
{
if
mo
,
ok
:=
pv
.
Annotations
[
v1
.
MountOptionAnnotation
];
ok
{
moList
:=
strings
.
Split
(
mo
,
","
)
moList
:=
strings
.
Split
(
mo
,
","
)
return
JoinMountOptions
(
moList
,
options
)
return
JoinMountOptions
(
moList
,
options
)
}
}
...
...
pkg/volume/util_test.go
View file @
e443277d
...
@@ -362,7 +362,7 @@ func TestMountOptionFromSpec(t *testing.T) {
...
@@ -362,7 +362,7 @@ func TestMountOptionFromSpec(t *testing.T) {
func
createVolumeSpecWithMountOption
(
name
string
,
mountOptions
string
,
spec
v1
.
PersistentVolumeSpec
)
*
Spec
{
func
createVolumeSpecWithMountOption
(
name
string
,
mountOptions
string
,
spec
v1
.
PersistentVolumeSpec
)
*
Spec
{
annotations
:=
map
[
string
]
string
{
annotations
:=
map
[
string
]
string
{
MountOptionAnnotation
:
mountOptions
,
v1
.
MountOptionAnnotation
:
mountOptions
,
}
}
objMeta
:=
metav1
.
ObjectMeta
{
objMeta
:=
metav1
.
ObjectMeta
{
Name
:
name
,
Name
:
name
,
...
...
pkg/volume/validation/pv_validation.go
View file @
e443277d
...
@@ -21,9 +21,6 @@ import (
...
@@ -21,9 +21,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
)
)
// MountOptionAnnotation defines mount option annotation used in PVs
const
MountOptionAnnotation
=
"volume.beta.kubernetes.io/mount-options"
// ValidatePersistentVolume validates PV object for plugin specific validation
// ValidatePersistentVolume validates PV object for plugin specific validation
// We can put here validations which are specific to volume types.
// We can put here validations which are specific to volume types.
func
ValidatePersistentVolume
(
pv
*
api
.
PersistentVolume
)
field
.
ErrorList
{
func
ValidatePersistentVolume
(
pv
*
api
.
PersistentVolume
)
field
.
ErrorList
{
...
@@ -50,9 +47,9 @@ func checkMountOption(pv *api.PersistentVolume) field.ErrorList {
...
@@ -50,9 +47,9 @@ func checkMountOption(pv *api.PersistentVolume) field.ErrorList {
return
allErrs
return
allErrs
}
}
// any other type if mount option is present lets return error
// any other type if mount option is present lets return error
if
_
,
ok
:=
pv
.
Annotations
[
MountOptionAnnotation
];
ok
{
if
_
,
ok
:=
pv
.
Annotations
[
api
.
MountOptionAnnotation
];
ok
{
metaField
:=
field
.
NewPath
(
"metadata"
)
metaField
:=
field
.
NewPath
(
"metadata"
)
allErrs
=
append
(
allErrs
,
field
.
Forbidden
(
metaField
.
Child
(
"annotations"
,
MountOptionAnnotation
),
"may not specify mount options for this volume type"
))
allErrs
=
append
(
allErrs
,
field
.
Forbidden
(
metaField
.
Child
(
"annotations"
,
api
.
MountOptionAnnotation
),
"may not specify mount options for this volume type"
))
}
}
return
allErrs
return
allErrs
}
}
pkg/volume/validation/pv_validation_test.go
View file @
e443277d
...
@@ -68,7 +68,7 @@ func TestValidatePersistentVolumes(t *testing.T) {
...
@@ -68,7 +68,7 @@ func TestValidatePersistentVolumes(t *testing.T) {
func
testVolumeWithMountOption
(
name
string
,
namespace
string
,
mountOptions
string
,
spec
api
.
PersistentVolumeSpec
)
*
api
.
PersistentVolume
{
func
testVolumeWithMountOption
(
name
string
,
namespace
string
,
mountOptions
string
,
spec
api
.
PersistentVolumeSpec
)
*
api
.
PersistentVolume
{
annotations
:=
map
[
string
]
string
{
annotations
:=
map
[
string
]
string
{
MountOptionAnnotation
:
mountOptions
,
api
.
MountOptionAnnotation
:
mountOptions
,
}
}
objMeta
:=
metav1
.
ObjectMeta
{
objMeta
:=
metav1
.
ObjectMeta
{
Name
:
name
,
Name
:
name
,
...
...
staging/src/k8s.io/client-go/pkg/api/types.go
View file @
e443277d
...
@@ -385,6 +385,9 @@ const (
...
@@ -385,6 +385,9 @@ const (
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
// It's currently still used and will be held for backwards compatibility
// It's currently still used and will be held for backwards compatibility
BetaStorageClassAnnotation
=
"volume.beta.kubernetes.io/storage-class"
BetaStorageClassAnnotation
=
"volume.beta.kubernetes.io/storage-class"
// MountOptionAnnotation defines mount option annotation used in PVs
MountOptionAnnotation
=
"volume.beta.kubernetes.io/mount-options"
)
)
// +genclient=true
// +genclient=true
...
...
staging/src/k8s.io/client-go/pkg/api/v1/types.go
View file @
e443277d
...
@@ -434,6 +434,9 @@ const (
...
@@ -434,6 +434,9 @@ const (
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
// It's currently still used and will be held for backwards compatibility
// It's currently still used and will be held for backwards compatibility
BetaStorageClassAnnotation
=
"volume.beta.kubernetes.io/storage-class"
BetaStorageClassAnnotation
=
"volume.beta.kubernetes.io/storage-class"
// MountOptionAnnotation defines mount option annotation used in PVs
MountOptionAnnotation
=
"volume.beta.kubernetes.io/mount-options"
)
)
// +genclient=true
// +genclient=true
...
...
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