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
ff86ae07
Commit
ff86ae07
authored
Apr 01, 2015
by
markturansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed RESTCreate/Update interface methods
parent
69d1d235
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
27 deletions
+21
-27
etcd.go
pkg/registry/persistentvolume/etcd/etcd.go
+1
-1
rest.go
pkg/registry/persistentvolume/rest.go
+13
-4
etcd.go
pkg/registry/persistentvolumeclaim/etcd/etcd.go
+1
-1
rest.go
pkg/registry/persistentvolumeclaim/rest.go
+6
-21
No files found.
pkg/registry/persistentvolume/etcd/etcd.go
View file @
ff86ae07
...
...
@@ -56,7 +56,7 @@ func NewStorage(h tools.EtcdHelper) (*REST, *StatusREST) {
}
store
.
CreateStrategy
=
persistentvolume
.
Strategy
store
.
UpdateStrategy
=
persistentvolume
.
St
atusSt
rategy
store
.
UpdateStrategy
=
persistentvolume
.
Strategy
store
.
ReturnDeletedObject
=
true
statusStore
:=
*
store
...
...
pkg/registry/persistentvolume/rest.go
View file @
ff86ae07
...
...
@@ -38,34 +38,43 @@ type persistentvolumeStrategy struct {
// objects via the REST API.
var
Strategy
=
persistentvolumeStrategy
{
api
.
Scheme
,
api
.
SimpleNameGenerator
}
// NamespaceScoped is false for persistentvolumes.
func
(
persistentvolumeStrategy
)
NamespaceScoped
()
bool
{
return
false
}
// ResetBeforeCreate clears
fields that are
not allowed to be set by end users on creation.
// ResetBeforeCreate clears
the Status field which is
not allowed to be set by end users on creation.
func
(
persistentvolumeStrategy
)
PrepareForCreate
(
obj
runtime
.
Object
)
{
pv
:=
obj
.
(
*
api
.
PersistentVolume
)
pv
.
Status
=
api
.
PersistentVolumeStatus
{}
}
// Validate validates a new persistentvolume.
func
(
persistentvolumeStrategy
)
Validate
(
ctx
api
.
Context
,
obj
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
persistentvolume
:=
obj
.
(
*
api
.
PersistentVolume
)
return
validation
.
ValidatePersistentVolume
(
persistentvolume
)
}
// AllowCreateOnUpdate is false for persistentvolumes.
func
(
persistentvolumeStrategy
)
AllowCreateOnUpdate
()
bool
{
return
false
}
// PrepareForUpdate sets the Status fields which is not allowed to be set by an end user updating a PV
func
(
persistentvolumeStrategy
)
PrepareForUpdate
(
obj
,
old
runtime
.
Object
)
{
newPv
:=
obj
.
(
*
api
.
PersistentVolume
)
oldPv
:=
obj
.
(
*
api
.
PersistentVolume
)
newPv
.
Status
=
oldPv
.
Status
}
func
(
persistentvolumeStrategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
return
validation
.
ValidatePersistentVolumeUpdate
(
obj
.
(
*
api
.
PersistentVolume
),
old
.
(
*
api
.
PersistentVolume
))
}
type
persistentvolumeStatusStrategy
struct
{
persistentvolumeStrategy
}
var
StatusStrategy
=
persistentvolumeStatusStrategy
{
Strategy
}
// PrepareForUpdate sets the Spec field which is not allowed to be changed when updating a PV's Status
func
(
persistentvolumeStatusStrategy
)
PrepareForUpdate
(
obj
,
old
runtime
.
Object
)
{
newPv
:=
obj
.
(
*
api
.
PersistentVolume
)
oldPv
:=
obj
.
(
*
api
.
PersistentVolume
)
...
...
pkg/registry/persistentvolumeclaim/etcd/etcd.go
View file @
ff86ae07
...
...
@@ -56,7 +56,7 @@ func NewStorage(h tools.EtcdHelper) *REST {
}
store
.
CreateStrategy
=
persistentvolumeclaim
.
Strategy
store
.
UpdateStrategy
=
persistentvolumeclaim
.
St
atusSt
rategy
store
.
UpdateStrategy
=
persistentvolumeclaim
.
Strategy
store
.
ReturnDeletedObject
=
true
return
&
REST
{
store
}
...
...
pkg/registry/persistentvolumeclaim/rest.go
View file @
ff86ae07
...
...
@@ -38,49 +38,34 @@ type persistentvolumeclaimStrategy struct {
// objects via the REST API.
var
Strategy
=
persistentvolumeclaimStrategy
{
api
.
Scheme
,
api
.
SimpleNameGenerator
}
// NamespaceScoped is true for persistentvolumeclaims.
func
(
persistentvolumeclaimStrategy
)
NamespaceScoped
()
bool
{
return
true
}
//
ResetBeforeCreate clears fields that are
not allowed to be set by end users on creation.
//
PrepareForCreate clears the Status field which is
not allowed to be set by end users on creation.
func
(
persistentvolumeclaimStrategy
)
PrepareForCreate
(
obj
runtime
.
Object
)
{
pv
:=
obj
.
(
*
api
.
PersistentVolumeClaim
)
pv
.
Status
=
api
.
PersistentVolumeClaimStatus
{}
}
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func
(
persistentvolumeclaimStrategy
)
PrepareForUpdate
(
obj
,
old
runtime
.
Object
)
{
newPvc
:=
obj
.
(
*
api
.
PersistentVolumeClaim
)
oldPvc
:=
obj
.
(
*
api
.
PersistentVolumeClaim
)
newPvc
.
Status
=
oldPvc
.
Status
}
// Validate validates a new persistentvolumeclaim.
func
(
persistentvolumeclaimStrategy
)
Validate
(
ctx
api
.
Context
,
obj
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
pvc
:=
obj
.
(
*
api
.
PersistentVolumeClaim
)
return
validation
.
ValidatePersistentVolumeClaim
(
pvc
)
}
// AllowCreateOnUpdate is false for persistentvolumeclaims.
func
(
persistentvolumeclaimStrategy
)
AllowCreateOnUpdate
()
bool
{
return
false
}
type
persistentvolumeclaimStatusStrategy
struct
{
persistentvolumeclaimStrategy
}
var
StatusStrategy
=
persistentvolumeclaimStatusStrategy
{
Strategy
}
func
(
persistentvolumeclaimStatusStrategy
)
PrepareForUpdate
(
obj
,
old
runtime
.
Object
)
{
// PrepareForUpdate sets the Status field which is not allowed to be set by end users on update
func
(
persistentvolumeclaimStrategy
)
PrepareForUpdate
(
obj
,
old
runtime
.
Object
)
{
newPvc
:=
obj
.
(
*
api
.
PersistentVolumeClaim
)
oldPvc
:=
obj
.
(
*
api
.
PersistentVolumeClaim
)
newPvc
.
S
pec
=
oldPvc
.
Spec
newPvc
.
S
tatus
=
oldPvc
.
Status
}
func
(
persistentvolumeclaimSt
atusSt
rategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
return
validation
.
ValidatePersistentVolumeClaim
Status
Update
(
obj
.
(
*
api
.
PersistentVolumeClaim
),
old
.
(
*
api
.
PersistentVolumeClaim
))
func
(
persistentvolumeclaimStrategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
return
validation
.
ValidatePersistentVolumeClaimUpdate
(
obj
.
(
*
api
.
PersistentVolumeClaim
),
old
.
(
*
api
.
PersistentVolumeClaim
))
}
// MatchPersistentVolumeClaim returns a generic matcher for a given label and field selector.
...
...
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