Add pre-commit

Better linting. We fix the issues this highlights in the process.

Change-Id: I02ce11b497988bc0165f20fbca678d13bed5827e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2024-04-12 15:01:10 +01:00 committed by Dmitriy Rabotyagov
parent fcff141f14
commit c0ed7726d8
18 changed files with 61 additions and 35 deletions

27
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,27 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
args: ['--fix', 'lf']
- id: check-byte-order-marker
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: debug-statements
- id: check-json
files: .*\.json$
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: remove-tabs
exclude: '.*\.(svg)$'
- repo: https://opendev.org/openstack/hacking
rev: 6.1.0
hooks:
- id: hacking
additional_dependencies: []
exclude: '^(doc|releasenotes|tools)/.*$'

View File

@ -17,7 +17,7 @@
:tocdepth: 3
======================
Backup Service API v1
Backup Service API v1
======================
.. rest_expand_all::

View File

@ -17,7 +17,7 @@
:tocdepth: 3
======================
Backup Service API v2
Backup Service API v2
======================
.. rest_expand_all::

View File

@ -6,6 +6,5 @@
"hostname": "szaher01",
"uuid": "6f588392aa864c96b4af96a4eae005ce",
"client_id": "752d8bd43d654e7a840bbfda77ce41af_szaher01"
},
}
}

View File

@ -17,8 +17,8 @@
"log_file": "/home/saad/job0001.log",
"snapshot": true,
"action": "backup",
"remove_older_than": 365,
"remove_older_than": 365
}
}
]
}
]
}

View File

@ -28,7 +28,7 @@
"log_file": "/home/saad/job0001.log",
"snapshot": false,
"action": "backup",
"remove_older_than": 365,
"remove_older_than": 365
},
"max_retries": 5,
"max_retries_interval": 6,
@ -38,4 +38,4 @@
}
],
"job_id": "0ae284d514eb47dd84154748b5056749"
}
}

View File

@ -18,8 +18,8 @@
"log_file": "/home/saad/job0001.log",
"snapshot": false,
"action": "backup",
"remove_older_than": 365,
"remove_older_than": 365
}
}
]
}
]
}

View File

@ -30,7 +30,7 @@
"log_file": "/home/saad/job0001.log",
"snapshot": false,
"action": "backup",
"remove_older_than": 365,
"remove_older_than": 365
},
"max_retries": 5,
"max_retries_interval": 6,

View File

@ -130,7 +130,7 @@ Show sessions(v2)
Shows sessions.
This operation shows a certain session in a project. It displays
This operation shows a certain session in a project. It displays
all session details with jobs included in this session.
Normal response codes: 200

View File

@ -47,15 +47,15 @@ Install DevStack step by step
cd devstack
2. Add stack user and change devstack directory user group::
./create_stack_user.sh
chown -R stack ./devstack/
chown -R stack.stack ./devstack/
3. Add this repo as an external repository.This is a sample local.conf file for freezer developer::
[[local|localrc]]
ADMIN_PASSWORD=stack
DATABASE_PASSWORD=stack
@ -64,7 +64,7 @@ Install DevStack step by step
DEST=/opt/stack
LOGFILE=$DEST/logs/stack.sh.log
# only install keystone/horizon/swift in devstack
# disable_all_services
# enable_service key mysql s-proxy s-object s-container s-account horizon
@ -73,7 +73,7 @@ Install DevStack step by step
enable_plugin freezer-api http://git.openstack.org/openstack/freezer-api.git master
enable_plugin freezer-tempest-plugin http://git.openstack.org/openstack/freezer-tempest-plugin.git master
enable_plugin freezer-web-ui http://git.openstack.org/openstack/freezer-web-ui.git master
export FREEZER_BACKEND='sqlalchemy'
4. Use stack user to run ``stack.sh``::
@ -117,8 +117,8 @@ Running Freezer tempest tests
cd /opt/stack/tempest
tempest run -r freezer_tempest_plugin.tests.freezer_api.api.test_api_jobs.TestFreezerApiJobs.test_api_jobs_post
For more information, see:
https://docs.openstack.org/devstack/latest/index.html
https://docs.openstack.org/tempest/latest/

