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
50a2c4c6
Commit
50a2c4c6
authored
Oct 08, 2015
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
grep-sed
parent
d1d10f83
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
36 additions
and
36 deletions
+36
-36
apiserver.go
pkg/apiserver/apiserver.go
+1
-1
listwatch_test.go
pkg/client/cache/listwatch_test.go
+2
-2
client.go
pkg/client/unversioned/client.go
+3
-3
client_test.go
pkg/client/unversioned/client_test.go
+4
-4
events_test.go
pkg/client/unversioned/events_test.go
+2
-2
experimental.go
pkg/client/unversioned/experimental.go
+2
-2
helper_blackbox_test.go
pkg/client/unversioned/helper_blackbox_test.go
+2
-2
nodes_test.go
pkg/client/unversioned/nodes_test.go
+1
-1
pods_test.go
pkg/client/unversioned/pods_test.go
+1
-1
request.go
pkg/client/unversioned/request.go
+2
-2
request_test.go
pkg/client/unversioned/request_test.go
+2
-2
services_test.go
pkg/client/unversioned/services_test.go
+1
-1
testclient.go
pkg/client/unversioned/testclient/testclient.go
+2
-2
apiversions.go
pkg/kubectl/cmd/apiversions.go
+1
-1
delete_test.go
pkg/kubectl/cmd/delete_test.go
+2
-2
get_test.go
pkg/kubectl/cmd/get_test.go
+2
-2
builder_test.go
pkg/kubectl/resource/builder_test.go
+3
-3
helper_test.go
pkg/kubectl/resource/helper_test.go
+1
-1
kubectl.go
test/e2e/kubectl.go
+2
-2
No files found.
pkg/apiserver/apiserver.go
View file @
50a2c4c6
...
@@ -307,7 +307,7 @@ func handleVersion(req *restful.Request, resp *restful.Response) {
...
@@ -307,7 +307,7 @@ func handleVersion(req *restful.Request, resp *restful.Response) {
func
APIVersionHandler
(
versions
...
string
)
restful
.
RouteFunction
{
func
APIVersionHandler
(
versions
...
string
)
restful
.
RouteFunction
{
return
func
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
return
func
(
req
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
// TODO: use restful's Response methods
// TODO: use restful's Response methods
writeRawJSON
(
http
.
StatusOK
,
api
.
APIVersions
{
Versions
:
versions
},
resp
.
ResponseWriter
)
writeRawJSON
(
http
.
StatusOK
,
unversioned
.
APIVersions
{
Versions
:
versions
},
resp
.
ResponseWriter
)
}
}
}
}
...
...
pkg/client/cache/listwatch_test.go
View file @
50a2c4c6
...
@@ -54,7 +54,7 @@ func buildLocation(resourcePath string, query url.Values) string {
...
@@ -54,7 +54,7 @@ func buildLocation(resourcePath string, query url.Values) string {
}
}
func
TestListWatchesCanList
(
t
*
testing
.
T
)
{
func
TestListWatchesCanList
(
t
*
testing
.
T
)
{
fieldSelectorQueryParamName
:=
api
.
FieldSelectorQueryParam
(
testapi
.
Default
.
Version
())
fieldSelectorQueryParamName
:=
unversioned
.
FieldSelectorQueryParam
(
testapi
.
Default
.
Version
())
table
:=
[]
struct
{
table
:=
[]
struct
{
location
string
location
string
resource
string
resource
string
...
@@ -104,7 +104,7 @@ func TestListWatchesCanList(t *testing.T) {
...
@@ -104,7 +104,7 @@ func TestListWatchesCanList(t *testing.T) {
}
}
func
TestListWatchesCanWatch
(
t
*
testing
.
T
)
{
func
TestListWatchesCanWatch
(
t
*
testing
.
T
)
{
fieldSelectorQueryParamName
:=
api
.
FieldSelectorQueryParam
(
testapi
.
Default
.
Version
())
fieldSelectorQueryParamName
:=
unversioned
.
FieldSelectorQueryParam
(
testapi
.
Default
.
Version
())
table
:=
[]
struct
{
table
:=
[]
struct
{
rv
string
rv
string
location
string
location
string
...
...
pkg/client/unversioned/client.go
View file @
50a2c4c6
...
@@ -116,7 +116,7 @@ func (c *Client) ComponentStatuses() ComponentStatusInterface {
...
@@ -116,7 +116,7 @@ func (c *Client) ComponentStatuses() ComponentStatusInterface {
// VersionInterface has a method to retrieve the server version.
// VersionInterface has a method to retrieve the server version.
type
VersionInterface
interface
{
type
VersionInterface
interface
{
ServerVersion
()
(
*
version
.
Info
,
error
)
ServerVersion
()
(
*
version
.
Info
,
error
)
ServerAPIVersions
()
(
*
api
.
APIVersions
,
error
)
ServerAPIVersions
()
(
*
unversioned
.
APIVersions
,
error
)
}
}
// APIStatus is exposed by errors that can be converted to an api.Status object
// APIStatus is exposed by errors that can be converted to an api.Status object
...
@@ -146,12 +146,12 @@ func (c *Client) ServerVersion() (*version.Info, error) {
...
@@ -146,12 +146,12 @@ func (c *Client) ServerVersion() (*version.Info, error) {
}
}
// ServerAPIVersions retrieves and parses the list of API versions the server supports.
// ServerAPIVersions retrieves and parses the list of API versions the server supports.
func
(
c
*
Client
)
ServerAPIVersions
()
(
*
api
.
APIVersions
,
error
)
{
func
(
c
*
Client
)
ServerAPIVersions
()
(
*
unversioned
.
APIVersions
,
error
)
{
body
,
err
:=
c
.
Get
()
.
UnversionedPath
(
""
)
.
Do
()
.
Raw
()
body
,
err
:=
c
.
Get
()
.
UnversionedPath
(
""
)
.
Do
()
.
Raw
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
var
v
api
.
APIVersions
var
v
unversioned
.
APIVersions
err
=
json
.
Unmarshal
(
body
,
&
v
)
err
=
json
.
Unmarshal
(
body
,
&
v
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"got '%s': %v"
,
string
(
body
),
err
)
return
nil
,
fmt
.
Errorf
(
"got '%s': %v"
,
string
(
body
),
err
)
...
...
pkg/client/unversioned/client_test.go
View file @
50a2c4c6
...
@@ -149,9 +149,9 @@ func (c *testClient) ValidateCommon(t *testing.T, err error) {
...
@@ -149,9 +149,9 @@ func (c *testClient) ValidateCommon(t *testing.T, err error) {
validator
,
ok
:=
c
.
QueryValidator
[
key
]
validator
,
ok
:=
c
.
QueryValidator
[
key
]
if
!
ok
{
if
!
ok
{
switch
key
{
switch
key
{
case
api
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
:
case
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
:
validator
=
validateLabels
validator
=
validateLabels
case
api
.
FieldSelectorQueryParam
(
testapi
.
Default
.
Version
())
:
case
unversioned
.
FieldSelectorQueryParam
(
testapi
.
Default
.
Version
())
:
validator
=
validateFields
validator
=
validateFields
default
:
default
:
validator
=
func
(
a
,
b
string
)
bool
{
return
a
==
b
}
validator
=
func
(
a
,
b
string
)
bool
{
return
a
==
b
}
...
@@ -272,7 +272,7 @@ func TestGetServerVersion(t *testing.T) {
...
@@ -272,7 +272,7 @@ func TestGetServerVersion(t *testing.T) {
func
TestGetServerAPIVersions
(
t
*
testing
.
T
)
{
func
TestGetServerAPIVersions
(
t
*
testing
.
T
)
{
versions
:=
[]
string
{
"v1"
,
"v2"
,
"v3"
}
versions
:=
[]
string
{
"v1"
,
"v2"
,
"v3"
}
expect
:=
api
.
APIVersions
{
Versions
:
versions
}
expect
:=
unversioned
.
APIVersions
{
Versions
:
versions
}
server
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
server
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
output
,
err
:=
json
.
Marshal
(
expect
)
output
,
err
:=
json
.
Marshal
(
expect
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -300,7 +300,7 @@ func swaggerSchemaFakeServer() (*httptest.Server, error) {
...
@@ -300,7 +300,7 @@ func swaggerSchemaFakeServer() (*httptest.Server, error) {
server
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
server
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
var
resp
interface
{}
var
resp
interface
{}
if
request
==
1
{
if
request
==
1
{
resp
=
api
.
APIVersions
{
Versions
:
[]
string
{
"v1"
,
"v2"
,
"v3"
}}
resp
=
unversioned
.
APIVersions
{
Versions
:
[]
string
{
"v1"
,
"v2"
,
"v3"
}}
request
++
request
++
}
else
{
}
else
{
resp
=
swagger
.
ApiDeclaration
{}
resp
=
swagger
.
ApiDeclaration
{}
...
...
pkg/client/unversioned/events_test.go
View file @
50a2c4c6
...
@@ -34,12 +34,12 @@ func TestEventSearch(t *testing.T) {
...
@@ -34,12 +34,12 @@ func TestEventSearch(t *testing.T) {
Method
:
"GET"
,
Method
:
"GET"
,
Path
:
testapi
.
Default
.
ResourcePath
(
"events"
,
"baz"
,
""
),
Path
:
testapi
.
Default
.
ResourcePath
(
"events"
,
"baz"
,
""
),
Query
:
url
.
Values
{
Query
:
url
.
Values
{
api
.
FieldSelectorQueryParam
(
testapi
.
Default
.
Version
())
:
[]
string
{
unversioned
.
FieldSelectorQueryParam
(
testapi
.
Default
.
Version
())
:
[]
string
{
getInvolvedObjectNameFieldLabel
(
testapi
.
Default
.
Version
())
+
"=foo,"
,
getInvolvedObjectNameFieldLabel
(
testapi
.
Default
.
Version
())
+
"=foo,"
,
"involvedObject.namespace=baz,"
,
"involvedObject.namespace=baz,"
,
"involvedObject.kind=Pod"
,
"involvedObject.kind=Pod"
,
},
},
api
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
:
[]
string
{},
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
:
[]
string
{},
},
},
},
},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
EventList
{}},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
EventList
{}},
...
...
pkg/client/unversioned/experimental.go
View file @
50a2c4c6
...
@@ -63,12 +63,12 @@ func (c *ExperimentalClient) ServerVersion() (*version.Info, error) {
...
@@ -63,12 +63,12 @@ func (c *ExperimentalClient) ServerVersion() (*version.Info, error) {
// ServerAPIVersions retrieves and parses the list of experimental API versions the
// ServerAPIVersions retrieves and parses the list of experimental API versions the
// server supports.
// server supports.
func
(
c
*
ExperimentalClient
)
ServerAPIVersions
()
(
*
api
.
APIVersions
,
error
)
{
func
(
c
*
ExperimentalClient
)
ServerAPIVersions
()
(
*
unversioned
.
APIVersions
,
error
)
{
body
,
err
:=
c
.
Get
()
.
UnversionedPath
(
""
)
.
Do
()
.
Raw
()
body
,
err
:=
c
.
Get
()
.
UnversionedPath
(
""
)
.
Do
()
.
Raw
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
var
v
api
.
APIVersions
var
v
unversioned
.
APIVersions
err
=
json
.
Unmarshal
(
body
,
&
v
)
err
=
json
.
Unmarshal
(
body
,
&
v
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"got '%s': %v"
,
string
(
body
),
err
)
return
nil
,
fmt
.
Errorf
(
"got '%s': %v"
,
string
(
body
),
err
)
...
...
pkg/client/unversioned/helper_blackbox_test.go
View file @
50a2c4c6
...
@@ -90,10 +90,10 @@ func TestNegotiateVersion(t *testing.T) {
...
@@ -90,10 +90,10 @@ func TestNegotiateVersion(t *testing.T) {
Codec
:
codec
,
Codec
:
codec
,
Resp
:
&
http
.
Response
{
Resp
:
&
http
.
Response
{
StatusCode
:
200
,
StatusCode
:
200
,
Body
:
objBody
(
&
api
.
APIVersions
{
Versions
:
test
.
serverVersions
}),
Body
:
objBody
(
&
unversioned
.
APIVersions
{
Versions
:
test
.
serverVersions
}),
},
},
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
&
api
.
APIVersions
{
Versions
:
test
.
serverVersions
})},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
&
unversioned
.
APIVersions
{
Versions
:
test
.
serverVersions
})},
nil
}),
}),
}
}
c
:=
unversioned
.
NewOrDie
(
test
.
config
)
c
:=
unversioned
.
NewOrDie
(
test
.
config
)
...
...
pkg/client/unversioned/nodes_test.go
View file @
50a2c4c6
...
@@ -45,7 +45,7 @@ func TestListNodes(t *testing.T) {
...
@@ -45,7 +45,7 @@ func TestListNodes(t *testing.T) {
}
}
func
TestListNodesLabels
(
t
*
testing
.
T
)
{
func
TestListNodesLabels
(
t
*
testing
.
T
)
{
labelSelectorQueryParamName
:=
api
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
labelSelectorQueryParamName
:=
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
c
:=
&
testClient
{
c
:=
&
testClient
{
Request
:
testRequest
{
Request
:
testRequest
{
Method
:
"GET"
,
Method
:
"GET"
,
...
...
pkg/client/unversioned/pods_test.go
View file @
50a2c4c6
...
@@ -64,7 +64,7 @@ func TestListPods(t *testing.T) {
...
@@ -64,7 +64,7 @@ func TestListPods(t *testing.T) {
func
TestListPodsLabels
(
t
*
testing
.
T
)
{
func
TestListPodsLabels
(
t
*
testing
.
T
)
{
ns
:=
api
.
NamespaceDefault
ns
:=
api
.
NamespaceDefault
labelSelectorQueryParamName
:=
api
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
labelSelectorQueryParamName
:=
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
c
:=
&
testClient
{
c
:=
&
testClient
{
Request
:
testRequest
{
Request
:
testRequest
{
Method
:
"GET"
,
Method
:
"GET"
,
...
...
pkg/client/unversioned/request.go
View file @
50a2c4c6
...
@@ -372,7 +372,7 @@ func (r *Request) FieldsSelectorParam(s fields.Selector) *Request {
...
@@ -372,7 +372,7 @@ func (r *Request) FieldsSelectorParam(s fields.Selector) *Request {
r
.
err
=
err
r
.
err
=
err
return
r
return
r
}
}
return
r
.
setParam
(
api
.
FieldSelectorQueryParam
(
r
.
apiVersion
),
s2
.
String
())
return
r
.
setParam
(
unversioned
.
FieldSelectorQueryParam
(
r
.
apiVersion
),
s2
.
String
())
}
}
// LabelsSelectorParam adds the given selector as a query parameter
// LabelsSelectorParam adds the given selector as a query parameter
...
@@ -386,7 +386,7 @@ func (r *Request) LabelsSelectorParam(s labels.Selector) *Request {
...
@@ -386,7 +386,7 @@ func (r *Request) LabelsSelectorParam(s labels.Selector) *Request {
if
s
.
Empty
()
{
if
s
.
Empty
()
{
return
r
return
r
}
}
return
r
.
setParam
(
api
.
LabelSelectorQueryParam
(
r
.
apiVersion
),
s
.
String
())
return
r
.
setParam
(
unversioned
.
LabelSelectorQueryParam
(
r
.
apiVersion
),
s
.
String
())
}
}
// UintParam creates a query parameter with the given value.
// UintParam creates a query parameter with the given value.
...
...
pkg/client/unversioned/request_test.go
View file @
50a2c4c6
...
@@ -777,7 +777,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
...
@@ -777,7 +777,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
}
}
tmpStr
:=
string
(
reqBodyExpected
)
tmpStr
:=
string
(
reqBodyExpected
)
requestURL
:=
testapi
.
Default
.
ResourcePathWithPrefix
(
"foo"
,
"bar"
,
""
,
"baz"
)
requestURL
:=
testapi
.
Default
.
ResourcePathWithPrefix
(
"foo"
,
"bar"
,
""
,
"baz"
)
requestURL
+=
"?"
+
api
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
+
"=name%3Dfoo&timeout=1s"
requestURL
+=
"?"
+
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
+
"=name%3Dfoo&timeout=1s"
fakeHandler
.
ValidateRequest
(
t
,
requestURL
,
"POST"
,
&
tmpStr
)
fakeHandler
.
ValidateRequest
(
t
,
requestURL
,
"POST"
,
&
tmpStr
)
if
fakeHandler
.
RequestReceived
.
Header
[
"Authorization"
]
==
nil
{
if
fakeHandler
.
RequestReceived
.
Header
[
"Authorization"
]
==
nil
{
t
.
Errorf
(
"Request is missing authorization header: %#v"
,
*
fakeHandler
.
RequestReceived
)
t
.
Errorf
(
"Request is missing authorization header: %#v"
,
*
fakeHandler
.
RequestReceived
)
...
@@ -819,7 +819,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
...
@@ -819,7 +819,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
}
}
tmpStr
:=
string
(
reqBodyExpected
)
tmpStr
:=
string
(
reqBodyExpected
)
requestURL
:=
testapi
.
Default
.
ResourcePath
(
"foo"
,
""
,
"bar/baz"
)
requestURL
:=
testapi
.
Default
.
ResourcePath
(
"foo"
,
""
,
"bar/baz"
)
requestURL
+=
"?"
+
api
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
+
"=name%3Dfoo&timeout=1s"
requestURL
+=
"?"
+
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
+
"=name%3Dfoo&timeout=1s"
fakeHandler
.
ValidateRequest
(
t
,
requestURL
,
"POST"
,
&
tmpStr
)
fakeHandler
.
ValidateRequest
(
t
,
requestURL
,
"POST"
,
&
tmpStr
)
if
fakeHandler
.
RequestReceived
.
Header
[
"Authorization"
]
==
nil
{
if
fakeHandler
.
RequestReceived
.
Header
[
"Authorization"
]
==
nil
{
t
.
Errorf
(
"Request is missing authorization header: %#v"
,
*
fakeHandler
.
RequestReceived
)
t
.
Errorf
(
"Request is missing authorization header: %#v"
,
*
fakeHandler
.
RequestReceived
)
...
...
pkg/client/unversioned/services_test.go
View file @
50a2c4c6
...
@@ -60,7 +60,7 @@ func TestListServices(t *testing.T) {
...
@@ -60,7 +60,7 @@ func TestListServices(t *testing.T) {
func
TestListServicesLabels
(
t
*
testing
.
T
)
{
func
TestListServicesLabels
(
t
*
testing
.
T
)
{
ns
:=
api
.
NamespaceDefault
ns
:=
api
.
NamespaceDefault
labelSelectorQueryParamName
:=
api
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
labelSelectorQueryParamName
:=
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
c
:=
&
testClient
{
c
:=
&
testClient
{
Request
:
testRequest
{
Request
:
testRequest
{
Method
:
"GET"
,
Method
:
"GET"
,
...
...
pkg/client/unversioned/testclient/testclient.go
View file @
50a2c4c6
...
@@ -281,13 +281,13 @@ func (c *Fake) ServerVersion() (*version.Info, error) {
...
@@ -281,13 +281,13 @@ func (c *Fake) ServerVersion() (*version.Info, error) {
return
&
versionInfo
,
nil
return
&
versionInfo
,
nil
}
}
func
(
c
*
Fake
)
ServerAPIVersions
()
(
*
api
.
APIVersions
,
error
)
{
func
(
c
*
Fake
)
ServerAPIVersions
()
(
*
unversioned
.
APIVersions
,
error
)
{
action
:=
ActionImpl
{}
action
:=
ActionImpl
{}
action
.
Verb
=
"get"
action
.
Verb
=
"get"
action
.
Resource
=
"apiversions"
action
.
Resource
=
"apiversions"
c
.
Invokes
(
action
,
nil
)
c
.
Invokes
(
action
,
nil
)
return
&
api
.
APIVersions
{
Versions
:
registered
.
RegisteredVersions
},
nil
return
&
unversioned
.
APIVersions
{
Versions
:
registered
.
RegisteredVersions
},
nil
}
}
func
(
c
*
Fake
)
ComponentStatuses
()
client
.
ComponentStatusInterface
{
func
(
c
*
Fake
)
ComponentStatuses
()
client
.
ComponentStatusInterface
{
...
...
pkg/kubectl/cmd/apiversions.go
View file @
50a2c4c6
...
@@ -57,7 +57,7 @@ func RunApiVersions(f *cmdutil.Factory, w io.Writer) error {
...
@@ -57,7 +57,7 @@ func RunApiVersions(f *cmdutil.Factory, w io.Writer) error {
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
}
var
expAPIVersions
*
api
.
APIVersions
var
expAPIVersions
*
unversioned
.
APIVersions
expAPIVersions
,
err
=
client
.
Experimental
()
.
ServerAPIVersions
()
expAPIVersions
,
err
=
client
.
Experimental
()
.
ServerAPIVersions
()
fmt
.
Fprintf
(
w
,
"Available Server Api Versions: %#v
\n
"
,
*
apiVersions
)
fmt
.
Fprintf
(
w
,
"Available Server Api Versions: %#v
\n
"
,
*
apiVersions
)
...
...
pkg/kubectl/cmd/delete_test.go
View file @
50a2c4c6
...
@@ -416,12 +416,12 @@ func TestDeleteMultipleSelector(t *testing.T) {
...
@@ -416,12 +416,12 @@ func TestDeleteMultipleSelector(t *testing.T) {
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/pods"
&&
m
==
"GET"
:
case
p
==
"/namespaces/test/pods"
&&
m
==
"GET"
:
if
req
.
URL
.
Query
()
.
Get
(
api
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
()))
!=
"a=b"
{
if
req
.
URL
.
Query
()
.
Get
(
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
()))
!=
"a=b"
{
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
}
}
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
pods
)},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
pods
)},
nil
case
p
==
"/namespaces/test/services"
&&
m
==
"GET"
:
case
p
==
"/namespaces/test/services"
&&
m
==
"GET"
:
if
req
.
URL
.
Query
()
.
Get
(
api
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
()))
!=
"a=b"
{
if
req
.
URL
.
Query
()
.
Get
(
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
()))
!=
"a=b"
{
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
}
}
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
svc
)},
nil
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
svc
)},
nil
...
...
pkg/kubectl/cmd/get_test.go
View file @
50a2c4c6
...
@@ -507,7 +507,7 @@ func TestGetMultipleTypeObjectsWithSelector(t *testing.T) {
...
@@ -507,7 +507,7 @@ func TestGetMultipleTypeObjectsWithSelector(t *testing.T) {
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
if
req
.
URL
.
Query
()
.
Get
(
api
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
()))
!=
"a=b"
{
if
req
.
URL
.
Query
()
.
Get
(
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
()))
!=
"a=b"
{
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
}
}
switch
req
.
URL
.
Path
{
switch
req
.
URL
.
Path
{
...
@@ -633,7 +633,7 @@ func TestWatchSelector(t *testing.T) {
...
@@ -633,7 +633,7 @@ func TestWatchSelector(t *testing.T) {
tf
.
Client
=
&
fake
.
RESTClient
{
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
if
req
.
URL
.
Query
()
.
Get
(
api
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
()))
!=
"a=b"
{
if
req
.
URL
.
Query
()
.
Get
(
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
()))
!=
"a=b"
{
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
}
}
switch
req
.
URL
.
Path
{
switch
req
.
URL
.
Path
{
...
...
pkg/kubectl/resource/builder_test.go
View file @
50a2c4c6
...
@@ -504,7 +504,7 @@ func TestResourceByNameAndEmptySelector(t *testing.T) {
...
@@ -504,7 +504,7 @@ func TestResourceByNameAndEmptySelector(t *testing.T) {
func
TestSelector
(
t
*
testing
.
T
)
{
func
TestSelector
(
t
*
testing
.
T
)
{
pods
,
svc
:=
testData
()
pods
,
svc
:=
testData
()
labelKey
:=
api
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
labelKey
:=
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
b
:=
NewBuilder
(
testapi
.
Default
.
RESTMapper
(),
api
.
Scheme
,
fakeClientWith
(
""
,
t
,
map
[
string
]
string
{
b
:=
NewBuilder
(
testapi
.
Default
.
RESTMapper
(),
api
.
Scheme
,
fakeClientWith
(
""
,
t
,
map
[
string
]
string
{
"/namespaces/test/pods?"
+
labelKey
+
"=a%3Db"
:
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
pods
),
"/namespaces/test/pods?"
+
labelKey
+
"=a%3Db"
:
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
pods
),
"/namespaces/test/services?"
+
labelKey
+
"=a%3Db"
:
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
svc
),
"/namespaces/test/services?"
+
labelKey
+
"=a%3Db"
:
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
svc
),
...
@@ -905,7 +905,7 @@ func TestSingularRootScopedObject(t *testing.T) {
...
@@ -905,7 +905,7 @@ func TestSingularRootScopedObject(t *testing.T) {
func
TestListObject
(
t
*
testing
.
T
)
{
func
TestListObject
(
t
*
testing
.
T
)
{
pods
,
_
:=
testData
()
pods
,
_
:=
testData
()
labelKey
:=
api
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
labelKey
:=
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
b
:=
NewBuilder
(
testapi
.
Default
.
RESTMapper
(),
api
.
Scheme
,
fakeClientWith
(
""
,
t
,
map
[
string
]
string
{
b
:=
NewBuilder
(
testapi
.
Default
.
RESTMapper
(),
api
.
Scheme
,
fakeClientWith
(
""
,
t
,
map
[
string
]
string
{
"/namespaces/test/pods?"
+
labelKey
+
"=a%3Db"
:
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
pods
),
"/namespaces/test/pods?"
+
labelKey
+
"=a%3Db"
:
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
pods
),
}))
.
}))
.
...
@@ -938,7 +938,7 @@ func TestListObject(t *testing.T) {
...
@@ -938,7 +938,7 @@ func TestListObject(t *testing.T) {
func
TestListObjectWithDifferentVersions
(
t
*
testing
.
T
)
{
func
TestListObjectWithDifferentVersions
(
t
*
testing
.
T
)
{
pods
,
svc
:=
testData
()
pods
,
svc
:=
testData
()
labelKey
:=
api
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
labelKey
:=
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
())
obj
,
err
:=
NewBuilder
(
testapi
.
Default
.
RESTMapper
(),
api
.
Scheme
,
fakeClientWith
(
""
,
t
,
map
[
string
]
string
{
obj
,
err
:=
NewBuilder
(
testapi
.
Default
.
RESTMapper
(),
api
.
Scheme
,
fakeClientWith
(
""
,
t
,
map
[
string
]
string
{
"/namespaces/test/pods?"
+
labelKey
+
"=a%3Db"
:
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
pods
),
"/namespaces/test/pods?"
+
labelKey
+
"=a%3Db"
:
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
pods
),
"/namespaces/test/services?"
+
labelKey
+
"=a%3Db"
:
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
svc
),
"/namespaces/test/services?"
+
labelKey
+
"=a%3Db"
:
runtime
.
EncodeOrDie
(
testapi
.
Default
.
Codec
(),
svc
),
...
...
pkg/kubectl/resource/helper_test.go
View file @
50a2c4c6
...
@@ -328,7 +328,7 @@ func TestHelperList(t *testing.T) {
...
@@ -328,7 +328,7 @@ func TestHelperList(t *testing.T) {
t
.
Errorf
(
"url doesn't contain name: %#v"
,
req
.
URL
)
t
.
Errorf
(
"url doesn't contain name: %#v"
,
req
.
URL
)
return
false
return
false
}
}
if
req
.
URL
.
Query
()
.
Get
(
api
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
()))
!=
labels
.
SelectorFromSet
(
labels
.
Set
{
"foo"
:
"baz"
})
.
String
()
{
if
req
.
URL
.
Query
()
.
Get
(
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
()))
!=
labels
.
SelectorFromSet
(
labels
.
Set
{
"foo"
:
"baz"
})
.
String
()
{
t
.
Errorf
(
"url doesn't contain query parameters: %#v"
,
req
.
URL
)
t
.
Errorf
(
"url doesn't contain query parameters: %#v"
,
req
.
URL
)
return
false
return
false
}
}
...
...
test/e2e/kubectl.go
View file @
50a2c4c6
...
@@ -723,12 +723,12 @@ func checkOutput(output string, required [][]string) {
...
@@ -723,12 +723,12 @@ func checkOutput(output string, required [][]string) {
}
}
}
}
func
getAPIVersions
(
apiEndpoint
string
)
(
*
api
.
APIVersions
,
error
)
{
func
getAPIVersions
(
apiEndpoint
string
)
(
*
unversioned
.
APIVersions
,
error
)
{
body
,
err
:=
curl
(
apiEndpoint
)
body
,
err
:=
curl
(
apiEndpoint
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Failed http.Get of %s: %v"
,
apiEndpoint
,
err
)
return
nil
,
fmt
.
Errorf
(
"Failed http.Get of %s: %v"
,
apiEndpoint
,
err
)
}
}
var
apiVersions
api
.
APIVersions
var
apiVersions
unversioned
.
APIVersions
if
err
:=
json
.
Unmarshal
([]
byte
(
body
),
&
apiVersions
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
body
),
&
apiVersions
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Failed to parse /api output %s: %v"
,
body
,
err
)
return
nil
,
fmt
.
Errorf
(
"Failed to parse /api output %s: %v"
,
body
,
err
)
}
}
...
...
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