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
8f65442c
Commit
8f65442c
authored
Dec 12, 2014
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client should not include ns/ for non-namespaced calls in v1beta3
parent
2495174a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
4 deletions
+47
-4
client.go
pkg/client/client.go
+1
-1
request.go
pkg/client/request.go
+5
-3
request_test.go
pkg/client/request_test.go
+5
-0
converter.go
pkg/conversion/converter.go
+4
-0
get_test.go
pkg/kubectl/cmd/get_test.go
+32
-0
No files found.
pkg/client/client.go
View file @
8f65442c
...
@@ -40,7 +40,7 @@ type Interface interface {
...
@@ -40,7 +40,7 @@ type Interface interface {
}
}
func
(
c
*
Client
)
ReplicationControllers
(
namespace
string
)
ReplicationControllerInterface
{
func
(
c
*
Client
)
ReplicationControllers
(
namespace
string
)
ReplicationControllerInterface
{
return
newReplicationControllers
(
c
,
namespace
)
return
newReplicationControllers
(
c
,
namespace
,
c
.
preV1Beta3
)
}
}
func
(
c
*
Client
)
Nodes
()
NodeInterface
{
func
(
c
*
Client
)
Nodes
()
NodeInterface
{
...
...
pkg/client/request.go
View file @
8f65442c
...
@@ -103,6 +103,7 @@ type Request struct {
...
@@ -103,6 +103,7 @@ type Request struct {
// structural elements of the request that are part of the Kubernetes API conventions
// structural elements of the request that are part of the Kubernetes API conventions
namespace
string
namespace
string
namespaceSet
bool
resource
string
resource
string
resourceName
string
resourceName
string
selector
labels
.
Selector
selector
labels
.
Selector
...
@@ -190,10 +191,11 @@ func (r *Request) Namespace(namespace string) *Request {
...
@@ -190,10 +191,11 @@ func (r *Request) Namespace(namespace string) *Request {
if
r
.
err
!=
nil
{
if
r
.
err
!=
nil
{
return
r
return
r
}
}
if
len
(
r
.
namespace
)
!=
0
{
if
r
.
namespaceSet
{
r
.
err
=
fmt
.
Errorf
(
"namespace already set to %q, cannot change to %q"
,
r
.
namespace
,
namespace
)
r
.
err
=
fmt
.
Errorf
(
"namespace already set to %q, cannot change to %q"
,
r
.
namespace
,
namespace
)
return
r
return
r
}
}
r
.
namespaceSet
=
true
r
.
namespace
=
namespace
r
.
namespace
=
namespace
return
r
return
r
}
}
...
@@ -330,7 +332,7 @@ func (r *Request) Poller(poller PollFunc) *Request {
...
@@ -330,7 +332,7 @@ func (r *Request) Poller(poller PollFunc) *Request {
func
(
r
*
Request
)
finalURL
()
string
{
func
(
r
*
Request
)
finalURL
()
string
{
p
:=
r
.
path
p
:=
r
.
path
if
!
r
.
namespaceInQuery
{
if
r
.
namespaceSet
&&
!
r
.
namespaceInQuery
&&
len
(
r
.
namespace
)
>
0
{
p
=
path
.
Join
(
p
,
"ns"
,
r
.
namespace
)
p
=
path
.
Join
(
p
,
"ns"
,
r
.
namespace
)
}
}
if
len
(
r
.
resource
)
!=
0
{
if
len
(
r
.
resource
)
!=
0
{
...
@@ -353,7 +355,7 @@ func (r *Request) finalURL() string {
...
@@ -353,7 +355,7 @@ func (r *Request) finalURL() string {
query
.
Add
(
key
,
value
)
query
.
Add
(
key
,
value
)
}
}
if
r
.
namespaceInQuery
&&
len
(
r
.
namespace
)
>
0
{
if
r
.
namespace
Set
&&
r
.
namespace
InQuery
&&
len
(
r
.
namespace
)
>
0
{
query
.
Add
(
"namespace"
,
r
.
namespace
)
query
.
Add
(
"namespace"
,
r
.
namespace
)
}
}
...
...
pkg/client/request_test.go
View file @
8f65442c
...
@@ -86,6 +86,11 @@ func TestRequestAbsPathPreservesTrailingSlash(t *testing.T) {
...
@@ -86,6 +86,11 @@ func TestRequestAbsPathPreservesTrailingSlash(t *testing.T) {
if
s
:=
r
.
finalURL
();
s
!=
"/foo/"
{
if
s
:=
r
.
finalURL
();
s
!=
"/foo/"
{
t
.
Errorf
(
"trailing slash should be preserved: %s"
,
s
)
t
.
Errorf
(
"trailing slash should be preserved: %s"
,
s
)
}
}
r
=
(
&
Request
{
baseURL
:
&
url
.
URL
{}})
.
AbsPath
(
"/foo/"
)
if
s
:=
r
.
finalURL
();
s
!=
"/foo/"
{
t
.
Errorf
(
"trailing slash should be preserved: %s"
,
s
)
}
}
}
func
TestRequestAbsPathJoins
(
t
*
testing
.
T
)
{
func
TestRequestAbsPathJoins
(
t
*
testing
.
T
)
{
...
...
pkg/conversion/converter.go
View file @
8f65442c
...
@@ -457,6 +457,10 @@ func (c *Converter) defaultConvert(sv, dv reflect.Value, scope *scope) error {
...
@@ -457,6 +457,10 @@ func (c *Converter) defaultConvert(sv, dv reflect.Value, scope *scope) error {
}
}
dkv
:=
reflect
.
New
(
dt
.
Elem
())
.
Elem
()
dkv
:=
reflect
.
New
(
dt
.
Elem
())
.
Elem
()
scope
.
setKeys
(
sk
.
Interface
(),
dk
.
Interface
())
scope
.
setKeys
(
sk
.
Interface
(),
dk
.
Interface
())
// TODO: sv.MapIndex(sk) may return a value with CanAddr() == false,
// because a map[string]struct{} does not allow a pointer reference.
// Calling a custom conversion function defined for the map value
// will panic. Example is PodInfo map[string]ContainerStatus.
if
err
:=
c
.
convert
(
sv
.
MapIndex
(
sk
),
dkv
,
scope
);
err
!=
nil
{
if
err
:=
c
.
convert
(
sv
.
MapIndex
(
sk
),
dkv
,
scope
);
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/cmd/get_test.go
View file @
8f65442c
...
@@ -21,9 +21,13 @@ import (
...
@@ -21,9 +21,13 @@ import (
"fmt"
"fmt"
"net/http"
"net/http"
"reflect"
"reflect"
"strings"
"testing"
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
)
)
// Verifies that schemas that are not in the master tree of Kubernetes can be retrieved via Get.
// Verifies that schemas that are not in the master tree of Kubernetes can be retrieved via Get.
...
@@ -50,3 +54,31 @@ func TestGetUnknownSchemaObject(t *testing.T) {
...
@@ -50,3 +54,31 @@ func TestGetUnknownSchemaObject(t *testing.T) {
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
String
())
}
}
}
}
// Verifies that schemas that are not in the master tree of Kubernetes can be retrieved via Get.
func
TestGetSchemaObject
(
t
*
testing
.
T
)
{
f
,
tf
,
_
:=
NewTestFactory
()
f
.
Mapper
=
latest
.
RESTMapper
f
.
Typer
=
api
.
Scheme
codec
:=
latest
.
Codec
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
client
.
FakeRESTClient
{
Codec
:
codec
,
Resp
:
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
api
.
ReplicationController
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}})},
}
buf
:=
bytes
.
NewBuffer
([]
byte
{})
cmd
:=
f
.
NewCmdGet
(
buf
)
cmd
.
Flags
()
.
String
(
"api-version"
,
"v1beta3"
,
""
)
cmd
.
Flags
()
.
String
(
"namespace"
,
"test"
,
""
)
cmd
.
Run
(
cmd
,
[]
string
{
"replicationcontrollers"
,
"foo"
})
expected
:=
&
api
.
ReplicationController
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
Spec
:
api
.
ReplicationControllerSpec
{
Template
:
&
api
.
PodTemplateSpec
{}}}
actual
:=
tf
.
Printer
.
(
*
testPrinter
)
.
Obj
if
!
reflect
.
DeepEqual
(
expected
,
actual
)
{
t
.
Errorf
(
"unexpected object: %s"
,
util
.
ObjectGoPrintDiff
(
expected
,
actual
))
}
if
!
strings
.
Contains
(
buf
.
String
(),
"
\"
foo
\"
"
)
{
t
.
Errorf
(
"unexpected output: %s"
,
buf
.
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