Add validate no new line at end of file
TrivialFix Change-Id: I817aa52caf56b7d54b266e553db6db1ceb38b773 Signed-off-by: Jeffrey Zhang <zhang.lei.fly@gmail.com>
This commit is contained in:
parent
c3ae6f5d82
commit
3e89f987c0
@ -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']
|
||||||
|
@ -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 }}"
|
||||||
|
@ -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] }}"
|
||||||
|
@ -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'
|
||||||
|
@ -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'
|
||||||
|
@ -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] }}"
|
||||||
|
@ -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
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
---
|
---
|
||||||
- include: "{{ action }}.yml"
|
- include: "{{ action }}.yml"
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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 }}
|
||||||
|
60
tools/validate-all-file.py
Executable file
60
tools/validate-all-file.py
Executable file
@ -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())
|
1
tox.ini
1
tox.ini
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user