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
875ed5f5
Commit
875ed5f5
authored
Jan 29, 2017
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pkg/genericapiserver/registry/rest: cut off pkg/api dependency
parent
a5d5527e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
9 deletions
+8
-9
meta_test.go
pkg/genericapiserver/registry/rest/meta_test.go
+4
-3
rest.go
pkg/genericapiserver/registry/rest/rest.go
+1
-2
update.go
pkg/genericapiserver/registry/rest/update.go
+3
-4
No files found.
pkg/genericapiserver/registry/rest/meta_test.go
View file @
875ed5f5
...
...
@@ -21,8 +21,8 @@ import (
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apiserver/pkg/apis/example"
genericapirequest
"k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/kubernetes/pkg/api"
)
// TestFillObjectMetaSystemFields validates that system populated fields are set on an object
...
...
@@ -62,14 +62,15 @@ func TestHasObjectMetaSystemFieldValues(t *testing.T) {
func
TestValidNamespace
(
t
*
testing
.
T
)
{
ctx
:=
genericapirequest
.
NewDefaultContext
()
namespace
,
_
:=
genericapirequest
.
NamespaceFrom
(
ctx
)
resource
:=
api
.
ReplicationController
{}
// TODO: use some genericapiserver type here instead of clientapiv1
resource
:=
example
.
Pod
{}
if
!
ValidNamespace
(
ctx
,
&
resource
.
ObjectMeta
)
{
t
.
Fatalf
(
"expected success"
)
}
if
namespace
!=
resource
.
Namespace
{
t
.
Fatalf
(
"expected resource to have the default namespace assigned during validation"
)
}
resource
=
api
.
ReplicationController
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Namespace
:
"other"
}}
resource
=
example
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Namespace
:
"other"
}}
if
ValidNamespace
(
ctx
,
&
resource
.
ObjectMeta
)
{
t
.
Fatalf
(
"Expected error that resource and context errors do not match because resource has different namespace"
)
}
...
...
pkg/genericapiserver/registry/rest/rest.go
View file @
875ed5f5
...
...
@@ -27,7 +27,6 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/watch"
genericapirequest
"k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/kubernetes/pkg/api"
)
//TODO:
...
...
@@ -184,7 +183,7 @@ type UpdatedObjectInfo interface {
// Returns preconditions built from the updated object, if applicable.
// May return nil, or a preconditions object containing nil fields,
// if no preconditions can be determined from the updated object.
Preconditions
()
*
api
.
Preconditions
Preconditions
()
*
metav1
.
Preconditions
// UpdatedObject returns the updated object, given a context and old object.
// The only time an empty oldObj should be passed in is if a "create on update" is occurring (there is no oldObj).
...
...
pkg/genericapiserver/registry/rest/update.go
View file @
875ed5f5
...
...
@@ -25,7 +25,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"
genericapirequest
"k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/validation/genericvalidation"
)
...
...
@@ -143,7 +142,7 @@ func DefaultUpdatedObjectInfo(obj runtime.Object, copier runtime.ObjectCopier, t
}
// Preconditions satisfies the UpdatedObjectInfo interface.
func
(
i
*
defaultUpdatedObjectInfo
)
Preconditions
()
*
api
.
Preconditions
{
func
(
i
*
defaultUpdatedObjectInfo
)
Preconditions
()
*
metav1
.
Preconditions
{
// Attempt to get the UID out of the object
accessor
,
err
:=
meta
.
Accessor
(
i
.
obj
)
if
err
!=
nil
{
...
...
@@ -157,7 +156,7 @@ func (i *defaultUpdatedObjectInfo) Preconditions() *api.Preconditions {
return
nil
}
return
&
api
.
Preconditions
{
UID
:
&
uid
}
return
&
metav1
.
Preconditions
{
UID
:
&
uid
}
}
// UpdatedObject satisfies the UpdatedObjectInfo interface.
...
...
@@ -206,7 +205,7 @@ func WrapUpdatedObjectInfo(objInfo UpdatedObjectInfo, transformers ...TransformF
}
// Preconditions satisfies the UpdatedObjectInfo interface.
func
(
i
*
wrappedUpdatedObjectInfo
)
Preconditions
()
*
api
.
Preconditions
{
func
(
i
*
wrappedUpdatedObjectInfo
)
Preconditions
()
*
metav1
.
Preconditions
{
return
i
.
objInfo
.
Preconditions
()
}
...
...
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