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
ed03973a
Commit
ed03973a
authored
Jun 26, 2015
by
Robert Bailey
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10269 from nikhiljindal/eventsErrors
Returning api/errors from event/rest.go
parents
8ee63307
7b56d89e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
rest.go
pkg/registry/event/rest.go
+8
-7
No files found.
pkg/registry/event/rest.go
View file @
ed03973a
...
@@ -45,7 +45,7 @@ func NewStorage(registry generic.Registry) *REST {
...
@@ -45,7 +45,7 @@ func NewStorage(registry generic.Registry) *REST {
func
(
rs
*
REST
)
Create
(
ctx
api
.
Context
,
obj
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
func
(
rs
*
REST
)
Create
(
ctx
api
.
Context
,
obj
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
event
,
ok
:=
obj
.
(
*
api
.
Event
)
event
,
ok
:=
obj
.
(
*
api
.
Event
)
if
!
ok
{
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"invalid object type"
)
return
nil
,
errors
.
NewInternalError
(
fmt
.
Errorf
(
"received object is not of type event: %#v"
,
obj
)
)
}
}
if
api
.
NamespaceValue
(
ctx
)
!=
""
{
if
api
.
NamespaceValue
(
ctx
)
!=
""
{
if
!
api
.
ValidNamespace
(
ctx
,
&
event
.
ObjectMeta
)
{
if
!
api
.
ValidNamespace
(
ctx
,
&
event
.
ObjectMeta
)
{
...
@@ -68,7 +68,8 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (runtime.Object, err
...
@@ -68,7 +68,8 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (runtime.Object, err
func
(
rs
*
REST
)
Update
(
ctx
api
.
Context
,
obj
runtime
.
Object
)
(
runtime
.
Object
,
bool
,
error
)
{
func
(
rs
*
REST
)
Update
(
ctx
api
.
Context
,
obj
runtime
.
Object
)
(
runtime
.
Object
,
bool
,
error
)
{
event
,
ok
:=
obj
.
(
*
api
.
Event
)
event
,
ok
:=
obj
.
(
*
api
.
Event
)
if
!
ok
{
if
!
ok
{
return
nil
,
false
,
fmt
.
Errorf
(
"not an event object: %#v"
,
obj
)
return
nil
,
false
,
errors
.
NewInternalError
(
fmt
.
Errorf
(
"received object is not of type event: %#v"
,
obj
))
}
}
if
api
.
NamespaceValue
(
ctx
)
!=
""
{
if
api
.
NamespaceValue
(
ctx
)
!=
""
{
if
!
api
.
ValidNamespace
(
ctx
,
&
event
.
ObjectMeta
)
{
if
!
api
.
ValidNamespace
(
ctx
,
&
event
.
ObjectMeta
)
{
...
@@ -95,19 +96,19 @@ func (rs *REST) Delete(ctx api.Context, name string) (runtime.Object, error) {
...
@@ -95,19 +96,19 @@ func (rs *REST) Delete(ctx api.Context, name string) (runtime.Object, error) {
}
}
_
,
ok
:=
obj
.
(
*
api
.
Event
)
_
,
ok
:=
obj
.
(
*
api
.
Event
)
if
!
ok
{
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"invalid object type"
)
return
nil
,
errors
.
NewInternalError
(
fmt
.
Errorf
(
"stored object %s is not of type event: %#v"
,
name
,
obj
)
)
}
}
return
rs
.
registry
.
Delete
(
ctx
,
name
,
nil
)
return
rs
.
registry
.
Delete
(
ctx
,
name
,
nil
)
}
}
func
(
rs
*
REST
)
Get
(
ctx
api
.
Context
,
id
string
)
(
runtime
.
Object
,
error
)
{
func
(
rs
*
REST
)
Get
(
ctx
api
.
Context
,
name
string
)
(
runtime
.
Object
,
error
)
{
obj
,
err
:=
rs
.
registry
.
Get
(
ctx
,
id
)
obj
,
err
:=
rs
.
registry
.
Get
(
ctx
,
name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
event
,
ok
:=
obj
.
(
*
api
.
Event
)
event
,
ok
:=
obj
.
(
*
api
.
Event
)
if
!
ok
{
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"invalid object type"
)
return
nil
,
errors
.
NewInternalError
(
fmt
.
Errorf
(
"stored object %s is not of type event: %#v"
,
name
,
obj
)
)
}
}
return
event
,
err
return
event
,
err
}
}
...
@@ -115,7 +116,7 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) {
...
@@ -115,7 +116,7 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) {
func
(
rs
*
REST
)
getAttrs
(
obj
runtime
.
Object
)
(
objLabels
labels
.
Set
,
objFields
fields
.
Set
,
err
error
)
{
func
(
rs
*
REST
)
getAttrs
(
obj
runtime
.
Object
)
(
objLabels
labels
.
Set
,
objFields
fields
.
Set
,
err
error
)
{
event
,
ok
:=
obj
.
(
*
api
.
Event
)
event
,
ok
:=
obj
.
(
*
api
.
Event
)
if
!
ok
{
if
!
ok
{
return
nil
,
nil
,
fmt
.
Errorf
(
"invalid object type"
)
return
nil
,
nil
,
errors
.
NewInternalError
(
fmt
.
Errorf
(
"object is not of type event: %#v"
,
obj
)
)
}
}
l
:=
event
.
Labels
l
:=
event
.
Labels
if
l
==
nil
{
if
l
==
nil
{
...
...
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