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
fae13eee
Commit
fae13eee
authored
May 14, 2017
by
zhangxiaoyu-zidif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename vars scheduledJob to cronJob
parent
4807e6ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
25 deletions
+25
-25
strategy.go
pkg/registry/batch/cronjob/strategy.go
+25
-25
No files found.
pkg/registry/batch/cronjob/strategy.go
View file @
fae13eee
...
...
@@ -33,91 +33,91 @@ import (
"k8s.io/kubernetes/pkg/apis/batch/validation"
)
//
scheduled
JobStrategy implements verification logic for Replication Controllers.
type
scheduled
JobStrategy
struct
{
//
cron
JobStrategy implements verification logic for Replication Controllers.
type
cron
JobStrategy
struct
{
runtime
.
ObjectTyper
names
.
NameGenerator
}
// Strategy is the default logic that applies when creating and updating CronJob objects.
var
Strategy
=
scheduled
JobStrategy
{
api
.
Scheme
,
names
.
SimpleNameGenerator
}
var
Strategy
=
cron
JobStrategy
{
api
.
Scheme
,
names
.
SimpleNameGenerator
}
// DefaultGarbageCollectionPolicy returns Orphan because that was the default
// behavior before the server-side garbage collection was implemented.
func
(
scheduled
JobStrategy
)
DefaultGarbageCollectionPolicy
()
rest
.
GarbageCollectionPolicy
{
func
(
cron
JobStrategy
)
DefaultGarbageCollectionPolicy
()
rest
.
GarbageCollectionPolicy
{
return
rest
.
OrphanDependents
}
// NamespaceScoped returns true because all scheduled jobs need to be within a namespace.
func
(
scheduled
JobStrategy
)
NamespaceScoped
()
bool
{
func
(
cron
JobStrategy
)
NamespaceScoped
()
bool
{
return
true
}
// PrepareForCreate clears the status of a scheduled job before creation.
func
(
scheduled
JobStrategy
)
PrepareForCreate
(
ctx
genericapirequest
.
Context
,
obj
runtime
.
Object
)
{
scheduled
Job
:=
obj
.
(
*
batch
.
CronJob
)
scheduled
Job
.
Status
=
batch
.
CronJobStatus
{}
func
(
cron
JobStrategy
)
PrepareForCreate
(
ctx
genericapirequest
.
Context
,
obj
runtime
.
Object
)
{
cron
Job
:=
obj
.
(
*
batch
.
CronJob
)
cron
Job
.
Status
=
batch
.
CronJobStatus
{}
}
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func
(
scheduled
JobStrategy
)
PrepareForUpdate
(
ctx
genericapirequest
.
Context
,
obj
,
old
runtime
.
Object
)
{
func
(
cron
JobStrategy
)
PrepareForUpdate
(
ctx
genericapirequest
.
Context
,
obj
,
old
runtime
.
Object
)
{
newCronJob
:=
obj
.
(
*
batch
.
CronJob
)
oldCronJob
:=
old
.
(
*
batch
.
CronJob
)
newCronJob
.
Status
=
oldCronJob
.
Status
}
// Validate validates a new scheduled job.
func
(
scheduled
JobStrategy
)
Validate
(
ctx
genericapirequest
.
Context
,
obj
runtime
.
Object
)
field
.
ErrorList
{
scheduled
Job
:=
obj
.
(
*
batch
.
CronJob
)
return
validation
.
ValidateCronJob
(
scheduled
Job
)
func
(
cron
JobStrategy
)
Validate
(
ctx
genericapirequest
.
Context
,
obj
runtime
.
Object
)
field
.
ErrorList
{
cron
Job
:=
obj
.
(
*
batch
.
CronJob
)
return
validation
.
ValidateCronJob
(
cron
Job
)
}
// Canonicalize normalizes the object after validation.
func
(
scheduled
JobStrategy
)
Canonicalize
(
obj
runtime
.
Object
)
{
func
(
cron
JobStrategy
)
Canonicalize
(
obj
runtime
.
Object
)
{
}
func
(
scheduled
JobStrategy
)
AllowUnconditionalUpdate
()
bool
{
func
(
cron
JobStrategy
)
AllowUnconditionalUpdate
()
bool
{
return
true
}
// AllowCreateOnUpdate is false for scheduled jobs; this means a POST is needed to create one.
func
(
scheduled
JobStrategy
)
AllowCreateOnUpdate
()
bool
{
func
(
cron
JobStrategy
)
AllowCreateOnUpdate
()
bool
{
return
false
}
// ValidateUpdate is the default update validation for an end user.
func
(
scheduled
JobStrategy
)
ValidateUpdate
(
ctx
genericapirequest
.
Context
,
obj
,
old
runtime
.
Object
)
field
.
ErrorList
{
func
(
cron
JobStrategy
)
ValidateUpdate
(
ctx
genericapirequest
.
Context
,
obj
,
old
runtime
.
Object
)
field
.
ErrorList
{
return
validation
.
ValidateCronJob
(
obj
.
(
*
batch
.
CronJob
))
}
type
scheduled
JobStatusStrategy
struct
{
scheduled
JobStrategy
type
cron
JobStatusStrategy
struct
{
cron
JobStrategy
}
var
StatusStrategy
=
scheduled
JobStatusStrategy
{
Strategy
}
var
StatusStrategy
=
cron
JobStatusStrategy
{
Strategy
}
func
(
scheduled
JobStatusStrategy
)
PrepareForUpdate
(
ctx
genericapirequest
.
Context
,
obj
,
old
runtime
.
Object
)
{
func
(
cron
JobStatusStrategy
)
PrepareForUpdate
(
ctx
genericapirequest
.
Context
,
obj
,
old
runtime
.
Object
)
{
newJob
:=
obj
.
(
*
batch
.
CronJob
)
oldJob
:=
old
.
(
*
batch
.
CronJob
)
newJob
.
Spec
=
oldJob
.
Spec
}
func
(
scheduled
JobStatusStrategy
)
ValidateUpdate
(
ctx
genericapirequest
.
Context
,
obj
,
old
runtime
.
Object
)
field
.
ErrorList
{
func
(
cron
JobStatusStrategy
)
ValidateUpdate
(
ctx
genericapirequest
.
Context
,
obj
,
old
runtime
.
Object
)
field
.
ErrorList
{
return
field
.
ErrorList
{}
}
// CronJobToSelectableFields returns a field set that represents the object for matching purposes.
func
CronJobToSelectableFields
(
scheduled
Job
*
batch
.
CronJob
)
fields
.
Set
{
return
generic
.
ObjectMetaFieldsSet
(
&
scheduled
Job
.
ObjectMeta
,
true
)
func
CronJobToSelectableFields
(
cron
Job
*
batch
.
CronJob
)
fields
.
Set
{
return
generic
.
ObjectMetaFieldsSet
(
&
cron
Job
.
ObjectMeta
,
true
)
}
// GetAttrs returns labels and fields of a given object for filtering purposes.
func
GetAttrs
(
obj
runtime
.
Object
)
(
labels
.
Set
,
fields
.
Set
,
error
)
{
scheduled
Job
,
ok
:=
obj
.
(
*
batch
.
CronJob
)
cron
Job
,
ok
:=
obj
.
(
*
batch
.
CronJob
)
if
!
ok
{
return
nil
,
nil
,
fmt
.
Errorf
(
"Given object is not a scheduled job."
)
}
return
labels
.
Set
(
scheduledJob
.
ObjectMeta
.
Labels
),
CronJobToSelectableFields
(
scheduled
Job
),
nil
return
labels
.
Set
(
cronJob
.
ObjectMeta
.
Labels
),
CronJobToSelectableFields
(
cron
Job
),
nil
}
// MatchCronJob is the filter used by the generic etcd backend to route
...
...
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