This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/cloudstack-kubernetes-provider.git


The following commit(s) were added to refs/heads/master by this push:
     new 5f71413  Implement Travis checks (#18)
5f71413 is described below

commit 5f7141347ba06d6959cb21f26f2b61ce70391146
Author: Gregor Riepl <[email protected]>
AuthorDate: Sun Oct 18 00:45:55 2020 +0200

    Implement Travis checks (#18)
    
    * Add test target to makefile (including gofmt check)
    
    * Added Travis-CI script
    
    * gofmt, to satisfy new Travis checks
---
 .travis.yml                |  7 +++++++
 Makefile                   |  5 +++++
 cloudstack_loadbalancer.go | 48 +++++++++++++++++++++++-----------------------
 cmd/cloudstack-ccm/main.go |  2 +-
 protocol.go                | 48 +++++++++++++++++++++++-----------------------
 5 files changed, 61 insertions(+), 49 deletions(-)

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..1615af4
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,7 @@
+language: go
+
+go:
+- 1.13
+- master
+
+script: make test
diff --git a/Makefile b/Makefile
index 1c70360..855aadd 100644
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,11 @@ clean:
 cloudstack-ccm: ${CMD_SRC}
        go build -ldflags ${LDFLAGS} -o $@ $^
 
+test:
+       go test -v
+       go vet
+       @(echo "gofmt -l"; FMTFILES="$$(gofmt -l .)"; if test -n 
"$${FMTFILES}"; then echo "Go files that need to be reformatted (use 'go 
fmt'):\n$${FMTFILES}"; exit 1; fi)
+
 docker:
        docker build . -t 
apache/cloudstack-kubernetes-provider:${GIT_COMMIT_SHORT}
        docker tag apache/cloudstack-kubernetes-provider:${GIT_COMMIT_SHORT} 
apache/cloudstack-kubernetes-provider:latest
diff --git a/cloudstack_loadbalancer.go b/cloudstack_loadbalancer.go
index 2b30483..dbf6dd3 100644
--- a/cloudstack_loadbalancer.go
+++ b/cloudstack_loadbalancer.go
@@ -168,7 +168,7 @@ func (cs *CSCloud) EnsureLoadBalancer(ctx context.Context, 
clusterName string, s
 
                if lbRule != nil {
                        klog.V(4).Infof("Creating firewall rules for load 
balancer rule: %v (%v:%v:%v)", lbRuleName, protocol, lbRule.Publicip, port.Port)
-                       if _ , err := lb.updateFirewallRule(lbRule.Publicipid, 
int(port.Port), protocol, service.Spec.LoadBalancerSourceRanges); err != nil {
+                       if _, err := lb.updateFirewallRule(lbRule.Publicipid, 
int(port.Port), protocol, service.Spec.LoadBalancerSourceRanges); err != nil {
                                return nil, err
                        }
                }
@@ -600,29 +600,29 @@ func symmetricDifference(hostIDs []string, lbInstances 
[]*cloudstack.VirtualMach
 //
 // Thanks to: https://stackoverflow.com/a/36000696
 func compareStringSlice(x, y []string) bool {
-    if len(x) != len(y) {
-        return false
-    }
-    // create a map of string -> int
-    diff := make(map[string]int, len(x))
-    for _, _x := range x {
-        // 0 value for int is 0, so just increment a counter for the string
-        diff[_x]++
-    }
-    for _, _y := range y {
-        // If the string _y is not in diff bail out early
-        if _, ok := diff[_y]; !ok {
-            return false
-        }
-        diff[_y] -= 1
-        if diff[_y] == 0 {
-            delete(diff, _y)
-        }
-    }
-    if len(diff) == 0 {
-        return true
-    }
-    return false
+       if len(x) != len(y) {
+               return false
+       }
+       // create a map of string -> int
+       diff := make(map[string]int, len(x))
+       for _, _x := range x {
+               // 0 value for int is 0, so just increment a counter for the 
string
+               diff[_x]++
+       }
+       for _, _y := range y {
+               // If the string _y is not in diff bail out early
+               if _, ok := diff[_y]; !ok {
+                       return false
+               }
+               diff[_y] -= 1
+               if diff[_y] == 0 {
+                       delete(diff, _y)
+               }
+       }
+       if len(diff) == 0 {
+               return true
+       }
+       return false
 }
 
 func ruleToString(rule *cloudstack.FirewallRule) string {
diff --git a/cmd/cloudstack-ccm/main.go b/cmd/cloudstack-ccm/main.go
index 06fb4e1..b787fb4 100644
--- a/cmd/cloudstack-ccm/main.go
+++ b/cmd/cloudstack-ccm/main.go
@@ -30,7 +30,7 @@ import (
        "k8s.io/component-base/logs"
        "k8s.io/kubernetes/cmd/cloud-controller-manager/app"
        _ "k8s.io/kubernetes/pkg/client/metrics/prometheus" // for client 
metric registration
-       _ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric 
registration
+       _ "k8s.io/kubernetes/pkg/version/prometheus"        // for version 
metric registration
 
        "github.com/spf13/pflag"
 
diff --git a/protocol.go b/protocol.go
index 0fd6afe..5673ffb 100644
--- a/protocol.go
+++ b/protocol.go
@@ -33,14 +33,14 @@ func (p LoadBalancerProtocol) String() string {
 // Returns "" if the value is unknown.
 func (p LoadBalancerProtocol) CSProtocol() string {
        switch p {
-               case LoadBalancerProtocolTCP:
-                       return "tcp"
-               case LoadBalancerProtocolUDP:
-                       return "udp"
-               case LoadBalancerProtocolTCPProxy:
-                       return "tcp-proxy"
-               default:
-                       return ""
+       case LoadBalancerProtocolTCP:
+               return "tcp"
+       case LoadBalancerProtocolUDP:
+               return "udp"
+       case LoadBalancerProtocolTCPProxy:
+               return "tcp-proxy"
+       default:
+               return ""
        }
 }
 
@@ -48,14 +48,14 @@ func (p LoadBalancerProtocol) CSProtocol() string {
 // Returns "" if the value is unknown.
 func (p LoadBalancerProtocol) IPProtocol() string {
        switch p {
-               case LoadBalancerProtocolTCP:
-                       fallthrough
-               case LoadBalancerProtocolTCPProxy:
-                       return "tcp"
-               case LoadBalancerProtocolUDP:
-                       return "udp"
-               default:
-                       return ""
+       case LoadBalancerProtocolTCP:
+               fallthrough
+       case LoadBalancerProtocolTCPProxy:
+               return "tcp"
+       case LoadBalancerProtocolUDP:
+               return "udp"
+       default:
+               return ""
        }
 }
 
@@ -93,13 +93,13 @@ func ProtocolFromServicePort(port v1.ServicePort, 
annotations map[string]string)
 // CloudStack load balancer protocol name.
 func ProtocolFromLoadBalancer(protocol string) LoadBalancerProtocol {
        switch protocol {
-               case "tcp":
-                       return LoadBalancerProtocolTCP
-               case "udp":
-                       return LoadBalancerProtocolUDP
-               case "tcp-proxy":
-                       return LoadBalancerProtocolTCPProxy
-               default:
-                       return LoadBalancerProtocolInvalid
+       case "tcp":
+               return LoadBalancerProtocolTCP
+       case "udp":
+               return LoadBalancerProtocolUDP
+       case "tcp-proxy":
+               return LoadBalancerProtocolTCPProxy
+       default:
+               return LoadBalancerProtocolInvalid
        }
 }

Reply via email to