-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove IsValidIP, IsValidCIDR & IsValidVLANTag #67
Conversation
Remove IsValidIP which can be replaced by https://godoc.org/gopkg.in/go-playground/validator.v9#hdr-Internet_Protocol_Address_IP
Codecov Report
@@ Coverage Diff @@
## master #67 +/- ##
==========================================
- Coverage 87.68% 87.11% -0.58%
==========================================
Files 7 7
Lines 203 194 -9
==========================================
- Hits 178 169 -9
Misses 16 16
Partials 9 9
Continue to review full report at Codecov.
|
client/main.go
Outdated
@@ -62,7 +64,8 @@ func main() { | |||
} | |||
|
|||
if setCIDR { | |||
if !utils.IsValidCIDR(options.Interface.CIDR) { | |||
errs := validate.Var(options.Interface.CIDR, "required,cidr") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err
client/main.go
Outdated
@@ -84,8 +87,9 @@ func main() { | |||
} | |||
|
|||
if setRoute { | |||
if !utils.IsValidCIDR(options.Route.DstCIDR) { | |||
log.Fatalf("Route destination netIP is not correct: %s", options.Route.DstCIDR) | |||
errs := validate.Var(options.Route.DstCIDR, "required,cidr") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err
govendor fetch gopkg.in/go-playground/validator.v9 |
fa35b61
to
50ed6be
Compare
91859a1
to
97ce259
Compare
This PR can be used.
kubectl exec -it myapp-pod -- bash
$ kubectl get po
NAME READY STATUS RESTARTS AGE
myapp-pod 1/1 Running 0 1m
network-controller-server-tcp-2cp8x 1/1 Running 0 2h
network-controller-server-unix-dgr9c 1/1 Running 0 2h
root@myapp-pod:/# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450
inet 10.244.0.16 netmask 255.255.255.0 broadcast 0.0.0.0
ether 0a:58:0a:f4:00:10 txqueuelen 0 (Ethernet)
RX packets 45628 bytes 27987371 (27.9 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 13848 bytes 752683 (752.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth100: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.24.50 netmask 255.255.255.0 broadcast 192.168.24.255
ether 7a:da:0b:c7:e9:3b txqueuelen 0 (Ethernet)
RX packets 8 bytes 648 (648.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
root@myapp-pod:/# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.244.0.1 0.0.0.0 UG 0 0 0 eth0
10.244.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.244.0.0 10.244.0.1 255.255.0.0 UG 0 0 0 eth0
192.168.24.0 0.0.0.0 255.255.255.0 U 0 0 0 eth100
224.0.0.0 0.0.0.0 240.0.0.0 U 0 0 0 eth100
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: myapp-container
image: ubuntu
command: ['sh', '-c', 'echo The app is running! && sleep 3600']
initContainers:
- name: init-network-client
image: sdnvortex/network-controller:sufuf3_remove-IsValid
command: ["/go/bin/client"]
args: ["-s=unix:///tmp/vortex.sock", "-b=br100", "-n=eth100", "-i=192.168.24.50/24", "--net=224.0.0.0/4", "-g=0.0.0.0"]
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_UUID
valueFrom:
fieldRef:
fieldPath: metadata.uid
volumeMounts:
- mountPath: /tmp/
name: grpc-sock
restartPolicy: Never
volumes:
- name: grpc-sock
hostPath:
path: /tmp/vortex/ |
97ce259
to
0428718
Compare
我後來思考一下還是覺得不要引入外部套件比較好XD 這樣專案比較不會太肥 |
好唷 |
https://godoc.org/gopkg.in/go-playground/validator.v9#hdr-Internet_Protocol_Address_IP