aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ansible/roles/aodh/tasks/pull.yml2
-rw-r--r--ansible/roles/glance/tasks/config.yml2
-rw-r--r--ansible/roles/keystone/tasks/init_fernet.yml2
-rw-r--r--ansible/roles/keystone/tasks/pull.yml2
-rw-r--r--ansible/roles/keystone/tasks/start.yml2
-rw-r--r--ansible/roles/rally/tasks/bootstrap_service.yml2
-rw-r--r--ansible/roles/swift/tasks/check.yml2
-rw-r--r--ansible/roles/vmtp/tasks/main.yml2
-rw-r--r--docker/collectd/extend_start.sh2
-rw-r--r--docker/keystone/keystone-fernet/extend_start.sh2
-rw-r--r--docker/keystone/keystone/Dockerfile.j22
-rwxr-xr-xtools/validate-all-file.py60
-rw-r--r--tox.ini1
13 files changed, 72 insertions, 11 deletions
diff --git a/ansible/roles/aodh/tasks/pull.yml b/ansible/roles/aodh/tasks/pull.yml
index 20030c261..dae4426a5 100644
--- a/ansible/roles/aodh/tasks/pull.yml
+++ b/ansible/roles/aodh/tasks/pull.yml
@@ -25,4 +25,4 @@
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ aodh_notifier_image_full }}"
- when: inventory_hostname in groups['aodh-notifier'] \ No newline at end of file
+ when: inventory_hostname in groups['aodh-notifier']
diff --git a/ansible/roles/glance/tasks/config.yml b/ansible/roles/glance/tasks/config.yml
index e943f54d7..88cb5c446 100644
--- a/ansible/roles/glance/tasks/config.yml
+++ b/ansible/roles/glance/tasks/config.yml
@@ -28,4 +28,4 @@
- "{{ node_custom_config }}/glance/{{ inventory_hostname }}/{{ item.service }}.conf"
dest: "{{ node_config_directory }}/{{ item.service }}/{{ item.service }}.conf"
when: inventory_hostname in groups[item.group]
- with_items: "{{ glance_service_groups }}" \ No newline at end of file
+ with_items: "{{ glance_service_groups }}"
diff --git a/ansible/roles/keystone/tasks/init_fernet.yml b/ansible/roles/keystone/tasks/init_fernet.yml
index 0d2bb0076..c608202ab 100644
--- a/ansible/roles/keystone/tasks/init_fernet.yml
+++ b/ansible/roles/keystone/tasks/init_fernet.yml
@@ -12,4 +12,4 @@
- name: Run key distribution
command: docker exec -t keystone_fernet /usr/bin/fernet-rotate.sh
run_once: True
- delegate_to: "{{ groups['keystone'][0] }}" \ No newline at end of file
+ delegate_to: "{{ groups['keystone'][0] }}"
diff --git a/ansible/roles/keystone/tasks/pull.yml b/ansible/roles/keystone/tasks/pull.yml
index 544940070..c9152b148 100644
--- a/ansible/roles/keystone/tasks/pull.yml
+++ b/ansible/roles/keystone/tasks/pull.yml
@@ -22,4 +22,4 @@
image: "{{ keystone_ssh_image_full }}"
when:
- inventory_hostname in groups['keystone']
- - keystone_token_provider == 'fernet' \ No newline at end of file
+ - keystone_token_provider == 'fernet'
diff --git a/ansible/roles/keystone/tasks/start.yml b/ansible/roles/keystone/tasks/start.yml
index 0470b3c11..382a0d1e6 100644
--- a/ansible/roles/keystone/tasks/start.yml
+++ b/ansible/roles/keystone/tasks/start.yml
@@ -46,4 +46,4 @@
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
- "keystone_fernet_tokens:/etc/keystone/fernet-keys"
- when: keystone_token_provider == 'fernet' \ No newline at end of file
+ when: keystone_token_provider == 'fernet'
diff --git a/ansible/roles/rally/tasks/bootstrap_service.yml b/ansible/roles/rally/tasks/bootstrap_service.yml
index 6d5f1f086..47a7c8f7f 100644
--- a/ansible/roles/rally/tasks/bootstrap_service.yml
+++ b/ansible/roles/rally/tasks/bootstrap_service.yml
@@ -17,4 +17,4 @@
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/"
run_once: True
- delegate_to: "{{ groups['rally'][0] }}" \ No newline at end of file
+ delegate_to: "{{ groups['rally'][0] }}"
diff --git a/ansible/roles/swift/tasks/check.yml b/ansible/roles/swift/tasks/check.yml
index 15e438c9d..e655ac0e7 100644
--- a/ansible/roles/swift/tasks/check.yml
+++ b/ansible/roles/swift/tasks/check.yml
@@ -16,4 +16,4 @@
retries: 10
delay: 5
run_once: True
- when: kolla_enable_sanity_swift | bool \ No newline at end of file
+ when: kolla_enable_sanity_swift | bool
diff --git a/ansible/roles/vmtp/tasks/main.yml b/ansible/roles/vmtp/tasks/main.yml
index bef222f6a..b017e8b4a 100644
--- a/ansible/roles/vmtp/tasks/main.yml
+++ b/ansible/roles/vmtp/tasks/main.yml
@@ -1,2 +1,2 @@
---
-- include: "{{ action }}.yml" \ No newline at end of file
+- include: "{{ action }}.yml"
diff --git a/docker/collectd/extend_start.sh b/docker/collectd/extend_start.sh
index 5142a67fe..92ff4a5ea 100644
--- a/docker/collectd/extend_start.sh
+++ b/docker/collectd/extend_start.sh
@@ -3,4 +3,4 @@
# Only update permissions if permissions need to be updated
if [[ $(stat -c %U:%G /var/lib/collectd) != "collectd:collectd" ]]; then
sudo chown collectd: /var/lib/collectd
-fi \ No newline at end of file
+fi
diff --git a/docker/keystone/keystone-fernet/extend_start.sh b/docker/keystone/keystone-fernet/extend_start.sh
index 0d6a3a539..cf356949f 100644
--- a/docker/keystone/keystone-fernet/extend_start.sh
+++ b/docker/keystone/keystone-fernet/extend_start.sh
@@ -9,4 +9,4 @@ fi
if [[ $(stat -c %U:%G ${FERNET_TOKEN_DIR}) != "keystone:keystone" ]]; then
chown keystone:keystone ${FERNET_TOKEN_DIR}
-fi \ No newline at end of file
+fi
diff --git a/docker/keystone/keystone/Dockerfile.j2 b/docker/keystone/keystone/Dockerfile.j2
index 4efca8744..761be7893 100644
--- a/docker/keystone/keystone/Dockerfile.j2
+++ b/docker/keystone/keystone/Dockerfile.j2
@@ -9,4 +9,4 @@ RUN chmod 755 /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_keystone_bo
{% block keystone_footer %}{% endblock %}
{% block footer %}{% endblock %}
-{{ include_footer }} \ No newline at end of file
+{{ include_footer }}
diff --git a/tools/validate-all-file.py b/tools/validate-all-file.py
new file mode 100755
index 000000000..601f2e432
--- /dev/null
+++ b/tools/validate-all-file.py
@@ -0,0 +1,60 @@
+#!/usr/bin/python
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import fnmatch
+import logging
+import os
+import re
+import sys
+
+
+PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
+
+NEWLINE_EOF_INCLUDE_PATTERNS = ['*.j2', '*.yml', '*.py', '*.sh']
+NEWLINE_EOF_EXCLUDE_PATTERNS = ['.tox', '.testrepository', '.git']
+
+logging.basicConfig()
+LOG = logging.getLogger(__name__)
+
+
+def check_newline_eof():
+ includes = r'|'.join([fnmatch.translate(x)
+ for x in NEWLINE_EOF_INCLUDE_PATTERNS])
+ excludes = r'|'.join([fnmatch.translate(x)
+ for x in NEWLINE_EOF_EXCLUDE_PATTERNS])
+ return_code = 0
+
+ def has_newline_eof(path):
+ with open(path, 'r') as f:
+ data = f.read()
+ if data and data[-1] != '\n':
+ LOG.error('%s file error: no newline at end of file', path)
+ return False
+ return True
+
+ for root, dirs, files in os.walk(PROJECT_ROOT):
+ dirs[:] = [d for d in dirs if not re.match(excludes, d)]
+ for f in files:
+ if not re.match(excludes, f) and re.match(includes, f):
+ if not has_newline_eof(os.path.join(root, f)):
+ return_code = 1
+ return return_code
+
+
+def main():
+ return sum([check_newline_eof()])
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/tox.ini b/tox.ini
index 6797a0fc4..3d09b228c 100644
--- a/tox.ini
+++ b/tox.ini
@@ -28,6 +28,7 @@ commands =
{toxinidir}/tools/validate-all-json.sh
{toxinidir}/tools/validate-all-yaml.sh
{toxinidir}/tools/validate-all-dockerfiles.sh
+ {toxinidir}/tools/validate-all-file.py
[testenv:bandit]
commands = bandit -r ansible/library docker kolla tests tools