Skip to content
Snippets Groups Projects
Commit 3e89f987 authored by Jeffrey Zhang's avatar Jeffrey Zhang Committed by Jeffrey Zhang
Browse files

Add validate no new line at end of file


TrivialFix

Change-Id: I817aa52caf56b7d54b266e553db6db1ceb38b773
Signed-off-by: default avatarJeffrey Zhang <zhang.lei.fly@gmail.com>
parent c3ae6f5d
No related branches found
No related tags found
No related merge requests found
...@@ -25,4 +25,4 @@ ...@@ -25,4 +25,4 @@
action: "pull_image" action: "pull_image"
common_options: "{{ docker_common_options }}" common_options: "{{ docker_common_options }}"
image: "{{ aodh_notifier_image_full }}" image: "{{ aodh_notifier_image_full }}"
when: inventory_hostname in groups['aodh-notifier'] when: inventory_hostname in groups['aodh-notifier']
\ No newline at end of file
...@@ -28,4 +28,4 @@ ...@@ -28,4 +28,4 @@
- "{{ node_custom_config }}/glance/{{ inventory_hostname }}/{{ item.service }}.conf" - "{{ node_custom_config }}/glance/{{ inventory_hostname }}/{{ item.service }}.conf"
dest: "{{ node_config_directory }}/{{ item.service }}/{{ item.service }}.conf" dest: "{{ node_config_directory }}/{{ item.service }}/{{ item.service }}.conf"
when: inventory_hostname in groups[item.group] when: inventory_hostname in groups[item.group]
with_items: "{{ glance_service_groups }}" with_items: "{{ glance_service_groups }}"
\ No newline at end of file
...@@ -12,4 +12,4 @@ ...@@ -12,4 +12,4 @@
- name: Run key distribution - name: Run key distribution
command: docker exec -t keystone_fernet /usr/bin/fernet-rotate.sh command: docker exec -t keystone_fernet /usr/bin/fernet-rotate.sh
run_once: True run_once: True
delegate_to: "{{ groups['keystone'][0] }}" delegate_to: "{{ groups['keystone'][0] }}"
\ No newline at end of file
...@@ -22,4 +22,4 @@ ...@@ -22,4 +22,4 @@
image: "{{ keystone_ssh_image_full }}" image: "{{ keystone_ssh_image_full }}"
when: when:
- inventory_hostname in groups['keystone'] - inventory_hostname in groups['keystone']
- keystone_token_provider == 'fernet' - keystone_token_provider == 'fernet'
\ No newline at end of file
...@@ -46,4 +46,4 @@ ...@@ -46,4 +46,4 @@
- "/etc/localtime:/etc/localtime:ro" - "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/" - "kolla_logs:/var/log/kolla/"
- "keystone_fernet_tokens:/etc/keystone/fernet-keys" - "keystone_fernet_tokens:/etc/keystone/fernet-keys"
when: keystone_token_provider == 'fernet' when: keystone_token_provider == 'fernet'
\ No newline at end of file
...@@ -17,4 +17,4 @@ ...@@ -17,4 +17,4 @@
- "/etc/localtime:/etc/localtime:ro" - "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla/" - "kolla_logs:/var/log/kolla/"
run_once: True run_once: True
delegate_to: "{{ groups['rally'][0] }}" delegate_to: "{{ groups['rally'][0] }}"
\ No newline at end of file
...@@ -16,4 +16,4 @@ ...@@ -16,4 +16,4 @@
retries: 10 retries: 10
delay: 5 delay: 5
run_once: True run_once: True
when: kolla_enable_sanity_swift | bool when: kolla_enable_sanity_swift | bool
\ No newline at end of file
--- ---
- include: "{{ action }}.yml" - include: "{{ action }}.yml"
\ No newline at end of file
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# Only update permissions if permissions need to be updated # Only update permissions if permissions need to be updated
if [[ $(stat -c %U:%G /var/lib/collectd) != "collectd:collectd" ]]; then if [[ $(stat -c %U:%G /var/lib/collectd) != "collectd:collectd" ]]; then
sudo chown collectd: /var/lib/collectd sudo chown collectd: /var/lib/collectd
fi fi
\ No newline at end of file
...@@ -9,4 +9,4 @@ fi ...@@ -9,4 +9,4 @@ fi
if [[ $(stat -c %U:%G ${FERNET_TOKEN_DIR}) != "keystone:keystone" ]]; then if [[ $(stat -c %U:%G ${FERNET_TOKEN_DIR}) != "keystone:keystone" ]]; then
chown keystone:keystone ${FERNET_TOKEN_DIR} chown keystone:keystone ${FERNET_TOKEN_DIR}
fi fi
\ No newline at end of file
...@@ -9,4 +9,4 @@ RUN chmod 755 /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_keystone_bo ...@@ -9,4 +9,4 @@ RUN chmod 755 /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_keystone_bo
{% block keystone_footer %}{% endblock %} {% block keystone_footer %}{% endblock %}
{% block footer %}{% endblock %} {% block footer %}{% endblock %}
{{ include_footer }} {{ include_footer }}
\ No newline at end of file
#!/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())
...@@ -28,6 +28,7 @@ commands = ...@@ -28,6 +28,7 @@ commands =
{toxinidir}/tools/validate-all-json.sh {toxinidir}/tools/validate-all-json.sh
{toxinidir}/tools/validate-all-yaml.sh {toxinidir}/tools/validate-all-yaml.sh
{toxinidir}/tools/validate-all-dockerfiles.sh {toxinidir}/tools/validate-all-dockerfiles.sh
{toxinidir}/tools/validate-all-file.py
[testenv:bandit] [testenv:bandit]
commands = bandit -r ansible/library docker kolla tests tools commands = bandit -r ansible/library docker kolla tests tools
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment