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
5746d876
Commit
5746d876
authored
Apr 13, 2017
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix cluster scoped self-link
parent
8e3d32b1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletion
+41
-1
apiserver_test.go
staging/src/k8s.io/apiserver/pkg/endpoints/apiserver_test.go
+40
-0
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 @
5746d876
...
@@ -1271,6 +1271,46 @@ func TestSelfLinkSkipsEmptyName(t *testing.T) {
...
@@ -1271,6 +1271,46 @@ func TestSelfLinkSkipsEmptyName(t *testing.T) {
}
}
}
}
func
TestRootSelfLink
(
t
*
testing
.
T
)
{
storage
:=
map
[
string
]
rest
.
Storage
{}
simpleStorage
:=
GetWithOptionsRootRESTStorage
{
SimpleTypedStorage
:
&
SimpleTypedStorage
{
baseType
:
&
genericapitesting
.
SimpleRoot
{},
// a root scoped type
item
:
&
genericapitesting
.
SimpleRoot
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
},
Other
:
"foo"
,
},
},
takesPath
:
"atAPath"
,
}
storage
[
"simple"
]
=
&
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
)
}
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
!=
"/"
+
prefix
+
"/"
+
testGroupVersion
.
Group
+
"/"
+
testGroupVersion
.
Version
+
"/simple/foo"
{
t
.
Errorf
(
"unexpected self link: %#v"
,
out
)
}
}
func
TestMetadata
(
t
*
testing
.
T
)
{
func
TestMetadata
(
t
*
testing
.
T
)
{
simpleStorage
:=
&
MetadataRESTStorage
{
&
SimpleRESTStorage
{},
[]
string
{
"text/plain"
}}
simpleStorage
:=
&
MetadataRESTStorage
{
&
SimpleRESTStorage
{},
[]
string
{
"text/plain"
}}
h
:=
handle
(
map
[
string
]
rest
.
Storage
{
"simple"
:
simpleStorage
})
h
:=
handle
(
map
[
string
]
rest
.
Storage
{
"simple"
:
simpleStorage
})
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/installer.go
View file @
5746d876
...
@@ -393,7 +393,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
...
@@ -393,7 +393,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
GetContext
:
ctxFn
,
GetContext
:
ctxFn
,
SelfLinker
:
a
.
group
.
Linker
,
SelfLinker
:
a
.
group
.
Linker
,
ClusterScoped
:
true
,
ClusterScoped
:
true
,
SelfLinkPathPrefix
:
gpath
.
Join
(
a
.
prefix
,
resourcePath
,
"/"
)
,
SelfLinkPathPrefix
:
gpath
.
Join
(
a
.
prefix
,
resourcePath
)
+
"/"
,
SelfLinkPathSuffix
:
suffix
,
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