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
5914deea
Commit
5914deea
authored
Feb 03, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19380 from brendandburns/apiresource
Auto commit by PR queue bot
parents
d7dd663d
79533385
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
8 deletions
+39
-8
rest.go
pkg/api/rest/rest.go
+8
-0
types.go
pkg/api/unversioned/types.go
+2
-0
types_swagger_doc_generated.go
pkg/api/unversioned/types_swagger_doc_generated.go
+1
-0
api_installer.go
pkg/apiserver/api_installer.go
+12
-1
client_test.go
pkg/client/unversioned/client_test.go
+6
-6
etcd.go
pkg/registry/thirdpartyresourcedata/etcd/etcd.go
+10
-1
No files found.
pkg/api/rest/rest.go
View file @
5914deea
...
...
@@ -55,6 +55,14 @@ type Storage interface {
New
()
runtime
.
Object
}
// KindProvider specifies a different kind for its API than for its internal storage. This is necessary for external
// objects that are not compiled into the api server. For such objects, there is no in-memory representation for
// the object, so they must be represented as generic objects (e.g. RawJSON), but when we present the object as part of
// API discovery we want to present the specific kind, not the generic internal representation.
type
KindProvider
interface
{
Kind
()
string
}
// Lister is an object that can retrieve resources that match the provided field and label criteria.
type
Lister
interface
{
// NewList returns an empty object that can be used with the List call.
...
...
pkg/api/unversioned/types.go
View file @
5914deea
...
...
@@ -339,6 +339,8 @@ type APIResource struct {
Name
string
`json:"name"`
// namespaced indicates if a resource is namespaced or not.
Namespaced
bool
`json:"namespaced"`
// kind is the kind for the resource (e.g. 'Foo' is the kind for a resource 'foo')
Kind
string
`json:"kind"`
}
// APIResourceList is a list of APIResource, it is used to expose the name of the
...
...
pkg/api/unversioned/types_swagger_doc_generated.go
View file @
5914deea
...
...
@@ -51,6 +51,7 @@ var map_APIResource = map[string]string{
""
:
"APIResource specifies the name of a resource and whether it is namespaced."
,
"name"
:
"name is the name of the resource."
,
"namespaced"
:
"namespaced indicates if a resource is namespaced or not."
,
"kind"
:
"kind is the kind for the resource (e.g. 'Foo' is the kind for a resource 'foo')"
,
}
func
(
APIResource
)
SwaggerDoc
()
map
[
string
]
string
{
...
...
pkg/apiserver/api_installer.go
View file @
5914deea
...
...
@@ -152,10 +152,11 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
}
}
kind
:=
fqKindToRegister
.
Kind
if
fqKindToRegister
.
IsEmpty
()
{
return
nil
,
fmt
.
Errorf
(
"unable to locate fully qualified kind for %v: found %v when registering for %v"
,
reflect
.
TypeOf
(
object
),
fqKinds
,
a
.
group
.
GroupVersion
)
}
kind
:=
fqKindToRegister
.
Kind
versionedPtr
,
err
:=
a
.
group
.
Creater
.
New
(
a
.
group
.
GroupVersion
.
WithKind
(
kind
))
if
err
!=
nil
{
...
...
@@ -322,6 +323,14 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
params
:=
[]
*
restful
.
Parameter
{}
actions
:=
[]
action
{}
var
resourceKind
string
kindProvider
,
ok
:=
storage
.
(
rest
.
KindProvider
)
if
ok
{
resourceKind
=
kindProvider
.
Kind
()
}
else
{
resourceKind
=
fqKindToRegister
.
Kind
}
var
apiResource
unversioned
.
APIResource
// Get the list of actions for the given scope.
switch
scope
.
Name
()
{
...
...
@@ -339,6 +348,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
}
apiResource
.
Name
=
path
apiResource
.
Namespaced
=
false
apiResource
.
Kind
=
resourceKind
namer
:=
rootScopeNaming
{
scope
,
a
.
group
.
Linker
,
gpath
.
Join
(
a
.
prefix
,
itemPath
)}
// Handler for standard REST verbs (GET, PUT, POST and DELETE).
...
...
@@ -381,6 +391,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
}
apiResource
.
Name
=
path
apiResource
.
Namespaced
=
true
apiResource
.
Kind
=
resourceKind
namer
:=
scopeNaming
{
scope
,
a
.
group
.
Linker
,
gpath
.
Join
(
a
.
prefix
,
itemPath
),
false
}
actions
=
appendIf
(
actions
,
action
{
"LIST"
,
resourcePath
,
resourceParams
,
namer
},
isLister
)
...
...
pkg/client/unversioned/client_test.go
View file @
5914deea
...
...
@@ -137,17 +137,17 @@ func TestGetServerResources(t *testing.T) {
stable
:=
unversioned
.
APIResourceList
{
GroupVersion
:
"v1"
,
APIResources
:
[]
unversioned
.
APIResource
{
{
"pods"
,
true
},
{
"services"
,
true
},
{
"namespaces"
,
false
},
{
"pods"
,
true
,
"Pod"
},
{
"services"
,
true
,
"Service"
},
{
"namespaces"
,
false
,
"Namespace"
},
},
}
beta
:=
unversioned
.
APIResourceList
{
GroupVersion
:
"extensions/v1"
,
APIResources
:
[]
unversioned
.
APIResource
{
{
"deployments"
,
true
},
{
"ingresses"
,
true
},
{
"jobs"
,
true
},
{
"deployments"
,
true
,
"Deployment"
},
{
"ingresses"
,
true
,
"Ingress"
},
{
"jobs"
,
true
,
"Job"
},
},
}
tests
:=
[]
struct
{
...
...
pkg/registry/thirdpartyresourcedata/etcd/etcd.go
View file @
5914deea
...
...
@@ -33,6 +33,7 @@ import (
// REST implements a RESTStorage for ThirdPartyResourceDatas against etcd
type
REST
struct
{
*
etcdgeneric
.
Etcd
kind
string
}
// NewREST returns a registry which will store ThirdPartyResourceData in the given helper
...
...
@@ -64,5 +65,13 @@ func NewREST(s storage.Interface, storageDecorator generic.StorageDecorator, gro
Storage
:
storageInterface
,
}
return
&
REST
{
store
}
return
&
REST
{
Etcd
:
store
,
kind
:
kind
,
}
}
// Implements the rest.KindProvider interface
func
(
r
*
REST
)
Kind
()
string
{
return
r
.
kind
}
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