Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

sufuf3
Copy link
Contributor

@sufuf3 sufuf3 commented Jul 24, 2018

@codecov
Copy link

codecov bot commented Jul 24, 2018

Codecov Report

Merging #67 into master will decrease coverage by 0.57%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
utils/utils.go 100% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update baac882...0428718. Read the comment docs.

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")
Copy link
Contributor

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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err

@John-Lin
Copy link
Contributor

govendor fetch gopkg.in/go-playground/validator.v9

@sufuf3 sufuf3 force-pushed the sufuf3/remove-IsValid branch from fa35b61 to 50ed6be Compare July 25, 2018 02:04
@sufuf3 sufuf3 force-pushed the sufuf3/remove-IsValid branch 2 times, most recently from 91859a1 to 97ce259 Compare July 25, 2018 02:45
@sufuf3
Copy link
Contributor Author

sufuf3 commented Jul 25, 2018

This PR can be used.

  • This is test.
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
  • yaml file
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/

@sufuf3 sufuf3 force-pushed the sufuf3/remove-IsValid branch from 97ce259 to 0428718 Compare July 25, 2018 07:11
@sufuf3 sufuf3 changed the title [WIP] Remove IsValidIP, IsValidCIDR & IsValidVLANTag Remove IsValidIP, IsValidCIDR & IsValidVLANTag Jul 25, 2018
@John-Lin
Copy link
Contributor

我後來思考一下還是覺得不要引入外部套件比較好XD 這樣專案比較不會太肥

@sufuf3
Copy link
Contributor Author

sufuf3 commented Jul 26, 2018

好唷
同意你的想法 😃 👍
之後如果需要再隨時 reopen 這個 PR 囉
我先關掉 😄

@sufuf3 sufuf3 closed this Jul 26, 2018
@sufuf3 sufuf3 deleted the sufuf3/remove-IsValid branch September 19, 2018 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants