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
f82b1ba9
Unverified
Commit
f82b1ba9
authored
Nov 17, 2017
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow constructing spdy executor from existing transports
parent
56e62b68
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
13 deletions
+21
-13
remotecommand_test.go
pkg/client/tests/remotecommand_test.go
+6
-1
BUILD
staging/src/k8s.io/client-go/tools/remotecommand/BUILD
+0
-1
remotecommand.go
...src/k8s.io/client-go/tools/remotecommand/remotecommand.go
+15
-11
No files found.
pkg/client/tests/remotecommand_test.go
View file @
f82b1ba9
...
...
@@ -256,7 +256,12 @@ func TestStream(t *testing.T) {
conf
:=
&
restclient
.
Config
{
Host
:
server
.
URL
,
}
e
,
err
:=
remoteclient
.
NewSPDYExecutorForProtocols
(
conf
,
"POST"
,
req
.
URL
(),
testCase
.
ClientProtocols
...
)
transport
,
upgradeTransport
,
err
:=
spdy
.
RoundTripperFor
(
conf
)
if
err
!=
nil
{
t
.
Errorf
(
"%s: unexpected error: %v"
,
name
,
err
)
continue
}
e
,
err
:=
remoteclient
.
NewSPDYExecutorForProtocols
(
transport
,
upgradeTransport
,
"POST"
,
req
.
URL
(),
testCase
.
ClientProtocols
...
)
if
err
!=
nil
{
t
.
Errorf
(
"%s: unexpected error: %v"
,
name
,
err
)
continue
...
...
staging/src/k8s.io/client-go/tools/remotecommand/BUILD
View file @
f82b1ba9
...
...
@@ -42,7 +42,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/util/remotecommand:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/client-go/transport:go_default_library",
"//vendor/k8s.io/client-go/transport/spdy:go_default_library",
"//vendor/k8s.io/client-go/util/exec:go_default_library",
],
...
...
staging/src/k8s.io/client-go/tools/remotecommand/remotecommand.go
View file @
f82b1ba9
...
...
@@ -27,7 +27,6 @@ import (
"k8s.io/apimachinery/pkg/util/httpstream"
"k8s.io/apimachinery/pkg/util/remotecommand"
restclient
"k8s.io/client-go/rest"
"k8s.io/client-go/transport"
spdy
"k8s.io/client-go/transport/spdy"
)
...
...
@@ -72,8 +71,18 @@ type streamExecutor struct {
// NewSPDYExecutor connects to the provided server and upgrades the connection to
// multiplexed bidirectional streams.
func
NewSPDYExecutor
(
config
*
restclient
.
Config
,
method
string
,
url
*
url
.
URL
)
(
Executor
,
error
)
{
wrapper
,
upgradeRoundTripper
,
err
:=
spdy
.
RoundTripperFor
(
config
)
if
err
!=
nil
{
return
nil
,
err
}
return
NewSPDYExecutorForTransports
(
wrapper
,
upgradeRoundTripper
,
method
,
url
)
}
// NewSPDYExecutorForTransports connects to the provided server using the given transport,
// upgrades the response using the given upgrader to multiplexed bidirectional streams.
func
NewSPDYExecutorForTransports
(
transport
http
.
RoundTripper
,
upgrader
spdy
.
Upgrader
,
method
string
,
url
*
url
.
URL
)
(
Executor
,
error
)
{
return
NewSPDYExecutorForProtocols
(
config
,
method
,
url
,
transport
,
upgrader
,
method
,
url
,
remotecommand
.
StreamProtocolV4Name
,
remotecommand
.
StreamProtocolV3Name
,
remotecommand
.
StreamProtocolV2Name
,
...
...
@@ -83,16 +92,11 @@ func NewSPDYExecutor(config *restclient.Config, method string, url *url.URL) (Ex
// NewSPDYExecutorForProtocols connects to the provided server and upgrades the connection to
// multiplexed bidirectional streams using only the provided protocols. Exposed for testing, most
// callers should use NewSPDYExecutor.
func
NewSPDYExecutorForProtocols
(
config
*
restclient
.
Config
,
method
string
,
url
*
url
.
URL
,
protocols
...
string
)
(
Executor
,
error
)
{
wrapper
,
upgradeRoundTripper
,
err
:=
spdy
.
RoundTripperFor
(
config
)
if
err
!=
nil
{
return
nil
,
err
}
wrapper
=
transport
.
DebugWrappers
(
wrapper
)
// callers should use NewSPDYExecutor or NewSPDYExecutorForTransports.
func
NewSPDYExecutorForProtocols
(
transport
http
.
RoundTripper
,
upgrader
spdy
.
Upgrader
,
method
string
,
url
*
url
.
URL
,
protocols
...
string
)
(
Executor
,
error
)
{
return
&
streamExecutor
{
upgrader
:
upgrade
RoundTrippe
r
,
transport
:
wrapper
,
upgrader
:
upgrader
,
transport
:
transport
,
method
:
method
,
url
:
url
,
protocols
:
protocols
,
...
...
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