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
e3d984be
Commit
e3d984be
authored
Oct 08, 2015
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
run grep-sed
parent
cbb3deb1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
17 deletions
+16
-17
api_installer.go
pkg/apiserver/api_installer.go
+3
-3
apiserver.go
pkg/apiserver/apiserver.go
+8
-9
master.go
pkg/master/master.go
+3
-3
master_test.go
pkg/master/master_test.go
+2
-2
No files found.
pkg/apiserver/api_installer.go
View file @
e3d984be
...
...
@@ -61,7 +61,7 @@ type documentable interface {
var
errEmptyName
=
errors
.
NewBadRequest
(
"name must be provided"
)
// Installs handlers for API resources.
func
(
a
*
APIInstaller
)
Install
(
ws
*
restful
.
WebService
)
(
apiResources
[]
api
.
APIResource
,
errors
[]
error
)
{
func
(
a
*
APIInstaller
)
Install
(
ws
*
restful
.
WebService
)
(
apiResources
[]
unversioned
.
APIResource
,
errors
[]
error
)
{
errors
=
make
([]
error
,
0
)
proxyHandler
:=
(
&
ProxyHandler
{
a
.
prefix
+
"/proxy/"
,
a
.
group
.
Storage
,
a
.
group
.
Codec
,
a
.
group
.
Context
,
a
.
info
,
a
.
proxyDialerFn
})
...
...
@@ -100,7 +100,7 @@ func (a *APIInstaller) NewWebService() *restful.WebService {
return
ws
}
func
(
a
*
APIInstaller
)
registerResourceHandlers
(
path
string
,
storage
rest
.
Storage
,
ws
*
restful
.
WebService
,
proxyHandler
http
.
Handler
)
(
*
api
.
APIResource
,
error
)
{
func
(
a
*
APIInstaller
)
registerResourceHandlers
(
path
string
,
storage
rest
.
Storage
,
ws
*
restful
.
WebService
,
proxyHandler
http
.
Handler
)
(
*
unversioned
.
APIResource
,
error
)
{
admit
:=
a
.
group
.
Admit
context
:=
a
.
group
.
Context
...
...
@@ -267,7 +267,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
params
:=
[]
*
restful
.
Parameter
{}
actions
:=
[]
action
{}
var
apiResource
api
.
APIResource
var
apiResource
unversioned
.
APIResource
// Get the list of actions for the given scope.
switch
scope
.
Name
()
{
case
meta
.
RESTScopeNameRoot
:
...
...
pkg/apiserver/apiserver.go
View file @
e3d984be
...
...
@@ -46,7 +46,6 @@ import (
"k8s.io/kubernetes/pkg/util/wsstream"
"k8s.io/kubernetes/pkg/version"
"github.com/emicklei/go-restful"
"github.com/golang/glog"
"github.com/prometheus/client_golang/prometheus"
)
...
...
@@ -259,7 +258,7 @@ func AddApiWebService(container *restful.Container, apiPrefix string, versions [
}
// Adds a service to return the supported api versions at /apis.
func
AddApisWebService
(
container
*
restful
.
Container
,
apiPrefix
string
,
groups
[]
api
.
APIGroup
)
{
func
AddApisWebService
(
container
*
restful
.
Container
,
apiPrefix
string
,
groups
[]
unversioned
.
APIGroup
)
{
rootAPIHandler
:=
RootAPIHandler
(
groups
)
ws
:=
new
(
restful
.
WebService
)
ws
.
Path
(
apiPrefix
)
...
...
@@ -274,7 +273,7 @@ func AddApisWebService(container *restful.Container, apiPrefix string, groups []
// Adds a service to return the supported versions, preferred version, and name
// of a group. E.g., a such web service will be registered at /apis/extensions.
func
AddGroupWebService
(
container
*
restful
.
Container
,
path
string
,
group
api
.
APIGroup
)
{
func
AddGroupWebService
(
container
*
restful
.
Container
,
path
string
,
group
unversioned
.
APIGroup
)
{
groupHandler
:=
GroupHandler
(
group
)
ws
:=
new
(
restful
.
WebService
)
ws
.
Path
(
path
)
...
...
@@ -289,7 +288,7 @@ func AddGroupWebService(container *restful.Container, path string, group api.API
// Adds a service to return the supported resources, E.g., a such web service
// will be registered at /apis/extensions/v1.
func
AddSupportedResourcesWebService
(
ws
*
restful
.
WebService
,
groupVersion
string
,
apiResources
[]
api
.
APIResource
)
{
func
AddSupportedResourcesWebService
(
ws
*
restful
.
WebService
,
groupVersion
string
,
apiResources
[]
unversioned
.
APIResource
)
{
resourceHandler
:=
SupportedResourcesHandler
(
groupVersion
,
apiResources
)
ws
.
Route
(
ws
.
GET
(
"/"
)
.
To
(
resourceHandler
)
.
Doc
(
"get available resources"
)
.
...
...
@@ -313,16 +312,16 @@ func APIVersionHandler(versions ...string) restful.RouteFunction {
}
// RootAPIHandler returns a handler which will list the provided groups and versions as available.
func
RootAPIHandler
(
groups
[]
api
.
APIGroup
)
restful
.
RouteFunction
{
func
RootAPIHandler
(
groups
[]
unversioned
.
APIGroup
)
restful
.
RouteFunction
{
return
func
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
// TODO: use restful's Response methods
writeRawJSON
(
http
.
StatusOK
,
api
.
APIGroupList
{
Groups
:
groups
},
resp
.
ResponseWriter
)
writeRawJSON
(
http
.
StatusOK
,
unversioned
.
APIGroupList
{
Groups
:
groups
},
resp
.
ResponseWriter
)
}
}
// GroupHandler returns a handler which will return the api.GroupAndVersion of
// the group.
func
GroupHandler
(
group
api
.
APIGroup
)
restful
.
RouteFunction
{
func
GroupHandler
(
group
unversioned
.
APIGroup
)
restful
.
RouteFunction
{
return
func
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
// TODO: use restful's Response methods
writeRawJSON
(
http
.
StatusOK
,
group
,
resp
.
ResponseWriter
)
...
...
@@ -330,10 +329,10 @@ func GroupHandler(group api.APIGroup) restful.RouteFunction {
}
// SupportedResourcesHandler returns a handler which will list the provided resources as available.
func
SupportedResourcesHandler
(
groupVersion
string
,
apiResources
[]
api
.
APIResource
)
restful
.
RouteFunction
{
func
SupportedResourcesHandler
(
groupVersion
string
,
apiResources
[]
unversioned
.
APIResource
)
restful
.
RouteFunction
{
return
func
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
// TODO: use restful's Response methods
writeRawJSON
(
http
.
StatusOK
,
api
.
APIResourceList
{
GroupVersion
:
groupVersion
,
APIResources
:
apiResources
},
resp
.
ResponseWriter
)
writeRawJSON
(
http
.
StatusOK
,
unversioned
.
APIResourceList
{
GroupVersion
:
groupVersion
,
APIResources
:
apiResources
},
resp
.
ResponseWriter
)
}
}
...
...
pkg/master/master.go
View file @
e3d984be
...
...
@@ -651,7 +651,7 @@ func (m *Master) init(c *Config) {
apiserver
.
InstallServiceErrorHandler
(
m
.
handlerContainer
,
m
.
newAPIRequestInfoResolver
(),
apiVersions
)
// allGroups records all supported groups at /apis
allGroups
:=
[]
api
.
APIGroup
{}
allGroups
:=
[]
unversioned
.
APIGroup
{}
if
m
.
exp
{
m
.
thirdPartyStorage
=
c
.
StorageDestinations
.
APIGroups
[
"extensions"
]
.
Default
m
.
thirdPartyResources
=
map
[
string
]
*
thirdpartyresourcedataetcd
.
REST
{}
...
...
@@ -675,7 +675,7 @@ func (m *Master) init(c *Config) {
if
!
found
{
glog
.
Fatalf
(
"Couldn't find storage version of group %v"
,
g
.
Group
)
}
group
:=
api
.
APIGroup
{
group
:=
unversioned
.
APIGroup
{
Name
:
g
.
Group
,
Versions
:
expAPIVersions
,
PreferredVersion
:
api
.
GroupVersion
{
GroupVersion
:
storageVersion
,
Version
:
apiutil
.
GetVersion
(
storageVersion
)},
...
...
@@ -995,7 +995,7 @@ func (m *Master) InstallThirdPartyResource(rsrc *expapi.ThirdPartyResource) erro
GroupVersion
:
group
+
"/"
+
rsrc
.
Versions
[
0
]
.
Name
,
Version
:
rsrc
.
Versions
[
0
]
.
Name
,
}
apiGroup
:=
api
.
APIGroup
{
apiGroup
:=
unversioned
.
APIGroup
{
Name
:
group
,
Versions
:
[]
api
.
GroupVersion
{
groupVersion
},
}
...
...
pkg/master/master_test.go
View file @
e3d984be
...
...
@@ -287,7 +287,7 @@ func TestDefaultAPIGroupVersion(t *testing.T) {
}
// TestExpapi verifies that the unexported exapi creates
// the an experimental
api
APIGroupVersion.
// the an experimental
unversioned.
APIGroupVersion.
func
TestExpapi
(
t
*
testing
.
T
)
{
master
,
config
,
assert
:=
setUp
(
t
)
...
...
@@ -465,7 +465,7 @@ func TestDiscoveryAtAPIS(t *testing.T) {
assert
.
Equal
(
http
.
StatusOK
,
resp
.
StatusCode
)
groupList
:=
api
.
APIGroupList
{}
groupList
:=
unversioned
.
APIGroupList
{}
assert
.
NoError
(
decodeResponse
(
resp
,
&
groupList
))
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
...
...
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