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
72da3b44
Commit
72da3b44
authored
Feb 11, 2015
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move rest.Pods to pkg/registry/pod/rest.go
parent
7a93af57
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
45 deletions
+47
-45
create_test.go
pkg/api/rest/create_test.go
+3
-3
types.go
pkg/api/rest/types.go
+0
-40
etcd.go
pkg/registry/pod/etcd/etcd.go
+2
-2
rest.go
pkg/registry/pod/rest.go
+42
-0
No files found.
pkg/api/rest/create_test.go
View file @
72da3b44
...
@@ -25,17 +25,17 @@ import (
...
@@ -25,17 +25,17 @@ import (
func
TestCheckGeneratedNameError
(
t
*
testing
.
T
)
{
func
TestCheckGeneratedNameError
(
t
*
testing
.
T
)
{
expect
:=
errors
.
NewNotFound
(
"foo"
,
"bar"
)
expect
:=
errors
.
NewNotFound
(
"foo"
,
"bar"
)
if
err
:=
CheckGeneratedNameError
(
Pod
s
,
expect
,
&
api
.
Pod
{});
err
!=
expect
{
if
err
:=
CheckGeneratedNameError
(
Service
s
,
expect
,
&
api
.
Pod
{});
err
!=
expect
{
t
.
Errorf
(
"NotFoundError should be ignored: %v"
,
err
)
t
.
Errorf
(
"NotFoundError should be ignored: %v"
,
err
)
}
}
expect
=
errors
.
NewAlreadyExists
(
"foo"
,
"bar"
)
expect
=
errors
.
NewAlreadyExists
(
"foo"
,
"bar"
)
if
err
:=
CheckGeneratedNameError
(
Pod
s
,
expect
,
&
api
.
Pod
{});
err
!=
expect
{
if
err
:=
CheckGeneratedNameError
(
Service
s
,
expect
,
&
api
.
Pod
{});
err
!=
expect
{
t
.
Errorf
(
"AlreadyExists should be returned when no GenerateName field: %v"
,
err
)
t
.
Errorf
(
"AlreadyExists should be returned when no GenerateName field: %v"
,
err
)
}
}
expect
=
errors
.
NewAlreadyExists
(
"foo"
,
"bar"
)
expect
=
errors
.
NewAlreadyExists
(
"foo"
,
"bar"
)
if
err
:=
CheckGeneratedNameError
(
Pod
s
,
expect
,
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
GenerateName
:
"foo"
}});
err
==
nil
||
!
errors
.
IsServerTimeout
(
err
)
{
if
err
:=
CheckGeneratedNameError
(
Service
s
,
expect
,
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
GenerateName
:
"foo"
}});
err
==
nil
||
!
errors
.
IsServerTimeout
(
err
)
{
t
.
Errorf
(
"expected try again later error: %v"
,
err
)
t
.
Errorf
(
"expected try again later error: %v"
,
err
)
}
}
}
}
pkg/api/rest/types.go
View file @
72da3b44
...
@@ -72,46 +72,6 @@ func (rcStrategy) Validate(obj runtime.Object) errors.ValidationErrorList {
...
@@ -72,46 +72,6 @@ func (rcStrategy) Validate(obj runtime.Object) errors.ValidationErrorList {
return
validation
.
ValidateReplicationController
(
controller
)
return
validation
.
ValidateReplicationController
(
controller
)
}
}
// podStrategy implements behavior for Pods
// TODO: move to a pod specific package.
type
podStrategy
struct
{
runtime
.
ObjectTyper
api
.
NameGenerator
}
// Pods is the default logic that applies when creating and updating Pod
// objects.
var
Pods
=
podStrategy
{
api
.
Scheme
,
api
.
SimpleNameGenerator
}
// NamespaceScoped is true for pods.
func
(
podStrategy
)
NamespaceScoped
()
bool
{
return
true
}
// ResetBeforeCreate clears fields that are not allowed to be set by end users on creation.
func
(
podStrategy
)
ResetBeforeCreate
(
obj
runtime
.
Object
)
{
pod
:=
obj
.
(
*
api
.
Pod
)
pod
.
Status
=
api
.
PodStatus
{
Phase
:
api
.
PodPending
,
}
}
// Validate validates a new pod.
func
(
podStrategy
)
Validate
(
obj
runtime
.
Object
)
errors
.
ValidationErrorList
{
pod
:=
obj
.
(
*
api
.
Pod
)
return
validation
.
ValidatePod
(
pod
)
}
// AllowCreateOnUpdate is false for pods.
func
(
podStrategy
)
AllowCreateOnUpdate
()
bool
{
return
false
}
// ValidateUpdate is the default update validation for an end user.
func
(
podStrategy
)
ValidateUpdate
(
obj
,
old
runtime
.
Object
)
errors
.
ValidationErrorList
{
return
validation
.
ValidatePodUpdate
(
obj
.
(
*
api
.
Pod
),
old
.
(
*
api
.
Pod
))
}
// svcStrategy implements behavior for Services
// svcStrategy implements behavior for Services
// TODO: move to a service specific package.
// TODO: move to a service specific package.
type
svcStrategy
struct
{
type
svcStrategy
struct
{
...
...
pkg/registry/pod/etcd/etcd.go
View file @
72da3b44
...
@@ -56,9 +56,9 @@ func NewREST(h tools.EtcdHelper, factory pod.BoundPodFactory) (*REST, *BindingRE
...
@@ -56,9 +56,9 @@ func NewREST(h tools.EtcdHelper, factory pod.BoundPodFactory) (*REST, *BindingRE
},
},
EndpointName
:
"pods"
,
EndpointName
:
"pods"
,
CreateStrategy
:
rest
.
Pods
,
CreateStrategy
:
pod
.
Strategy
,
UpdateStrategy
:
rest
.
Pods
,
UpdateStrategy
:
pod
.
Strategy
,
AfterUpdate
:
bindings
.
AfterUpdate
,
AfterUpdate
:
bindings
.
AfterUpdate
,
ReturnDeletedObject
:
true
,
ReturnDeletedObject
:
true
,
...
...
pkg/registry/pod/rest.go
View file @
72da3b44
...
@@ -24,11 +24,53 @@ import (
...
@@ -24,11 +24,53 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/rest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/rest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/generic"
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/generic"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
)
)
// podStrategy implements behavior for Pods
// TODO: move to a pod specific package.
type
podStrategy
struct
{
runtime
.
ObjectTyper
api
.
NameGenerator
}
// Strategy is the default logic that applies when creating and updating Pod
// objects via the REST API.
// TODO: Create other strategies for updating status, bindings, etc
var
Strategy
=
podStrategy
{
api
.
Scheme
,
api
.
SimpleNameGenerator
}
// NamespaceScoped is true for pods.
func
(
podStrategy
)
NamespaceScoped
()
bool
{
return
true
}
// ResetBeforeCreate clears fields that are not allowed to be set by end users on creation.
func
(
podStrategy
)
ResetBeforeCreate
(
obj
runtime
.
Object
)
{
pod
:=
obj
.
(
*
api
.
Pod
)
pod
.
Status
=
api
.
PodStatus
{
Phase
:
api
.
PodPending
,
}
}
// Validate validates a new pod.
func
(
podStrategy
)
Validate
(
obj
runtime
.
Object
)
errors
.
ValidationErrorList
{
pod
:=
obj
.
(
*
api
.
Pod
)
return
validation
.
ValidatePod
(
pod
)
}
// AllowCreateOnUpdate is false for pods.
func
(
podStrategy
)
AllowCreateOnUpdate
()
bool
{
return
false
}
// ValidateUpdate is the default update validation for an end user.
func
(
podStrategy
)
ValidateUpdate
(
obj
,
old
runtime
.
Object
)
errors
.
ValidationErrorList
{
return
validation
.
ValidatePodUpdate
(
obj
.
(
*
api
.
Pod
),
old
.
(
*
api
.
Pod
))
}
// PodStatusGetter is an interface used by Pods to fetch and retrieve status info.
// PodStatusGetter is an interface used by Pods to fetch and retrieve status info.
type
PodStatusGetter
interface
{
type
PodStatusGetter
interface
{
GetPodStatus
(
namespace
,
name
string
)
(
*
api
.
PodStatus
,
error
)
GetPodStatus
(
namespace
,
name
string
)
(
*
api
.
PodStatus
,
error
)
...
...
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