Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
7323fa04
M
minikube
项目概览
Chu Peng 楚鹏
/
minikube
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
minikube
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7323fa04
编写于
10月 29, 2016
作者:
M
Matt Rickard
提交者:
GitHub
10月 29, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #773 from dlorenc/netip
Add support for net.IP to the configurator.
上级
620b2d49
e8d8cc0b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
0 deletion
+12
-0
pkg/util/config.go
pkg/util/config.go
+7
-0
pkg/util/config_test.go
pkg/util/config_test.go
+5
-0
未找到文件。
pkg/util/config.go
浏览文件 @
7323fa04
...
...
@@ -18,6 +18,7 @@ package util
import
(
"fmt"
"net"
"reflect"
"strconv"
"strings"
...
...
@@ -65,6 +66,12 @@ func setElement(e reflect.Value, v string) error {
return
fmt
.
Errorf
(
"Error converting input %s to a bool: %s"
,
b
,
err
)
}
e
.
SetBool
(
b
)
case
net
.
IP
:
ip
:=
net
.
ParseIP
(
v
)
if
ip
==
nil
{
return
fmt
.
Errorf
(
"Error converting input %s to an IP."
,
v
)
}
e
.
Set
(
reflect
.
ValueOf
(
ip
))
default
:
return
fmt
.
Errorf
(
"Unable to set type %s."
,
t
)
}
...
...
pkg/util/config_test.go
浏览文件 @
7323fa04
...
...
@@ -18,6 +18,7 @@ package util
import
(
"math"
"net"
"testing"
)
...
...
@@ -47,6 +48,7 @@ type subConfig3 struct {
N
int
O
float32
P
bool
Q
net
.
IP
}
func
buildConfig
()
testConfig
{
...
...
@@ -62,6 +64,8 @@ func buildConfig() testConfig {
M
:
"baz"
,
N
:
3
,
O
:
3.3
,
P
:
false
,
Q
:
net
.
ParseIP
(
"12.34.56.78"
),
},
},
E
:
&
subConfig2
{
...
...
@@ -159,6 +163,7 @@ func TestSetElement(t *testing.T) {
{
"E.L"
,
"1.234"
,
func
(
t
testConfig
)
bool
{
return
checkFloats
(
float64
(
t
.
E
.
L
),
1.234
)
}},
{
"D.I.P"
,
"true"
,
func
(
t
testConfig
)
bool
{
return
bool
(
t
.
D
.
I
.
P
)
==
true
}},
{
"D.I.P"
,
"false"
,
func
(
t
testConfig
)
bool
{
return
bool
(
t
.
D
.
I
.
P
)
==
false
}},
{
"D.I.Q"
,
"11.22.33.44"
,
func
(
t
testConfig
)
bool
{
return
t
.
D
.
I
.
Q
.
Equal
(
net
.
ParseIP
(
"11.22.33.44"
))
}},
}
{
a
:=
buildConfig
()
if
err
:=
FindAndSet
(
tc
.
path
,
&
a
,
tc
.
newval
);
err
!=
nil
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录