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
dde12218
Commit
dde12218
authored
Apr 14, 2017
by
Cao Shufeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix PathPrefix for subresources
parent
21f30db4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
15 deletions
+32
-15
apiserver_test.go
staging/src/k8s.io/apiserver/pkg/endpoints/apiserver_test.go
+31
-14
installer.go
staging/src/k8s.io/apiserver/pkg/endpoints/installer.go
+1
-1
No files found.
staging/src/k8s.io/apiserver/pkg/endpoints/apiserver_test.go
View file @
dde12218
...
...
@@ -1284,30 +1284,47 @@ func TestRootSelfLink(t *testing.T) {
takesPath
:
"atAPath"
,
}
storage
[
"simple"
]
=
&
simpleStorage
storage
[
"simple/sub"
]
=
&
simpleStorage
handler
:=
handle
(
storage
)
server
:=
httptest
.
NewServer
(
handler
)
defer
server
.
Close
()
resp
,
err
:=
http
.
Get
(
server
.
URL
+
"/"
+
prefix
+
"/"
+
testGroupVersion
.
Group
+
"/"
+
testGroupVersion
.
Version
+
"/simple/foo"
)
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
testCases
:=
[]
struct
{
url
string
selfLink
string
}{
{
url
:
server
.
URL
+
"/"
+
prefix
+
"/"
+
testGroupVersion
.
Group
+
"/"
+
testGroupVersion
.
Version
+
"/simple/foo"
,
selfLink
:
"/"
+
prefix
+
"/"
+
testGroupVersion
.
Group
+
"/"
+
testGroupVersion
.
Version
+
"/simple/foo"
,
},
{
url
:
server
.
URL
+
"/"
+
prefix
+
"/"
+
testGroupVersion
.
Group
+
"/"
+
testGroupVersion
.
Version
+
"/simple/foo/sub"
,
selfLink
:
"/"
+
prefix
+
"/"
+
testGroupVersion
.
Group
+
"/"
+
testGroupVersion
.
Version
+
"/simple/foo/sub"
,
},
}
if
resp
.
StatusCode
!=
http
.
StatusOK
{
t
.
Errorf
(
"Unexpected status: %d, Expected: %d, %#v"
,
resp
.
StatusCode
,
http
.
StatusOK
,
resp
)
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
for
_
,
test
:=
range
testCases
{
resp
,
err
:=
http
.
Get
(
test
.
url
)
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
t
.
Logf
(
"Data: %s"
,
string
(
body
))
}
var
out
genericapitesting
.
SimpleRoot
if
_
,
err
:=
extractBody
(
resp
,
&
out
);
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
if
out
.
SelfLink
!=
"/"
+
prefix
+
"/"
+
testGroupVersion
.
Group
+
"/"
+
testGroupVersion
.
Version
+
"/simple/foo"
{
t
.
Errorf
(
"unexpected self link: %#v"
,
out
)
if
resp
.
StatusCode
!=
http
.
StatusOK
{
t
.
Errorf
(
"Unexpected status: %d, Expected: %d, %#v"
,
resp
.
StatusCode
,
http
.
StatusOK
,
resp
)
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
t
.
Logf
(
"Data: %s"
,
string
(
body
))
}
var
out
genericapitesting
.
SimpleRoot
if
_
,
err
:=
extractBody
(
resp
,
&
out
);
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
if
out
.
SelfLink
!=
test
.
selfLink
{
t
.
Errorf
(
"unexpected self link: %#v"
,
out
.
SelfLink
)
}
}
}
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/installer.go
View file @
dde12218
...
...
@@ -393,7 +393,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
GetContext
:
ctxFn
,
SelfLinker
:
a
.
group
.
Linker
,
ClusterScoped
:
true
,
SelfLinkPathPrefix
:
gpath
.
Join
(
a
.
prefix
,
resource
Path
)
+
"/"
,
SelfLinkPathPrefix
:
gpath
.
Join
(
a
.
prefix
,
resource
)
+
"/"
,
SelfLinkPathSuffix
:
suffix
,
}
...
...
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