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
927f30b0
Commit
927f30b0
authored
Nov 12, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #17074 from krousey/timeout
Auto commit by PR queue bot
parents
eb3de9c4
eacf65dd
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
90 additions
and
93 deletions
+90
-93
fake.go
pkg/client/unversioned/fake/fake.go
+10
-4
helper_blackbox_test.go
pkg/client/unversioned/helper_blackbox_test.go
+4
-5
restclient.go
pkg/client/unversioned/restclient.go
+5
-1
annotate_test.go
pkg/kubectl/cmd/annotate_test.go
+3
-3
apply_test.go
pkg/kubectl/cmd/apply_test.go
+4
-5
attach_test.go
pkg/kubectl/cmd/attach_test.go
+3
-3
create_test.go
pkg/kubectl/cmd/create_test.go
+3
-3
delete_test.go
pkg/kubectl/cmd/delete_test.go
+12
-12
describe_test.go
pkg/kubectl/cmd/describe_test.go
+1
-1
exec_test.go
pkg/kubectl/cmd/exec_test.go
+2
-2
expose_test.go
pkg/kubectl/cmd/expose_test.go
+1
-1
get_test.go
pkg/kubectl/cmd/get_test.go
+10
-10
label_test.go
pkg/kubectl/cmd/label_test.go
+2
-2
log_test.go
pkg/kubectl/cmd/log_test.go
+1
-1
patch_test.go
pkg/kubectl/cmd/patch_test.go
+2
-2
portforward_test.go
pkg/kubectl/cmd/portforward_test.go
+2
-2
replace_test.go
pkg/kubectl/cmd/replace_test.go
+4
-4
run_test.go
pkg/kubectl/cmd/run_test.go
+1
-1
factory_test.go
pkg/kubectl/cmd/util/factory_test.go
+1
-1
builder_test.go
pkg/kubectl/resource/builder_test.go
+1
-1
helper_test.go
pkg/kubectl/resource/helper_test.go
+15
-21
rolling_updater_test.go
pkg/kubectl/rolling_updater_test.go
+2
-2
monitoring.go
test/e2e/monitoring.go
+1
-6
No files found.
pkg/client/unversioned/fake/fake.go
View file @
927f30b0
...
...
@@ -28,15 +28,21 @@ import (
"k8s.io/kubernetes/pkg/runtime"
)
type
HTTPClientFunc
func
(
*
http
.
Request
)
(
*
http
.
Response
,
error
)
func
CreateHTTPClient
(
roundTripper
func
(
*
http
.
Request
)
(
*
http
.
Response
,
error
))
*
http
.
Client
{
return
&
http
.
Client
{
Transport
:
roundTripperFunc
(
roundTripper
),
}
}
type
roundTripperFunc
func
(
*
http
.
Request
)
(
*
http
.
Response
,
error
)
func
(
f
HTTPClientFunc
)
Do
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
func
(
f
roundTripperFunc
)
RoundTrip
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
return
f
(
req
)
}
// RESTClient provides a fake RESTClient interface.
type
RESTClient
struct
{
Client
unversioned
.
HTTP
Client
Client
*
http
.
Client
Codec
runtime
.
Codec
Req
*
http
.
Request
Resp
*
http
.
Response
...
...
@@ -68,7 +74,7 @@ func (c *RESTClient) Do(req *http.Request) (*http.Response, error) {
return
nil
,
c
.
Err
}
c
.
Req
=
req
if
c
.
Client
!=
unversioned
.
HTTPClient
(
nil
)
{
if
c
.
Client
!=
nil
{
return
c
.
Client
.
Do
(
req
)
}
return
c
.
Resp
,
nil
...
...
pkg/client/unversioned/helper_blackbox_test.go
View file @
927f30b0
...
...
@@ -19,7 +19,7 @@ package unversioned_test
import
(
"bytes"
"encoding/json"
"
fmt
"
"
errors
"
"io"
"io/ioutil"
"net/http"
...
...
@@ -41,7 +41,6 @@ func objBody(object interface{}) io.ReadCloser {
}
func
TestNegotiateVersion
(
t
*
testing
.
T
)
{
refusedErr
:=
fmt
.
Errorf
(
"connection refused"
)
tests
:=
[]
struct
{
name
,
version
,
expectedVersion
string
serverVersions
[]
string
...
...
@@ -87,8 +86,8 @@ func TestNegotiateVersion(t *testing.T) {
config
:
&
unversioned
.
Config
{
Version
:
testapi
.
Default
.
Version
()},
serverVersions
:
[]
string
{
"version1"
},
clientVersions
:
[]
string
{
"version1"
,
testapi
.
Default
.
Version
()},
sendErr
:
refusedErr
,
expectErr
:
func
(
err
error
)
bool
{
return
err
==
refusedErr
},
sendErr
:
errors
.
New
(
"connection refused"
)
,
expectErr
:
func
(
err
error
)
bool
{
return
strings
.
Contains
(
err
.
Error
(),
"connection refused"
)
},
},
}
codec
:=
testapi
.
Default
.
Codec
()
...
...
@@ -100,7 +99,7 @@ func TestNegotiateVersion(t *testing.T) {
StatusCode
:
200
,
Body
:
objBody
(
&
unversionedapi
.
APIVersions
{
Versions
:
test
.
serverVersions
}),
},
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
if
test
.
sendErr
!=
nil
{
return
nil
,
test
.
sendErr
}
...
...
pkg/client/unversioned/restclient.go
View file @
927f30b0
...
...
@@ -17,6 +17,7 @@ limitations under the License.
package
unversioned
import
(
"net/http"
"net/url"
"strings"
...
...
@@ -43,7 +44,7 @@ type RESTClient struct {
// Set specific behavior of the client. If not set http.DefaultClient will be
// used.
Client
HTTP
Client
Client
*
http
.
Client
// TODO extract this into a wrapper interface via the RESTClient interface in kubectl.
Throttle
util
.
RateLimiter
...
...
@@ -88,6 +89,9 @@ func (c *RESTClient) Verb(verb string) *Request {
if
c
.
Throttle
!=
nil
{
c
.
Throttle
.
Accept
()
}
if
c
.
Client
==
nil
{
return
NewRequest
(
nil
,
verb
,
c
.
baseURL
,
c
.
apiVersion
,
c
.
Codec
)
}
return
NewRequest
(
c
.
Client
,
verb
,
c
.
baseURL
,
c
.
apiVersion
,
c
.
Codec
)
}
...
...
pkg/kubectl/cmd/annotate_test.go
View file @
927f30b0
...
...
@@ -423,7 +423,7 @@ func TestAnnotateObject(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
req
.
Method
{
case
"GET"
:
switch
req
.
URL
.
Path
{
...
...
@@ -470,7 +470,7 @@ func TestAnnotateObjectFromFile(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
req
.
Method
{
case
"GET"
:
switch
req
.
URL
.
Path
{
...
...
@@ -518,7 +518,7 @@ func TestAnnotateMultipleObjects(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
req
.
Method
{
case
"GET"
:
switch
req
.
URL
.
Path
{
...
...
pkg/kubectl/cmd/apply_test.go
View file @
927f30b0
...
...
@@ -28,7 +28,6 @@ import (
"github.com/spf13/cobra"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/client/unversioned/fake"
"k8s.io/kubernetes/pkg/kubectl"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
...
...
@@ -178,7 +177,7 @@ func TestApplyObject(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
pathRC
&&
m
==
"GET"
:
bodyRC
:=
ioutil
.
NopCloser
(
bytes
.
NewReader
(
currentRC
))
...
...
@@ -217,10 +216,10 @@ func TestApplyNonExistObject(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
pathNameRC
&&
m
==
"GET"
:
return
&
http
.
Response
{
StatusCode
:
404
},
errors
.
NewNotFound
(
"ReplicationController"
,
""
)
return
&
http
.
Response
{
StatusCode
:
404
,
Body
:
ioutil
.
NopCloser
(
bytes
.
NewReader
(
nil
))},
nil
case
p
==
pathRC
&&
m
==
"POST"
:
bodyRC
:=
ioutil
.
NopCloser
(
bytes
.
NewReader
(
currentRC
))
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
bodyRC
},
nil
...
...
@@ -256,7 +255,7 @@ func TestApplyMultipleObject(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
pathRC
&&
m
==
"GET"
:
bodyRC
:=
ioutil
.
NopCloser
(
bytes
.
NewReader
(
currentRC
))
...
...
pkg/kubectl/cmd/attach_test.go
View file @
927f30b0
...
...
@@ -83,7 +83,7 @@ func TestPodAndContainerAttach(t *testing.T) {
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
return
nil
,
nil
}),
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
return
nil
,
nil
}),
}
tf
.
Namespace
=
"test"
tf
.
ClientConfig
=
&
client
.
Config
{}
...
...
@@ -136,7 +136,7 @@ func TestAttach(t *testing.T) {
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
test
.
podPath
&&
m
==
"GET"
:
body
:=
objBody
(
codec
,
test
.
pod
)
...
...
@@ -214,7 +214,7 @@ func TestAttachWarnings(t *testing.T) {
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
test
.
podPath
&&
m
==
"GET"
:
body
:=
objBody
(
codec
,
test
.
pod
)
...
...
pkg/kubectl/cmd/create_test.go
View file @
927f30b0
...
...
@@ -44,7 +44,7 @@ func TestCreateObject(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/replicationcontrollers"
&&
m
==
"POST"
:
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
...
...
@@ -75,7 +75,7 @@ func TestCreateMultipleObject(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/services"
&&
m
==
"POST"
:
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
...
...
@@ -110,7 +110,7 @@ func TestCreateDirectory(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/services"
&&
m
==
"POST"
:
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
...
...
pkg/kubectl/cmd/delete_test.go
View file @
927f30b0
...
...
@@ -36,7 +36,7 @@ func TestDeleteObjectByTuple(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/replicationcontrollers/redis-master-controller"
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
...
...
@@ -68,7 +68,7 @@ func TestDeleteNamedObject(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/replicationcontrollers/redis-master-controller"
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
...
...
@@ -100,7 +100,7 @@ func TestDeleteObject(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/replicationcontrollers/redis-master"
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
...
...
@@ -130,7 +130,7 @@ func TestDeleteObjectNotFound(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/replicationcontrollers/redis-master"
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
404
,
Body
:
stringBody
(
""
)},
nil
...
...
@@ -160,7 +160,7 @@ func TestDeleteObjectIgnoreNotFound(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/replicationcontrollers/redis-master"
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
404
,
Body
:
stringBody
(
""
)},
nil
...
...
@@ -197,7 +197,7 @@ func TestDeleteAllNotFound(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/services"
&&
m
==
"GET"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
svc
)},
nil
...
...
@@ -239,7 +239,7 @@ func TestDeleteAllIgnoreNotFound(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/services"
&&
m
==
"GET"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
svc
)},
nil
...
...
@@ -274,7 +274,7 @@ func TestDeleteMultipleObject(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/replicationcontrollers/redis-master"
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
...
...
@@ -308,7 +308,7 @@ func TestDeleteMultipleObjectContinueOnMissing(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/replicationcontrollers/redis-master"
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
404
,
Body
:
stringBody
(
""
)},
nil
...
...
@@ -345,7 +345,7 @@ func TestDeleteMultipleResourcesWithTheSameName(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/replicationcontrollers/baz"
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
...
...
@@ -381,7 +381,7 @@ func TestDeleteDirectory(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
strings
.
HasPrefix
(
p
,
"/namespaces/test/services/"
)
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
...
...
@@ -414,7 +414,7 @@ func TestDeleteMultipleSelector(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/pods"
&&
m
==
"GET"
:
if
req
.
URL
.
Query
()
.
Get
(
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
()))
!=
"a=b"
{
...
...
pkg/kubectl/cmd/describe_test.go
View file @
927f30b0
...
...
@@ -56,7 +56,7 @@ func TestDescribeObject(t *testing.T) {
tf
.
Describer
=
d
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/replicationcontrollers/redis-master"
&&
m
==
"GET"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
...
...
pkg/kubectl/cmd/exec_test.go
View file @
927f30b0
...
...
@@ -126,7 +126,7 @@ func TestPodAndContainer(t *testing.T) {
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
return
nil
,
nil
}),
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
return
nil
,
nil
}),
}
tf
.
Namespace
=
"test"
tf
.
ClientConfig
=
&
client
.
Config
{}
...
...
@@ -182,7 +182,7 @@ func TestExec(t *testing.T) {
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
test
.
podPath
&&
m
==
"GET"
:
body
:=
objBody
(
codec
,
test
.
pod
)
...
...
pkg/kubectl/cmd/expose_test.go
View file @
927f30b0
...
...
@@ -341,7 +341,7 @@ func TestRunExposeService(t *testing.T) {
tf
.
Printer
=
&
kubectl
.
JSONPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
test
.
calls
[
m
]
&&
m
==
"GET"
:
return
&
http
.
Response
{
StatusCode
:
test
.
status
,
Body
:
objBody
(
codec
,
test
.
input
)},
nil
...
...
pkg/kubectl/cmd/get_test.go
View file @
927f30b0
...
...
@@ -179,7 +179,7 @@ func TestGetUnknownSchemaObjectListGeneric(t *testing.T) {
apiCodec
:=
runtime
.
CodecFor
(
api
.
Scheme
,
testapi
.
Default
.
Version
())
regularClient
:=
&
fake
.
RESTClient
{
Codec
:
apiCodec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
apiCodec
,
&
api
.
ReplicationController
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}})},
nil
}),
}
...
...
@@ -188,7 +188,7 @@ func TestGetUnknownSchemaObjectListGeneric(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
internalType
{
Name
:
"foo"
})},
nil
}),
}
...
...
@@ -407,7 +407,7 @@ func TestGetMultipleTypeObjects(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
req
.
URL
.
Path
{
case
"/namespaces/test/pods"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
pods
)},
nil
...
...
@@ -446,7 +446,7 @@ func TestGetMultipleTypeObjectsAsList(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
req
.
URL
.
Path
{
case
"/namespaces/test/pods"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
pods
)},
nil
...
...
@@ -506,7 +506,7 @@ func TestGetMultipleTypeObjectsWithSelector(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
if
req
.
URL
.
Query
()
.
Get
(
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
()))
!=
"a=b"
{
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
}
...
...
@@ -558,7 +558,7 @@ func TestGetMultipleTypeObjectsWithDirectReference(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
req
.
URL
.
Path
{
case
"/nodes/foo"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
node
)},
nil
...
...
@@ -632,7 +632,7 @@ func TestWatchSelector(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
if
req
.
URL
.
Query
()
.
Get
(
unversioned
.
LabelSelectorQueryParam
(
testapi
.
Default
.
Version
()))
!=
"a=b"
{
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
}
...
...
@@ -674,7 +674,7 @@ func TestWatchResource(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
req
.
URL
.
Path
{
case
"/namespaces/test/pods/foo"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
pods
[
0
])},
nil
...
...
@@ -712,7 +712,7 @@ func TestWatchResourceIdentifiedByFile(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
req
.
URL
.
Path
{
case
"/namespaces/test/pods/cassandra"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
pods
[
0
])},
nil
...
...
@@ -751,7 +751,7 @@ func TestWatchOnlyResource(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
req
.
URL
.
Path
{
case
"/namespaces/test/pods/foo"
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
pods
[
0
])},
nil
...
...
pkg/kubectl/cmd/label_test.go
View file @
927f30b0
...
...
@@ -329,7 +329,7 @@ func TestLabelForResourceFromFile(t *testing.T) {
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
req
.
Method
{
case
"GET"
:
switch
req
.
URL
.
Path
{
...
...
@@ -376,7 +376,7 @@ func TestLabelMultipleObjects(t *testing.T) {
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
req
.
Method
{
case
"GET"
:
switch
req
.
URL
.
Path
{
...
...
pkg/kubectl/cmd/log_test.go
View file @
927f30b0
...
...
@@ -49,7 +49,7 @@ func TestLog(t *testing.T) {
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
test
.
podPath
&&
m
==
"GET"
:
body
:=
objBody
(
codec
,
test
.
pod
)
...
...
pkg/kubectl/cmd/patch_test.go
View file @
927f30b0
...
...
@@ -31,7 +31,7 @@ func TestPatchObject(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/services/frontend"
&&
(
m
==
"PATCH"
||
m
==
"GET"
)
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
...
...
@@ -63,7 +63,7 @@ func TestPatchObjectFromFile(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/services/frontend"
&&
(
m
==
"PATCH"
||
m
==
"GET"
)
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
...
...
pkg/kubectl/cmd/portforward_test.go
View file @
927f30b0
...
...
@@ -70,7 +70,7 @@ func TestPortForward(t *testing.T) {
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
test
.
podPath
&&
m
==
"GET"
:
body
:=
objBody
(
codec
,
test
.
pod
)
...
...
@@ -140,7 +140,7 @@ func TestPortForwardWithPFlag(t *testing.T) {
f
,
tf
,
codec
:=
NewAPIFactory
()
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
test
.
podPath
&&
m
==
"GET"
:
body
:=
objBody
(
codec
,
test
.
pod
)
...
...
pkg/kubectl/cmd/replace_test.go
View file @
927f30b0
...
...
@@ -32,7 +32,7 @@ func TestReplaceObject(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/replicationcontrollers/redis-master"
&&
(
m
==
"GET"
||
m
==
"PUT"
||
m
==
"DELETE"
)
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
...
...
@@ -75,7 +75,7 @@ func TestReplaceMultipleObject(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/replicationcontrollers/redis-master"
&&
(
m
==
"GET"
||
m
==
"PUT"
||
m
==
"DELETE"
)
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
rc
.
Items
[
0
])},
nil
...
...
@@ -122,7 +122,7 @@ func TestReplaceDirectory(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
strings
.
HasPrefix
(
p
,
"/namespaces/test/services/"
)
&&
(
m
==
"GET"
||
m
==
"PUT"
||
m
==
"DELETE"
)
:
return
&
http
.
Response
{
StatusCode
:
200
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
...
...
@@ -169,7 +169,7 @@ func TestForceReplaceObjectNotFound(t *testing.T) {
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
"/namespaces/test/replicationcontrollers/redis-master"
&&
m
==
"DELETE"
:
return
&
http
.
Response
{
StatusCode
:
404
,
Body
:
stringBody
(
""
)},
nil
...
...
pkg/kubectl/cmd/run_test.go
View file @
927f30b0
...
...
@@ -203,7 +203,7 @@ func TestGenerateService(t *testing.T) {
tf
.
ClientConfig
=
&
client
.
Config
{
Version
:
testapi
.
Default
.
Version
()}
tf
.
Client
=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
test
.
expectPOST
&&
m
==
"POST"
&&
p
==
"/namespaces/namespace/services"
:
sawPOST
=
true
...
...
pkg/kubectl/cmd/util/factory_test.go
View file @
927f30b0
...
...
@@ -230,7 +230,7 @@ func TestValidateCachesSchema(t *testing.T) {
c
:=
&
fake
.
RESTClient
{
Codec
:
testapi
.
Default
.
Codec
(),
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
strings
.
HasPrefix
(
p
,
"/swaggerapi"
)
&&
m
==
"GET"
:
requests
[
p
]
=
requests
[
p
]
+
1
...
...
pkg/kubectl/resource/builder_test.go
View file @
927f30b0
...
...
@@ -64,7 +64,7 @@ func fakeClientWith(testName string, t *testing.T, data map[string]string) Clien
return
ClientMapperFunc
(
func
(
*
meta
.
RESTMapping
)
(
RESTClient
,
error
)
{
return
&
fake
.
RESTClient
{
Codec
:
testapi
.
Default
.
Codec
(),
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
p
:=
req
.
URL
.
Path
q
:=
req
.
URL
.
RawQuery
if
len
(
q
)
!=
0
{
...
...
pkg/kubectl/resource/helper_test.go
View file @
927f30b0
...
...
@@ -131,11 +131,10 @@ func TestHelperCreate(t *testing.T) {
}
tests
:=
[]
struct
{
Resp
*
http
.
Response
RespFunc
fake
.
HTTPClientFunc
HttpErr
error
Modify
bool
Object
runtime
.
Object
Resp
*
http
.
Response
HttpErr
error
Modify
bool
Object
runtime
.
Object
ExpectObject
runtime
.
Object
Err
bool
...
...
@@ -188,9 +187,6 @@ func TestHelperCreate(t *testing.T) {
Resp
:
test
.
Resp
,
Err
:
test
.
HttpErr
,
}
if
test
.
RespFunc
!=
nil
{
client
.
Client
=
test
.
RespFunc
}
modifier
:=
&
Helper
{
RESTClient
:
client
,
Codec
:
testapi
.
Default
.
Codec
(),
...
...
@@ -380,11 +376,11 @@ func TestHelperReplace(t *testing.T) {
}
tests
:=
[]
struct
{
Resp
*
http
.
Response
RespFunc
fake
.
HTTPClientFunc
HttpErr
error
Overwrite
bool
Object
runtime
.
Object
Resp
*
http
.
Response
HTTPClient
*
http
.
Client
HttpErr
error
Overwrite
bool
Object
runtime
.
Object
ExpectObject
runtime
.
Object
Err
bool
...
...
@@ -421,12 +417,12 @@ func TestHelperReplace(t *testing.T) {
Spec
:
apitesting
.
DeepEqualSafePodSpec
(),
},
Overwrite
:
true
,
RespFunc
:
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
HTTPClient
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
if
req
.
Method
==
"PUT"
{
return
&
http
.
Response
{
StatusCode
:
http
.
StatusOK
,
Body
:
objBody
(
&
unversioned
.
Status
{
Status
:
unversioned
.
StatusSuccess
})},
nil
}
return
&
http
.
Response
{
StatusCode
:
http
.
StatusOK
,
Body
:
objBody
(
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
ResourceVersion
:
"10"
}})},
nil
},
}
)
,
Req
:
expectPut
,
},
{
...
...
@@ -438,12 +434,10 @@ func TestHelperReplace(t *testing.T) {
}
for
i
,
test
:=
range
tests
{
client
:=
&
fake
.
RESTClient
{
Codec
:
testapi
.
Default
.
Codec
(),
Resp
:
test
.
Resp
,
Err
:
test
.
HttpErr
,
}
if
test
.
RespFunc
!=
nil
{
client
.
Client
=
test
.
RespFunc
Client
:
test
.
HTTPClient
,
Codec
:
testapi
.
Default
.
Codec
(),
Resp
:
test
.
Resp
,
Err
:
test
.
HttpErr
,
}
modifier
:=
&
Helper
{
RESTClient
:
client
,
...
...
pkg/kubectl/rolling_updater_test.go
View file @
927f30b0
...
...
@@ -1051,7 +1051,7 @@ func TestUpdateWithRetries(t *testing.T) {
}
fakeClient
:=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
testapi
.
Default
.
ResourcePath
(
"replicationcontrollers"
,
"default"
,
"rc"
)
&&
m
==
"PUT"
:
update
:=
updates
[
0
]
...
...
@@ -1142,7 +1142,7 @@ func TestAddDeploymentHash(t *testing.T) {
updatedRc
:=
false
fakeClient
:=
&
fake
.
RESTClient
{
Codec
:
codec
,
Client
:
fake
.
HTTPClientFunc
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
switch
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
;
{
case
p
==
testapi
.
Default
.
ResourcePath
(
"pods"
,
"default"
,
""
)
&&
m
==
"GET"
:
if
req
.
URL
.
RawQuery
!=
"labelSelector=foo%3Dbar"
{
...
...
test/e2e/monitoring.go
View file @
927f30b0
...
...
@@ -18,7 +18,6 @@ package e2e
import
(
"fmt"
"net/http"
"net/url"
"time"
...
...
@@ -133,10 +132,6 @@ func getAllNodesInCluster(c *client.Client) ([]string, error) {
}
func
getInfluxdbClient
(
c
*
client
.
Client
)
(
*
influxdb
.
Client
,
error
)
{
kubeMasterHttpClient
,
ok
:=
c
.
Client
.
(
*
http
.
Client
)
if
!
ok
{
Failf
(
"failed to get master http client"
)
}
proxyUrl
:=
fmt
.
Sprintf
(
"%s/api/v1/proxy/namespaces/%s/services/%s:api/"
,
getMasterHost
(),
api
.
NamespaceSystem
,
influxdbService
)
config
:=
&
influxdb
.
ClientConfig
{
Host
:
proxyUrl
,
...
...
@@ -144,7 +139,7 @@ func getInfluxdbClient(c *client.Client) (*influxdb.Client, error) {
Username
:
influxdbUser
,
Password
:
influxdbPW
,
Database
:
influxdbDatabaseName
,
HttpClient
:
kubeMasterHttp
Client
,
HttpClient
:
c
.
Client
,
IsSecure
:
true
,
}
return
influxdb
.
NewClient
(
config
)
...
...
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