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
1d7f70a5
Commit
1d7f70a5
authored
Jun 18, 2015
by
Satnam Singh
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9991 from nikhiljindal/dupPost
Do not register cross namespace actions with subresources in path
parents
98e1aef2
d3d579f5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
80 deletions
+15
-80
v1.json
api/swagger-spec/v1.json
+0
-37
v1beta3.json
api/swagger-spec/v1beta3.json
+0
-37
api_installer.go
pkg/apiserver/api_installer.go
+15
-6
No files found.
api/swagger-spec/v1.json
View file @
1d7f70a5
...
...
@@ -5675,43 +5675,6 @@
"consumes"
:
[
"*/*"
]
},
{
"type"
:
"v1.Binding"
,
"method"
:
"POST"
,
"summary"
:
"create binding of a Binding"
,
"nickname"
:
"createBindingBinding"
,
"parameters"
:
[
{
"type"
:
"string"
,
"paramType"
:
"query"
,
"name"
:
"pretty"
,
"description"
:
"If 'true', then the output is pretty printed."
,
"required"
:
false
,
"allowMultiple"
:
false
},
{
"type"
:
"v1.Binding"
,
"paramType"
:
"body"
,
"name"
:
"body"
,
"description"
:
""
,
"required"
:
true
,
"allowMultiple"
:
false
}
],
"responseMessages"
:
[
{
"code"
:
200
,
"message"
:
"OK"
,
"responseModel"
:
"v1.Binding"
}
],
"produces"
:
[
"application/json"
],
"consumes"
:
[
"*/*"
]
}
]
},
...
...
api/swagger-spec/v1beta3.json
View file @
1d7f70a5
...
...
@@ -5675,43 +5675,6 @@
"consumes"
:
[
"*/*"
]
},
{
"type"
:
"v1beta3.Binding"
,
"method"
:
"POST"
,
"summary"
:
"create binding of a Binding"
,
"nickname"
:
"createBindingBinding"
,
"parameters"
:
[
{
"type"
:
"string"
,
"paramType"
:
"query"
,
"name"
:
"pretty"
,
"description"
:
"If 'true', then the output is pretty printed."
,
"required"
:
false
,
"allowMultiple"
:
false
},
{
"type"
:
"v1beta3.Binding"
,
"paramType"
:
"body"
,
"name"
:
"body"
,
"description"
:
""
,
"required"
:
true
,
"allowMultiple"
:
false
}
],
"responseMessages"
:
[
{
"code"
:
200
,
"message"
:
"OK"
,
"responseModel"
:
"v1beta3.Binding"
}
],
"produces"
:
[
"application/json"
],
"consumes"
:
[
"*/*"
]
}
]
},
...
...
pkg/apiserver/api_installer.go
View file @
1d7f70a5
...
...
@@ -250,6 +250,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
// Get the list of actions for the given scope.
if
scope
.
Name
()
!=
meta
.
RESTScopeNameNamespace
{
// Handle non-namespace scoped resources like nodes.
resourcePath
:=
resource
resourceParams
:=
params
itemPath
:=
resourcePath
+
"/{name}"
...
...
@@ -263,10 +264,12 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
namer
:=
rootScopeNaming
{
scope
,
a
.
group
.
Linker
,
gpath
.
Join
(
a
.
prefix
,
itemPath
)}
// Handler for standard REST verbs (GET, PUT, POST and DELETE).
// Add actions at the resource path: /api/apiVersion/resource
actions
=
appendIf
(
actions
,
action
{
"LIST"
,
resourcePath
,
resourceParams
,
namer
},
isLister
)
actions
=
appendIf
(
actions
,
action
{
"POST"
,
resourcePath
,
resourceParams
,
namer
},
isCreater
)
actions
=
appendIf
(
actions
,
action
{
"WATCHLIST"
,
"watch/"
+
resourcePath
,
resourceParams
,
namer
},
allowWatchList
)
// Add actions at the item path: /api/apiVersion/resource/{name}
actions
=
appendIf
(
actions
,
action
{
"GET"
,
itemPath
,
nameParams
,
namer
},
isGetter
)
if
getSubpath
{
actions
=
appendIf
(
actions
,
action
{
"GET"
,
itemPath
+
"/{path:*}"
,
proxyParams
,
namer
},
isGetter
)
...
...
@@ -281,8 +284,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
actions
=
appendIf
(
actions
,
action
{
"CONNECT"
,
itemPath
+
"/{path:*}"
,
proxyParams
,
namer
},
isConnecter
&&
connectSubpath
)
}
else
{
//
v1beta3+ format with namespace in path
//
Handle namespace scoped resources like pods.
if
scope
.
ParamPath
()
{
// Handle the case when namespace is part of the path.
// Handler for standard REST verbs (GET, PUT, POST and DELETE).
namespaceParam
:=
ws
.
PathParameter
(
scope
.
ParamName
(),
scope
.
ParamDescription
())
.
DataType
(
"string"
)
namespacedPath
:=
scope
.
ParamName
()
+
"/{"
+
scope
.
ParamName
()
+
"}/"
+
resource
...
...
@@ -300,11 +304,13 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
}
namer
:=
scopeNaming
{
scope
,
a
.
group
.
Linker
,
gpath
.
Join
(
a
.
prefix
,
itemPath
),
false
}
// Add actions at the resource path: /api/apiVersion/namespaces/{namespaces}/resource
actions
=
appendIf
(
actions
,
action
{
"LIST"
,
resourcePath
,
resourceParams
,
namer
},
isLister
)
actions
=
appendIf
(
actions
,
action
{
"POST"
,
resourcePath
,
resourceParams
,
namer
},
isCreater
)
// DEPRECATED
actions
=
appendIf
(
actions
,
action
{
"WATCHLIST"
,
"watch/"
+
resourcePath
,
resourceParams
,
namer
},
allowWatchList
)
// Add actions at the item path: /api/apiVersion/namespaces/{namespaces}/resource/{name}
actions
=
appendIf
(
actions
,
action
{
"GET"
,
itemPath
,
nameParams
,
namer
},
isGetter
)
if
getSubpath
{
actions
=
appendIf
(
actions
,
action
{
"GET"
,
itemPath
+
"/{path:*}"
,
proxyParams
,
namer
},
isGetter
)
...
...
@@ -319,13 +325,16 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
actions
=
appendIf
(
actions
,
action
{
"CONNECT"
,
itemPath
+
"/{path:*}"
,
proxyParams
,
namer
},
isConnecter
&&
connectSubpath
)
// list or post across namespace.
// For ex: LIST all pods in all namespaces by sending a LIST request at /api/apiVersion/pods.
// TODO: more strongly type whether a resource allows these actions on "all namespaces" (bulk delete)
namer
=
scopeNaming
{
scope
,
a
.
group
.
Linker
,
gpath
.
Join
(
a
.
prefix
,
itemPath
),
true
}
actions
=
appendIf
(
actions
,
action
{
"LIST"
,
resource
,
params
,
namer
},
isLister
)
actions
=
appendIf
(
actions
,
action
{
"POST"
,
resource
,
params
,
namer
},
isCreater
)
actions
=
appendIf
(
actions
,
action
{
"WATCHLIST"
,
"watch/"
+
resource
,
params
,
namer
},
allowWatchList
)
if
!
hasSubresource
{
namer
=
scopeNaming
{
scope
,
a
.
group
.
Linker
,
gpath
.
Join
(
a
.
prefix
,
itemPath
),
true
}
actions
=
appendIf
(
actions
,
action
{
"LIST"
,
resource
,
params
,
namer
},
isLister
)
actions
=
appendIf
(
actions
,
action
{
"POST"
,
resource
,
params
,
namer
},
isCreater
)
actions
=
appendIf
(
actions
,
action
{
"WATCHLIST"
,
"watch/"
+
resource
,
params
,
namer
},
allowWatchList
)
}
}
else
{
// Namespace as param is no longer supported
//
Legacy behavior:
Namespace as param is no longer supported
return
fmt
.
Errorf
(
"namespace as a parameter is no longer supported"
)
}
}
...
...
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