0
devstack/plugin.sh Executable file → Normal file
View File

View File

@ -53,10 +53,10 @@ edit config file
setup/configure the db
----------------------
The currently supported DB include Elasticsearch and sqlalchemy. You can
The currently supported DB include Elasticsearch and sqlalchemy. You can
config backend DB in ``freezer-api.conf`` file. If use sqlalchemy::
[storage]
[storage]
driver = sqlalchemy
backend = sqlalchemy

View File

@ -180,7 +180,7 @@ class DbActionTestCase(base.DbTestCase):
def test_add_and_search_action(self):
count = 0
actionids = []
while(count < 20):
while (count < 20):
doc = copy.deepcopy(self.fake_action_3)
action_id = common.get_fake_action_id()
doc['action_id'] = action_id

View File

@ -188,7 +188,7 @@ class DbActionTestCase(base.DbTestCase):
def test_add_and_search_action(self):
count = 0
actionids = []
while(count < 20):
while (count < 20):
doc = copy.deepcopy(self.fake_action_3)
action_id = common.get_fake_action_id()
doc['action_id'] = action_id

View File

@ -128,8 +128,8 @@ class TestJobDoc(common.FreezerBaseTestCase):
def test_createpatch_pops_jobid_and_userid(self):
job_doc = common.get_fake_job_0()
res_doc = utils.JobDoc.create_patch(job_doc)
self.assertFalse('job_id' in res_doc)
self.assertFalse('user_id' in res_doc)
self.assertNotIn('job_id', res_doc)
self.assertNotIn('user_id', res_doc)
def test_createpatch_raises_BadDataFormat_when_patch_has_invalid_state(
self):
@ -207,8 +207,8 @@ class TestActionDoc(common.FreezerBaseTestCase):
def test_createpatch_pops_actionid_and_userid(self):
action_doc = common.get_fake_action_0()
res_doc = utils.ActionDoc.create_patch(action_doc)
self.assertFalse('action_id' in res_doc)
self.assertFalse('user_id' in res_doc)
self.assertNotIn('action_id', res_doc)
self.assertNotIn('user_id', res_doc)
def test_createpatch_raises_BadDataFormat_when_patch_has_invalid_field(
self):
@ -269,8 +269,8 @@ class TestSessionDoc(common.FreezerBaseTestCase):
def test_createpatch_pops_sessionid_and_userid(self):
session_doc = common.get_fake_session_0()
res_doc = utils.SessionDoc.create_patch(session_doc)
self.assertFalse('session_id' in res_doc)
self.assertFalse('user_id' in res_doc)
self.assertNotIn('session_id', res_doc)
self.assertNotIn('user_id', res_doc)
def test_createpatch_raises_BadDataFormat_when_patch_has_invalid_field(
self):

View File

@ -2,7 +2,7 @@
features:
- |
Completely support sqlalchemy driver for freezer-api.
The previous version only implemented part one. In this patch,
The previous version only implemented part one. In this patch,
sqlalchemy driver has been completely implemented for freezer-api.
See links in detail: https://storyboard.openstack.org/#!/story/2004132
The configuration example is as follows:

View File

@ -2,8 +2,6 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
# hacking already pins flake8
hacking>=3.0.1,<=3.1.0 # Apache-2.0
pylint>=2.4.0 # GPLv2
coverage>=4.5.1 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD

View File

@ -32,8 +32,10 @@ commands =
pylint --rcfile .pylintrc freezer_api
[testenv:pep8]
deps =
pre-commit
commands =
flake8 freezer_api
pre-commit run --all-files --show-diff-on-failure
[testenv:docs]
commands =