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
52519ecb
Commit
52519ecb
authored
Jan 21, 2019
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove deprecated openapi paths in favor of /openapi/v2
parent
5e86fa43
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
10 additions
and
42 deletions
+10
-42
update-openapi-spec.sh
hack/update-openapi-spec.sh
+1
-1
master_openapi_test.go
pkg/master/master_openapi_test.go
+3
-3
policy.go
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go
+0
-3
cluster-roles.yaml
...thorizer/rbac/bootstrappolicy/testdata/cluster-roles.yaml
+0
-2
openapi.go
staging/src/k8s.io/apiserver/pkg/server/routes/openapi.go
+1
-8
aggregator.go
....io/kube-aggregator/pkg/controllers/openapi/aggregator.go
+1
-21
downloader.go
....io/kube-aggregator/pkg/controllers/openapi/downloader.go
+2
-2
kube_apiserver_test.go
test/integration/master/kube_apiserver_test.go
+2
-2
No files found.
hack/update-openapi-spec.sh
View file @
52519ecb
...
...
@@ -83,7 +83,7 @@ fi
kube::log::status
"Updating "
${
OPENAPI_ROOT_DIR
}
curl
-w
"
\n
"
-fs
"
${
API_HOST
}
:
${
API_PORT
}
/
swagger.json
"
>
"
${
OPENAPI_ROOT_DIR
}
/swagger.json"
curl
-w
"
\n
"
-fs
"
${
API_HOST
}
:
${
API_PORT
}
/
openapi/v2
"
>
"
${
OPENAPI_ROOT_DIR
}
/swagger.json"
kube::log::status
"SUCCESS"
...
...
pkg/master/master_openapi_test.go
View file @
52519ecb
...
...
@@ -61,7 +61,7 @@ func TestValidOpenAPISpec(t *testing.T) {
// make sure swagger.json is not registered before calling PrepareRun.
server
:=
httptest
.
NewServer
(
master
.
GenericAPIServer
.
Handler
.
Director
)
defer
server
.
Close
()
resp
,
err
:=
http
.
Get
(
server
.
URL
+
"/
swagger.json
"
)
resp
,
err
:=
http
.
Get
(
server
.
URL
+
"/
openapi/v2
"
)
if
!
assert
.
NoError
(
err
)
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
...
...
@@ -69,7 +69,7 @@ func TestValidOpenAPISpec(t *testing.T) {
master
.
GenericAPIServer
.
PrepareRun
()
resp
,
err
=
http
.
Get
(
server
.
URL
+
"/
swagger.json
"
)
resp
,
err
=
http
.
Get
(
server
.
URL
+
"/
openapi/v2
"
)
if
!
assert
.
NoError
(
err
)
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
...
...
@@ -84,7 +84,7 @@ func TestValidOpenAPISpec(t *testing.T) {
}
// Validate OpenApi spec
doc
,
err
:=
loads
.
Spec
(
server
.
URL
+
"/
swagger.json
"
)
doc
,
err
:=
loads
.
Spec
(
server
.
URL
+
"/
openapi/v2
"
)
if
assert
.
NoError
(
err
)
{
validator
:=
validate
.
NewSpecValidator
(
doc
.
Schema
(),
strfmt
.
Default
)
res
,
warns
:=
validator
.
Validate
(
doc
)
...
...
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go
View file @
52519ecb
...
...
@@ -199,9 +199,6 @@ func ClusterRoles() []rbacv1.ClusterRole {
Rules
:
[]
rbacv1
.
PolicyRule
{
rbacv1helpers
.
NewRule
(
"get"
)
.
URLs
(
"/healthz"
,
"/version"
,
"/version/"
,
// do not expand this pattern for openapi discovery docs
// move to a single openapi endpoint that takes accept/accept-encoding headers
"/swagger.json"
,
"/swagger-2.0.0.pb-v1"
,
"/openapi"
,
"/openapi/*"
,
"/api"
,
"/api/*"
,
"/apis"
,
"/apis/*"
,
...
...
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/cluster-roles.yaml
View file @
52519ecb
...
...
@@ -550,8 +550,6 @@ items:
-
/healthz
-
/openapi
-
/openapi/*
-
/swagger-2.0.0.pb-v1
-
/swagger.json
-
/version
-
/version/
verbs
:
...
...
staging/src/k8s.io/apiserver/pkg/server/routes/openapi.go
View file @
52519ecb
...
...
@@ -32,14 +32,7 @@ type OpenAPI struct {
// Install adds the SwaggerUI webservice to the given mux.
func
(
oa
OpenAPI
)
Install
(
c
*
restful
.
Container
,
mux
*
mux
.
PathRecorderMux
)
{
// NOTE: [DEPRECATION] We will announce deprecation for format-separated endpoints for OpenAPI spec,
// and switch to a single /openapi/v2 endpoint in Kubernetes 1.10. The design doc and deprecation process
// are tracked at: https://docs.google.com/document/d/19lEqE9lc4yHJ3WJAJxS_G7TcORIJXGHyq3wpwcH28nU.
_
,
err
:=
handler
.
BuildAndRegisterOpenAPIService
(
"/swagger.json"
,
c
.
RegisteredWebServices
(),
oa
.
Config
,
mux
)
if
err
!=
nil
{
klog
.
Fatalf
(
"Failed to register open api spec for root: %v"
,
err
)
}
_
,
err
=
handler
.
BuildAndRegisterOpenAPIVersionedService
(
"/openapi/v2"
,
c
.
RegisteredWebServices
(),
oa
.
Config
,
mux
)
_
,
err
:=
handler
.
BuildAndRegisterOpenAPIVersionedService
(
"/openapi/v2"
,
c
.
RegisteredWebServices
(),
oa
.
Config
,
mux
)
if
err
!=
nil
{
klog
.
Fatalf
(
"Failed to register versioned open api spec for root: %v"
,
err
)
}
...
...
staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator.go
View file @
52519ecb
...
...
@@ -51,7 +51,6 @@ type specAggregator struct {
openAPISpecs
map
[
string
]
*
openAPISpecInfo
// provided for dynamic OpenAPI spec
openAPIService
*
handler
.
OpenAPIService
openAPIVersionedService
*
handler
.
OpenAPIService
}
...
...
@@ -110,14 +109,6 @@ func BuildAndRegisterAggregator(downloader *Downloader, delegationTarget server.
}
// Install handler
// NOTE: [DEPRECATION] We will announce deprecation for format-separated endpoints for OpenAPI spec,
// and switch to a single /openapi/v2 endpoint in Kubernetes 1.10. The design doc and deprecation process
// are tracked at: https://docs.google.com/document/d/19lEqE9lc4yHJ3WJAJxS_G7TcORIJXGHyq3wpwcH28nU.
s
.
openAPIService
,
err
=
handler
.
RegisterOpenAPIService
(
specToServe
,
"/swagger.json"
,
pathHandler
)
if
err
!=
nil
{
return
nil
,
err
}
s
.
openAPIVersionedService
,
err
=
handler
.
RegisterOpenAPIVersionedService
(
specToServe
,
"/openapi/v2"
,
pathHandler
)
if
err
!=
nil
{
...
...
@@ -216,24 +207,13 @@ func (s *specAggregator) buildOpenAPISpec() (specToReturn *spec.Swagger, err err
// updateOpenAPISpec aggregates all OpenAPI specs. It is not thread-safe. The caller is responsible to hold proper locks.
func
(
s
*
specAggregator
)
updateOpenAPISpec
()
error
{
if
s
.
openAPIService
==
nil
||
s
.
openAPIVersionedService
==
nil
{
// openAPIVersionedService and deprecated openAPIService should be initialized together
if
!
(
s
.
openAPIService
==
nil
&&
s
.
openAPIVersionedService
==
nil
)
{
return
fmt
.
Errorf
(
"unexpected openapi service initialization error"
)
}
if
s
.
openAPIVersionedService
==
nil
{
return
nil
}
specToServe
,
err
:=
s
.
buildOpenAPISpec
()
if
err
!=
nil
{
return
err
}
// openAPIService.UpdateSpec and openAPIVersionedService.UpdateSpec read the same swagger spec
// serially and update their local caches separately. Both endpoints will have same spec in
// their caches if the caller is holding proper locks.
err
=
s
.
openAPIService
.
UpdateSpec
(
specToServe
)
if
err
!=
nil
{
return
err
}
return
s
.
openAPIVersionedService
.
UpdateSpec
(
specToServe
)
}
...
...
staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/downloader.go
View file @
52519ecb
...
...
@@ -29,7 +29,7 @@ import (
"k8s.io/apiserver/pkg/endpoints/request"
)
// Downloader is the OpenAPI downloader type. It will try to download spec from /swagger.json endpoint.
// Downloader is the OpenAPI downloader type. It will try to download spec from /
openapi/v2 or /
swagger.json endpoint.
type
Downloader
struct
{
}
...
...
@@ -89,7 +89,7 @@ func etagFor(data []byte) string {
return
fmt
.
Sprintf
(
"%s%X
\"
"
,
locallyGeneratedEtagPrefix
,
sha512
.
Sum512
(
data
))
}
// Download downloads openAPI spec from /swagger.json endpoint of the given handler.
// Download downloads openAPI spec from /
openapi/v2 or /
swagger.json endpoint of the given handler.
// httpStatus is only valid if err == nil
func
(
s
*
Downloader
)
Download
(
handler
http
.
Handler
,
etag
string
)
(
returnSpec
*
spec
.
Swagger
,
newEtag
string
,
httpStatus
int
,
err
error
)
{
handler
=
s
.
handlerWithUser
(
handler
,
&
user
.
DefaultInfo
{
Name
:
aggregatorUser
})
...
...
test/integration/master/kube_apiserver_test.go
View file @
52519ecb
...
...
@@ -96,11 +96,11 @@ func TestOpenAPIDelegationChainPlumbing(t *testing.T) {
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
result
:=
kubeclient
.
RESTClient
()
.
Get
()
.
AbsPath
(
"/
swagger.json
"
)
.
Do
()
result
:=
kubeclient
.
RESTClient
()
.
Get
()
.
AbsPath
(
"/
openapi/v2
"
)
.
Do
()
status
:=
0
result
.
StatusCode
(
&
status
)
if
status
!=
http
.
StatusOK
{
t
.
Fatalf
(
"GET /
swagger.json
failed: expected status=%d, got=%d"
,
http
.
StatusOK
,
status
)
t
.
Fatalf
(
"GET /
openapi/v2
failed: expected status=%d, got=%d"
,
http
.
StatusOK
,
status
)
}
raw
,
err
:=
result
.
Raw
()
...
...
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