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
7831085e
Commit
7831085e
authored
Jun 02, 2017
by
carlory
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
func parseEndpointWithFallbackProtocol should check if protocol of endpoint is empty.
parent
3837d951
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
6 deletions
+9
-6
util.go
pkg/kubelet/util/util.go
+3
-1
util_linux.go
pkg/kubelet/util/util_linux.go
+2
-2
util_test.go
pkg/kubelet/util/util_test.go
+4
-3
No files found.
pkg/kubelet/util/util.go
View file @
7831085e
...
@@ -39,7 +39,9 @@ func parseEndpoint(endpoint string) (string, string, error) {
...
@@ -39,7 +39,9 @@ func parseEndpoint(endpoint string) (string, string, error) {
return
"tcp"
,
u
.
Host
,
nil
return
"tcp"
,
u
.
Host
,
nil
}
else
if
u
.
Scheme
==
"unix"
{
}
else
if
u
.
Scheme
==
"unix"
{
return
"unix"
,
u
.
Path
,
nil
return
"unix"
,
u
.
Path
,
nil
}
else
if
u
.
Scheme
==
""
{
return
""
,
""
,
fmt
.
Errorf
(
"Using %q as endpoint is deprecated, please consider using full url format"
,
endpoint
)
}
else
{
}
else
{
return
""
,
""
,
fmt
.
Errorf
(
"protocol %q not supported"
,
u
.
Scheme
)
return
u
.
Scheme
,
""
,
fmt
.
Errorf
(
"protocol %q not supported"
,
u
.
Scheme
)
}
}
}
}
pkg/kubelet/util/util_linux.go
View file @
7831085e
...
@@ -68,11 +68,11 @@ func dial(addr string, timeout time.Duration) (net.Conn, error) {
...
@@ -68,11 +68,11 @@ func dial(addr string, timeout time.Duration) (net.Conn, error) {
}
}
func
parseEndpointWithFallbackProtocol
(
endpoint
string
,
fallbackProtocol
string
)
(
protocol
string
,
addr
string
,
err
error
)
{
func
parseEndpointWithFallbackProtocol
(
endpoint
string
,
fallbackProtocol
string
)
(
protocol
string
,
addr
string
,
err
error
)
{
if
protocol
,
addr
,
err
=
parseEndpoint
(
endpoint
);
err
!=
nil
{
if
protocol
,
addr
,
err
=
parseEndpoint
(
endpoint
);
err
!=
nil
&&
protocol
==
""
{
fallbackEndpoint
:=
fallbackProtocol
+
"://"
+
endpoint
fallbackEndpoint
:=
fallbackProtocol
+
"://"
+
endpoint
protocol
,
addr
,
err
=
parseEndpoint
(
fallbackEndpoint
)
protocol
,
addr
,
err
=
parseEndpoint
(
fallbackEndpoint
)
if
err
==
nil
{
if
err
==
nil
{
glog
.
Warningf
(
"Using %q as endpoint is dep
er
cated, please consider using full url format %q."
,
endpoint
,
fallbackEndpoint
)
glog
.
Warningf
(
"Using %q as endpoint is dep
re
cated, please consider using full url format %q."
,
endpoint
,
fallbackEndpoint
)
}
}
}
}
return
return
...
...
pkg/kubelet/util/util_test.go
View file @
7831085e
...
@@ -40,8 +40,9 @@ func TestParseEndpoint(t *testing.T) {
...
@@ -40,8 +40,9 @@ func TestParseEndpoint(t *testing.T) {
expectedAddr
:
"localhost:15880"
,
expectedAddr
:
"localhost:15880"
,
},
},
{
{
endpoint
:
"tcp1://abc"
,
endpoint
:
"tcp1://abc"
,
expectError
:
true
,
expectedProtocol
:
"tcp1"
,
expectError
:
true
,
},
},
{
{
endpoint
:
"a b c"
,
endpoint
:
"a b c"
,
...
@@ -51,12 +52,12 @@ func TestParseEndpoint(t *testing.T) {
...
@@ -51,12 +52,12 @@ func TestParseEndpoint(t *testing.T) {
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
protocol
,
addr
,
err
:=
parseEndpoint
(
test
.
endpoint
)
protocol
,
addr
,
err
:=
parseEndpoint
(
test
.
endpoint
)
assert
.
Equal
(
t
,
test
.
expectedProtocol
,
protocol
)
if
test
.
expectError
{
if
test
.
expectError
{
assert
.
NotNil
(
t
,
err
,
"Expect error during parsing %q"
,
test
.
endpoint
)
assert
.
NotNil
(
t
,
err
,
"Expect error during parsing %q"
,
test
.
endpoint
)
continue
continue
}
}
assert
.
Nil
(
t
,
err
,
"Expect no error during parsing %q"
,
test
.
endpoint
)
assert
.
Nil
(
t
,
err
,
"Expect no error during parsing %q"
,
test
.
endpoint
)
assert
.
Equal
(
t
,
test
.
expectedProtocol
,
protocol
)
assert
.
Equal
(
t
,
test
.
expectedAddr
,
addr
)
assert
.
Equal
(
t
,
test
.
expectedAddr
,
addr
)
}
}
...
...
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