Add code verification tools 71/571/7
authorCristina Pauna <cristina.pauna@enea.com>
Fri, 19 Apr 2019 13:53:27 +0000 (16:53 +0300)
committerCristina Pauna <cristina.pauna@enea.com>
Wed, 24 Apr 2019 12:04:01 +0000 (12:04 +0000)
JIRA: IEC-2
Tools used to verify code style and correctness.
Usage command: tox -e coala

Change-Id: I9440349239446a6042664bdbb67f08fa0bc578b3
Signed-off-by: Cristina Pauna <cristina.pauna@enea.com>
.coafile [new file with mode: 0644]
ci/labs/arm/virtual1.yaml
ci/labs/arm/virtual2.yaml
src/foundation/hot/k8s_master_init.sh
src/foundation/scripts/cni/calico/calico.yaml
src/foundation/scripts/cni/calico/etcd-amd64.yaml
src/foundation/scripts/cni/calico/etcd-arm64.yaml
src/foundation/scripts/cni/calico/rbac.yaml
src/foundation/scripts/config.sh
src/use_cases/seba_on_arm/install/install.sh
tox.ini

diff --git a/.coafile b/.coafile
new file mode 100644 (file)
index 0000000..dbc38bc
--- /dev/null
+++ b/.coafile
@@ -0,0 +1,44 @@
+[all]
+ignore = .tox/**,
+    .git/**,
+    .gitignore,
+    .gitreview,
+    .gitmodules,
+    **.sw?,
+    **.orig
+
+[all.GitCommit]
+bears = GitCommitBear
+ignore_length_regex = Signed-off-by,
+    Also-by,
+    Co-authored-by,
+    http://,
+    https://
+
+[all.reStructuredText]
+bears = SpaceConsistencyBear
+files = docs/**.rst
+use_spaces = true
+ignore = .git/**,
+    .tox/**
+
+[all.ShellCheck]
+bears = ShellCheckBear,SpaceConsistencyBear
+files = **.sh
+shell = bash
+use_spaces = true
+
+[all.YAML]
+bears = YAMLLintBear
+files = **.yaml, **.yml
+use_spaces = true
+ignore_length_regex = ^.*https?://
+max_line_length = 120
+ignore = src/use_cases/
+
+[all.Python]
+bears = PyLintBear
+files = **.py
+use_spaces = true
+pylint_disable = E0401, W0401, C0111
+ignore = src/use_cases/
index 3a4a681..be600bd 100644 (file)
@@ -10,8 +10,8 @@
 
 version: 1.0
 details:
-  pod_owner: ENEA AB
-  contact: armband@enea.com
+  pod_owner: Arm IEC team
+  contact: blueprints@lists.akraino.org   # use hashtag iec
   lab: ENEA lab
   location: Stockholm, Sweden
   type: production
index 6486af8..d1f210d 100644 (file)
@@ -10,8 +10,8 @@
 
 version: 1.0
 details:
-  pod_owner: ENEA AB
-  contact: armband@enea.com
+  pod_owner: Arm IEC team
+  contact: blueprints@lists.akraino.org   # use hashtag iec
   lab: ENEA lab
   location: Stockholm, Sweden
   type: production
index 23be336..79ac03d 100644 (file)
@@ -10,6 +10,7 @@ git clone https://gerrit.akraino.org/r/iec
 cd iec/src/foundation/scripts
 ./k8s_common.sh
 ./k8s_master.sh k8s_master_ip k8s_pod_net_cidr k8s_svc_net_cidr
+# shellcheck source=/dev/null
 . ${HOME}/.profile
 ./setup-cni.sh k8s_cluster_ip k8s_pod_net_cidr
 token=$(kubeadm token list --skip-headers | awk 'END{print $1}')
index 3f74490..8b3da19 100644 (file)
@@ -18,7 +18,7 @@ data:
   # If you're using TLS enabled etcd uncomment the following.
   # You must also populate the Secret below with these files.
   etcd_ca: ""   # "/calico-secrets/etcd-ca"
-  etcd_cert: "" # "/calico-secrets/etcd-cert"
+  etcd_cert: ""   # "/calico-secrets/etcd-cert"
   etcd_key: ""  # "/calico-secrets/etcd-key"
   # Configure the Calico backend to use.
   calico_backend: "bird"
@@ -71,13 +71,13 @@ metadata:
   name: calico-etcd-secrets
   namespace: kube-system
 data:
-  # Populate the following files with etcd TLS configuration if desired, but leave blank if
-  # not using TLS for etcd.
-  # This self-hosted install expects three files with the following names.  The values
-  # should be base64 encoded strings of the entire contents of each file.
-  # etcd-key: null
-  # etcd-cert: null
-  # etcd-ca: null
+# Populate the following files with etcd TLS configuration if desired, but leave blank if
+# not using TLS for etcd.
+# This self-hosted install expects three files with the following names.  The values
+# should be base64 encoded strings of the entire contents of each file.
+# etcd-key: null
+# etcd-cert: null
+# etcd-ca: null
 
 ---
 
@@ -220,9 +220,9 @@ spec:
           readinessProbe:
             exec:
               command:
-              - /bin/calico-node
-              - -bird-ready
-              - -felix-ready
+                - /bin/calico-node
+                - -bird-ready
+                - -felix-ready
             periodSeconds: 10
           volumeMounts:
             - mountPath: /lib/modules
@@ -384,8 +384,8 @@ spec:
           readinessProbe:
             exec:
               command:
-              - /usr/bin/check-status
-              - -r
+                - /usr/bin/check-status
+                - -r
       volumes:
         # Mount in the etcd TLS secrets with mode 400.
         # See https://kubernetes.io/docs/concepts/configuration/secret/
@@ -401,4 +401,3 @@ kind: ServiceAccount
 metadata:
   name: calico-kube-controllers
   namespace: kube-system
-
index 86fda95..e3d0aa3 100644 (file)
@@ -45,14 +45,14 @@ spec:
                 fieldRef:
                   fieldPath: status.podIP
           command:
-          - /usr/local/bin/etcd
+            - /usr/local/bin/etcd
           args:
-          - --name=calico
-          - --data-dir=/var/etcd/calico-data
-          - --advertise-client-urls=http://$(CALICO_ETCD_IP):6666
-          - --listen-client-urls=http://0.0.0.0:6666
-          - --listen-peer-urls=http://0.0.0.0:6667
-          - --auto-compaction-retention=1
+            - --name=calico
+            - --data-dir=/var/etcd/calico-data
+            - --advertise-client-urls=http://$(CALICO_ETCD_IP):6666
+            - --listen-client-urls=http://0.0.0.0:6666
+            - --listen-peer-urls=http://0.0.0.0:6667
+            - --auto-compaction-retention=1
           volumeMounts:
             - name: var-etcd
               mountPath: /var/etcd
index f408686..940525f 100644 (file)
@@ -47,14 +47,14 @@ spec:
             - name: ETCD_UNSUPPORTED_ARCH
               value: "arm64"
           command:
-          - /usr/local/bin/etcd
+            - /usr/local/bin/etcd
           args:
-          - --name=calico
-          - --data-dir=/var/etcd/calico-data
-          - --advertise-client-urls=http://$(CALICO_ETCD_IP):6666
-          - --listen-client-urls=http://0.0.0.0:6666
-          - --listen-peer-urls=http://0.0.0.0:6667
-          - --auto-compaction-retention=1
+            - --name=calico
+            - --data-dir=/var/etcd/calico-data
+            - --advertise-client-urls=http://$(CALICO_ETCD_IP):6666
+            - --listen-client-urls=http://0.0.0.0:6666
+            - --listen-peer-urls=http://0.0.0.0:6667
+            - --auto-compaction-retention=1
           volumeMounts:
             - name: var-etcd
               mountPath: /var/etcd
index 95115c7..135773c 100644 (file)
@@ -9,8 +9,8 @@ metadata:
   name: calico-kube-controllers
 rules:
   - apiGroups:
-    - ""
-    - extensions
+      - ""
+      - extensions
     resources:
       - pods
       - namespaces
@@ -21,7 +21,7 @@ rules:
       - watch
       - list
   - apiGroups:
-    - networking.k8s.io
+      - networking.k8s.io
     resources:
       - networkpolicies
     verbs:
@@ -37,9 +37,9 @@ roleRef:
   kind: ClusterRole
   name: calico-kube-controllers
 subjects:
-- kind: ServiceAccount
-  name: calico-kube-controllers
-  namespace: kube-system
+  - kind: ServiceAccount
+    name: calico-kube-controllers
+    namespace: kube-system
 
 ---
 
@@ -72,6 +72,6 @@ roleRef:
   kind: ClusterRole
   name: calico-node
 subjects:
-- kind: ServiceAccount
-  name: calico-node
-  namespace: kube-system
+  - kind: ServiceAccount
+    name: calico-node
+    namespace: kube-system
index 9bd88e0..1a541a7 100755 (executable)
@@ -1,4 +1,5 @@
 #!/bin/bash
+# shellcheck disable=SC2034
 
 # Host user which can log into master and each worker nodes
 HOST_USER=${HOST_USER:-iec}
index 5fd5fca..cda8322 100755 (executable)
@@ -3,7 +3,7 @@
 
 #Modified from https://github.com/cachengo/seba_charts/blob/master/scripts/installSEBA.sh
 
-basepath=$(cd `dirname $0`; pwd)
+basepath=$(cd "$(dirname "$0")"; pwd)
 CORD_REPO=${CORD_REPO:-https://charts.opencord.org}
 CORD_PLATFORM_VERSION=${CORD_PLATFORM_VERSION:-6.1.0}
 SEBA_VERSION=${SEBA_VERSION:-1.0.0}
diff --git a/tox.ini b/tox.ini
index f2f331f..1e35c7a 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -8,9 +8,12 @@
 [tox]
 minversion = 1.6
 envlist =
-    docs,
-    docs-linkcheck
+  docs,
+  docs-linkcheck,
+  coala,
 skipsdist = true
+passenv = TOX_WORK_DIR
+toxworkdir = {env:TOX_WORK_DIR:/tmp/v}
 
 [testenv:docs]
 deps = -rdocs/requirements.txt
@@ -22,3 +25,13 @@ whitelist_externals = echo
 [testenv:docs-linkcheck]
 deps = -rdocs/requirements.txt
 commands = sphinx-build -b linkcheck -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/linkcheck
+
+[testenv:coala]
+basepython = python3
+whitelist_externals = rm
+deps =
+    coala
+    coala-bears
+commands =
+   rm -rf src/use_cases/seba_on_arm/src_repo/
+   coala --non-interactive