Skip to content

Commit

Permalink
Merge pull request #76 from larsks/feature/precommit
Browse files Browse the repository at this point in the history
feature/precommit
  • Loading branch information
tzumainn authored Jan 14, 2025
2 parents 2a4ce35 + c8ea0d4 commit b183f7f
Show file tree
Hide file tree
Showing 41 changed files with 6,010 additions and 5,293 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Set update schedule for GitHub Actions

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
31 changes: 31 additions & 0 deletions .github/workflows/precommit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Run pre-commit checks"

on:
push:
pull_request:

jobs:
run-linters:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Configure caching
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: precommit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Install pre-commit
run: |
pip install pre-commit
- name: Run linters
run: |
pre-commit run --all-files
2 changes: 0 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install tox
- name: Lint
run: tox -epep8
- name: Unit Tests
run: tox -epy3
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
- id: end-of-file-fixer
- id: check-added-large-files
- id: check-case-conflict
- id: check-json
- id: check-symlinks
- id: detect-private-key
- id: check-executables-have-shebangs

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.1
hooks:
- id: ruff
- id: ruff-format
10 changes: 10 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
extends: default
rules:
line-length: disable
document-start: disable
indentation:
indent-sequences: whatever
hyphens:
max-spaces-after: 4
truthy:
check-keys: false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Disable VLAN access to a switchport on a switch.
```
openstack esi switch port disable access
<switch>
<switchport>
<switchport>
```

- `switch`: Switch
Expand Down
10 changes: 5 additions & 5 deletions doc/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Each of these functions has a parser containing data.

### <a name="attach"></a>Attach

The attach command will attack a network to a node.
The attach command will attack a network to a node.

* `openstack esi node network attach <node> --port <port> --network <network>`
* `openstack esi node network attach <node> --port <port> --network <network>`
* Exactly one port or network is needed.
* node: name or UUID of the node.
* port: name or UUID of the port.
Expand All @@ -22,15 +22,15 @@ The attach command will attack a network to a node.

### <a name="detach"></a>Detach

The detach command will detach a network from a node.
The detach command will detach a network from a node.

* `openstack esi node network detach <node> <port>`
* node: name or UUID of the node.
* port: name or UUID of the port.

### <a name="list"></a>List

The list command will list the networks that are attached to a node.
The list command will list the networks that are attached to a node.

* `openstack esi node network list --node <node> --network <network>`
* node: name or UUID of the node.
Expand Down
2 changes: 1 addition & 1 deletion esiclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
import pbr.version


__version__ = pbr.version.VersionInfo('python-esiclient').version_string()
__version__ = pbr.version.VersionInfo("python-esiclient").version_string()
32 changes: 15 additions & 17 deletions esiclient/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@

LOG = logging.getLogger(__name__)

DEFAULT_BAREMETAL_API_VERSION = '1.69'
DEFAULT_ESICLIENT_API_VERSION = '1'
DEFAULT_BAREMETAL_API_VERSION = "1.69"
DEFAULT_ESICLIENT_API_VERSION = "1"

# Required by the OSC plugin interface
API_NAME = 'esiclient'
API_VERSION_OPTION = 'os_esiclient_api_version'
API_VERSIONS = {
'1': 'esiclient.plugin'
}
API_NAME = "esiclient"
API_VERSION_OPTION = "os_esiclient_api_version"
API_VERSIONS = {"1": "esiclient.plugin"}


def make_client(instance):
Expand All @@ -44,21 +42,21 @@ def build_option_parser(parser):
:param argparse.ArgumentParser parser: The parser object that has been
initialized by OpenStackShell.
"""
if ('OS_BAREMETAL_API_VERSION' not in os.environ):
os.environ['OS_BAREMETAL_API_VERSION'] = DEFAULT_BAREMETAL_API_VERSION
if "OS_BAREMETAL_API_VERSION" not in os.environ:
os.environ["OS_BAREMETAL_API_VERSION"] = DEFAULT_BAREMETAL_API_VERSION
parser.add_argument(
'--os-esiclient-api-version',
metavar='<esiclient-api-version>',
"--os-esiclient-api-version",
metavar="<esiclient-api-version>",
default=utils.env(
'OS_ESICLIENT_API_VERSION',
default=DEFAULT_ESICLIENT_API_VERSION),
help='ESI Client API version, default=' +
DEFAULT_ESICLIENT_API_VERSION +
' (Env: OS_ESICLIENT_API_VERSION)')
"OS_ESICLIENT_API_VERSION", default=DEFAULT_ESICLIENT_API_VERSION
),
help="ESI Client API version, default="
+ DEFAULT_ESICLIENT_API_VERSION
+ " (Env: OS_ESICLIENT_API_VERSION)",
)
return parser


class ClientWrapper(object):

def __init__(self, instance):
self._instance = instance
Loading

0 comments on commit b183f7f

Please sign in to comment.