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
9669acc3
Commit
9669acc3
authored
Jan 04, 2018
by
hzxuzhonghu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove hard coding Namespace
parent
17ffacc3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
6 deletions
+7
-6
context.go
...ing/src/k8s.io/apiserver/pkg/endpoints/request/context.go
+3
-4
requestinfo.go
...src/k8s.io/apiserver/pkg/endpoints/request/requestinfo.go
+2
-1
requestinfo_test.go
...8s.io/apiserver/pkg/endpoints/request/requestinfo_test.go
+2
-1
No files found.
staging/src/k8s.io/apiserver/pkg/endpoints/request/context.go
View file @
9669acc3
...
...
@@ -21,6 +21,7 @@ import (
"time"
"golang.org/x/net/context"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apiserver/pkg/apis/audit"
"k8s.io/apiserver/pkg/authentication/user"
...
...
@@ -66,8 +67,6 @@ const (
// auditKey is the context key for the audit event.
auditKey
namespaceDefault
=
"default"
// TODO(sttts): solve import cycle when using metav1.NamespaceDefault
)
// NewContext instantiates a base context object for request flows.
...
...
@@ -77,7 +76,7 @@ func NewContext() Context {
// NewDefaultContext instantiates a base context object for request flows in the default namespace
func
NewDefaultContext
()
Context
{
return
WithNamespace
(
NewContext
(),
n
amespaceDefault
)
return
WithNamespace
(
NewContext
(),
metav1
.
N
amespaceDefault
)
}
// WithValue returns a copy of parent in which the value associated with key is val.
...
...
@@ -110,7 +109,7 @@ func NamespaceValue(ctx Context) string {
func
WithNamespaceDefaultIfNone
(
parent
Context
)
Context
{
namespace
,
ok
:=
NamespaceFrom
(
parent
)
if
!
ok
||
len
(
namespace
)
==
0
{
return
WithNamespace
(
parent
,
n
amespaceDefault
)
return
WithNamespace
(
parent
,
metav1
.
N
amespaceDefault
)
}
return
parent
}
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/request/requestinfo.go
View file @
9669acc3
...
...
@@ -21,6 +21,7 @@ import (
"net/http"
"strings"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
)
...
...
@@ -178,7 +179,7 @@ func (r *RequestInfoFactory) NewRequestInfo(req *http.Request) (*RequestInfo, er
}
}
}
else
{
requestInfo
.
Namespace
=
""
// TODO(sttts): solve import cycle when using
metav1.NamespaceNone
requestInfo
.
Namespace
=
metav1
.
NamespaceNone
}
// parsing successful, so we now know the proper value for .Parts
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/request/requestinfo_test.go
View file @
9669acc3
...
...
@@ -21,6 +21,7 @@ import (
"reflect"
"testing"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
)
...
...
@@ -31,7 +32,7 @@ func (f fakeRL) TryAccept() bool { return bool(f) }
func
(
f
fakeRL
)
Accept
()
{}
func
TestGetAPIRequestInfo
(
t
*
testing
.
T
)
{
namespaceAll
:=
""
// TODO(sttts): solve import cycle when using
metav1.NamespaceAll
namespaceAll
:=
metav1
.
NamespaceAll
successCases
:=
[]
struct
{
method
string
url
string
...
...
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