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
d45fbce3
Unverified
Commit
d45fbce3
authored
Apr 17, 2018
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
distinguish custom dialers in transport cache
parent
fe23fa3e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
cache.go
staging/src/k8s.io/client-go/transport/cache.go
+4
-2
cache_test.go
staging/src/k8s.io/client-go/transport/cache_test.go
+12
-5
No files found.
staging/src/k8s.io/client-go/transport/cache.go
View file @
d45fbce3
...
@@ -44,6 +44,7 @@ type tlsCacheKey struct {
...
@@ -44,6 +44,7 @@ type tlsCacheKey struct {
certData
string
certData
string
keyData
string
keyData
string
serverName
string
serverName
string
dial
string
}
}
func
(
t
tlsCacheKey
)
String
()
string
{
func
(
t
tlsCacheKey
)
String
()
string
{
...
@@ -51,7 +52,7 @@ func (t tlsCacheKey) String() string {
...
@@ -51,7 +52,7 @@ func (t tlsCacheKey) String() string {
if
len
(
t
.
keyData
)
>
0
{
if
len
(
t
.
keyData
)
>
0
{
keyText
=
"<redacted>"
keyText
=
"<redacted>"
}
}
return
fmt
.
Sprintf
(
"insecure:%v, caData:%#v, certData:%#v, keyData:%s, serverName:%s
"
,
t
.
insecure
,
t
.
caData
,
t
.
certData
,
keyText
,
t
.
serverName
)
return
fmt
.
Sprintf
(
"insecure:%v, caData:%#v, certData:%#v, keyData:%s, serverName:%s
, dial:%s"
,
t
.
insecure
,
t
.
caData
,
t
.
certData
,
keyText
,
t
.
serverName
,
t
.
dial
)
}
}
func
(
c
*
tlsTransportCache
)
get
(
config
*
Config
)
(
http
.
RoundTripper
,
error
)
{
func
(
c
*
tlsTransportCache
)
get
(
config
*
Config
)
(
http
.
RoundTripper
,
error
)
{
...
@@ -75,7 +76,7 @@ func (c *tlsTransportCache) get(config *Config) (http.RoundTripper, error) {
...
@@ -75,7 +76,7 @@ func (c *tlsTransportCache) get(config *Config) (http.RoundTripper, error) {
return
nil
,
err
return
nil
,
err
}
}
// The options didn't require a custom TLS config
// The options didn't require a custom TLS config
if
tlsConfig
==
nil
{
if
tlsConfig
==
nil
&&
config
.
Dial
==
nil
{
return
http
.
DefaultTransport
,
nil
return
http
.
DefaultTransport
,
nil
}
}
...
@@ -109,5 +110,6 @@ func tlsConfigKey(c *Config) (tlsCacheKey, error) {
...
@@ -109,5 +110,6 @@ func tlsConfigKey(c *Config) (tlsCacheKey, error) {
certData
:
string
(
c
.
TLS
.
CertData
),
certData
:
string
(
c
.
TLS
.
CertData
),
keyData
:
string
(
c
.
TLS
.
KeyData
),
keyData
:
string
(
c
.
TLS
.
KeyData
),
serverName
:
c
.
TLS
.
ServerName
,
serverName
:
c
.
TLS
.
ServerName
,
dial
:
fmt
.
Sprintf
(
"%p"
,
c
.
Dial
),
},
nil
},
nil
}
}
staging/src/k8s.io/client-go/transport/cache_test.go
View file @
d45fbce3
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
transport
package
transport
import
(
import
(
"net"
"net/http"
"net/http"
"testing"
"testing"
)
)
...
@@ -53,6 +54,8 @@ func TestTLSConfigKey(t *testing.T) {
...
@@ -53,6 +54,8 @@ func TestTLSConfigKey(t *testing.T) {
// Make sure config fields that affect the tls config affect the cache key
// Make sure config fields that affect the tls config affect the cache key
uniqueConfigurations
:=
map
[
string
]
*
Config
{
uniqueConfigurations
:=
map
[
string
]
*
Config
{
"no tls"
:
{},
"no tls"
:
{},
"dialer"
:
{
Dial
:
net
.
Dial
},
"dialer2"
:
{
Dial
:
func
(
network
,
address
string
)
(
net
.
Conn
,
error
)
{
return
nil
,
nil
}},
"insecure"
:
{
TLS
:
TLSConfig
{
Insecure
:
true
}},
"insecure"
:
{
TLS
:
TLSConfig
{
Insecure
:
true
}},
"cadata 1"
:
{
TLS
:
TLSConfig
{
CAData
:
[]
byte
{
1
}}},
"cadata 1"
:
{
TLS
:
TLSConfig
{
CAData
:
[]
byte
{
1
}}},
"cadata 2"
:
{
TLS
:
TLSConfig
{
CAData
:
[]
byte
{
2
}}},
"cadata 2"
:
{
TLS
:
TLSConfig
{
CAData
:
[]
byte
{
2
}}},
...
@@ -104,11 +107,6 @@ func TestTLSConfigKey(t *testing.T) {
...
@@ -104,11 +107,6 @@ func TestTLSConfigKey(t *testing.T) {
}
}
for
nameA
,
valueA
:=
range
uniqueConfigurations
{
for
nameA
,
valueA
:=
range
uniqueConfigurations
{
for
nameB
,
valueB
:=
range
uniqueConfigurations
{
for
nameB
,
valueB
:=
range
uniqueConfigurations
{
// Don't compare to ourselves
if
nameA
==
nameB
{
continue
}
keyA
,
err
:=
tlsConfigKey
(
valueA
)
keyA
,
err
:=
tlsConfigKey
(
valueA
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Unexpected error for %q: %v"
,
nameA
,
err
)
t
.
Errorf
(
"Unexpected error for %q: %v"
,
nameA
,
err
)
...
@@ -119,6 +117,15 @@ func TestTLSConfigKey(t *testing.T) {
...
@@ -119,6 +117,15 @@ func TestTLSConfigKey(t *testing.T) {
t
.
Errorf
(
"Unexpected error for %q: %v"
,
nameB
,
err
)
t
.
Errorf
(
"Unexpected error for %q: %v"
,
nameB
,
err
)
continue
continue
}
}
// Make sure we get the same key on the same config
if
nameA
==
nameB
{
if
keyA
!=
keyB
{
t
.
Errorf
(
"Expected identical cache keys for %q and %q, got:
\n\t
%s
\n\t
%s"
,
nameA
,
nameB
,
keyA
,
keyB
)
}
continue
}
if
keyA
==
keyB
{
if
keyA
==
keyB
{
t
.
Errorf
(
"Expected unique cache keys for %q and %q, got:
\n\t
%s
\n\t
%s"
,
nameA
,
nameB
,
keyA
,
keyB
)
t
.
Errorf
(
"Expected unique cache keys for %q and %q, got:
\n\t
%s
\n\t
%s"
,
nameA
,
nameB
,
keyA
,
keyB
)
continue
continue
...
...
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