Skip to content

Commit

Permalink
Merge pull request #151 from ryanmerolle/dev
Browse files Browse the repository at this point in the history
1.3.0
  • Loading branch information
ryanmerolle authored Jun 23, 2023
2 parents 6c744b1 + a8243bd commit 175f8c3
Show file tree
Hide file tree
Showing 52 changed files with 623 additions and 267 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile-plugin_dev
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ARG NETBOX_VARIANT=v3.4
ARG NETBOX_VARIANT=v3.5

FROM netboxcommunity/netbox:${NETBOX_VARIANT}

ARG NETBOX_INITIALIZERS_VARIANT=3.4.*
ARG NETBOX_INITIALIZERS_VARIANT=3.5.*

ARG DEBIAN_FRONTEND=noninteractive

Expand Down
9 changes: 3 additions & 6 deletions .devcontainer/configuration/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Read secret from file
def _read_secret(secret_name, default=None):
try:
f = open("/run/secrets/" + secret_name, encoding="utf-8")
f = open(f"/run/secrets/{secret_name}", encoding="utf-8")
except OSError:
return default
else:
Expand Down Expand Up @@ -74,8 +74,7 @@ def _read_secret(secret_name, default=None):
environ.get("REDIS_CACHE_PASSWORD", environ.get("REDIS_PASSWORD", "")),
),
"DATABASE": int(environ.get("REDIS_CACHE_DATABASE", 1)),
"SSL": environ.get("REDIS_CACHE_SSL", environ.get("REDIS_SSL", "False")).lower()
== "true",
"SSL": environ.get("REDIS_CACHE_SSL", environ.get("REDIS_SSL", "False")).lower() == "true",
"INSECURE_SKIP_TLS_VERIFY": environ.get(
"REDIS_CACHE_INSECURE_SKIP_TLS_VERIFY",
environ.get("REDIS_INSECURE_SKIP_TLS_VERIFY", "False"),
Expand Down Expand Up @@ -252,9 +251,7 @@ def _read_secret(secret_name, default=None):
"netbox.authentication.RemoteUserBackend",
)
REMOTE_AUTH_HEADER = environ.get("REMOTE_AUTH_HEADER", "HTTP_REMOTE_USER")
REMOTE_AUTH_AUTO_CREATE_USER = (
environ.get("REMOTE_AUTH_AUTO_CREATE_USER", "True").lower() == "true"
)
REMOTE_AUTH_AUTO_CREATE_USER = environ.get("REMOTE_AUTH_AUTO_CREATE_USER", "True").lower() == "true"
REMOTE_AUTH_DEFAULT_GROUPS = list(
filter(None, environ.get("REMOTE_AUTH_DEFAULT_GROUPS", "").split(" ")),
)
Expand Down
13 changes: 12 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,31 @@
"extensions": [
"DavidAnson.vscode-markdownlint",
"GitHub.codespaces",
"GitHub.copilot-labs",
"GitHub.vscode-pull-request-github",
"Gruntfuggly.todo-tree",
"Tyriar.sort-lines",
"aaron-bond.better-comments",
"batisteo.vscode-django",
"charliermarsh.ruff",
"codezombiech.gitignore",
"esbenp.prettier-vscode",
"exiasr.hadolint",
"formulahendry.auto-rename-tag",
"mintlify.document",
"ms-python.isort",
"ms-python.pylint",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-vscode.makefile-tools",
"mutantdino.resourcemonitor",
"oderwat.indent-rainbow",
"paulomenezes.duplicated-code",
"redhat.vscode-yaml",
"searKing.preview-vscode",
"sourcery.sourcery"
"sourcery.sourcery",
"wholroyd.jinja",
"yzhang.markdown-all-in-one"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/env/netbox.env
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ REDIS_DATABASE=0
REDIS_HOST=redis
REDIS_INSECURE_SKIP_TLS_VERIFY=false
REDIS_PASSWORD=H733Kdjndks81
SECRET_KEY=r8OwDznj!!dciP9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNj
SECRET_KEY=r8OwDznj!!dciP9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNjaa
SUPERUSER_API_TOKEN=0123456789abcdef0123456789abcdef01234567
SUPERUSER_EMAIL=[email protected]
SUPERUSER_NAME=admin
Expand Down
2 changes: 2 additions & 0 deletions .devcontainer/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ pycodestyle
pydocstyle
pylint
pylint-django
ruff
sourcery-analytics
wily
yapf
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
max-line-length = 160
max-line-length = 140
extend-ignore = E203
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ body:
attributes:
label: NetBox access-list plugin version
description: What version of the NetBox access-list plugin are you currently running?
placeholder: v1.2.0
placeholder: v1.3.0
validations:
required: true
- type: input
attributes:
label: NetBox version
description: What version of NetBox are you currently running?
placeholder: v3.4.3
placeholder: v3.5.4
validations:
required: true
- type: textarea
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ body:
attributes:
label: NetBox version
description: What version of NetBox are you currently running?
placeholder: v3.4.3
placeholder: v3.5.4
validations:
required: true
- type: dropdown
Expand Down
3 changes: 0 additions & 3 deletions .github/linters/.flake8

This file was deleted.

8 changes: 0 additions & 8 deletions .github/linters/.isort.cfg

This file was deleted.

3 changes: 0 additions & 3 deletions .github/linters/.jscpd.json

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: CI

on:
push:
pull_request:

# This ensures that previous jobs for the workflow are canceled when the ref is
# updated.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
run-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0

- name: Lint Code Base
uses: github/super-linter/slim@v4
env:
DEFAULT_BRANCH: dev
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SUPPRESS_POSSUM: true
LINTER_RULES_PATH: /
VALIDATE_ALL_CODEBASE: false
VALIDATE_DOCKERFILE: false
VALIDATE_JSCPD: true
FILTER_REGEX_EXCLUDE: (.*/)?(configuration/.*)

test:
runs-on: ubuntu-latest
name: Runs plugin tests
needs: run-lint
steps:
- id: git-checkout
name: Checkout
uses: actions/checkout@v3

- id: docker-test
name: Test the image
run: ./test.sh snapshot
30 changes: 0 additions & 30 deletions .github/workflows/super-linter.yml

This file was deleted.

8 changes: 0 additions & 8 deletions .isort.cfg

This file was deleted.

4 changes: 4 additions & 0 deletions .jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"threshold": 10,
"ignore": ["**/migrations/**", "**/tests/**"]
}
37 changes: 31 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,25 @@ repos:
- id: debug-statements
- id: end-of-file-fixer
- id: name-tests-test
args:
- "--django"
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/isort
rev: 5.11.4
rev: 5.12.0
hooks:
- id: isort
args:
- "--profile=black"
exclude: ^.devcontainer/
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.3.0
hooks:
- id: black
language_version: python3
exclude: ^.devcontainer/
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.4.0
rev: v2.5.1
hooks:
- id: add-trailing-comma
args:
Expand All @@ -32,25 +36,36 @@ repos:
rev: 6.0.0
hooks:
- id: flake8
exclude: ^.devcontainer/
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.7.0
hooks:
- id: pyupgrade
args:
- "--py39-plus"
- repo: https://github.com/adrienverge/yamllint
rev: v1.29.0
rev: v1.32.0
hooks:
- id: yamllint
- repo: https://github.com/econchick/interrogate
rev: 1.5.0
hooks:
- id: interrogate
args: [--fail-under=90, --verbose]
exclude: (^.devcontainer/|^netbox_acls/migrations/)
#- repo: https://github.com/Lucas-C/pre-commit-hooks-nodejs
# rev: v1.1.2
# hooks:
# - id: htmlhint
# args: [--config, .htmlhintrc]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.33.0
rev: v0.35.0
hooks:
- id: markdownlint
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.272
hooks:
- id: ruff
#- repo: local
# hooks:
# - id: wily
Expand All @@ -59,3 +74,13 @@ repos:
# verbose: true
# language: python
# additional_dependencies: [wily]
#- repo: https://github.com/sourcery-ai/sourcery
# rev: v1.0.4b23
# hooks:
# - id: sourcery
# # The best way to use Sourcery in a pre-commit hook:
# # * review only changed lines:
# # * omit the summary
# args:
# - --diff=git diff HEAD
# - --no-summary
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARG NETBOX_VARIANT=v3.5

FROM netboxcommunity/netbox:${NETBOX_VARIANT}

RUN mkdir -pv /plugins/netbox-acls
COPY . /plugins/netbox-acls

RUN /opt/netbox/venv/bin/python3 /plugins/netbox-acls/setup.py develop && \
cp -rf /plugins/netbox-acls/netbox_acls/ /opt/netbox/venv/lib/python3.10/site-packages/netbox_acls
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
include README.md
include LICENSE
recursive-include netbox_acls/templates *
recursive-include netbox_acls/static *
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ start:
.PHONY: all ## Run all PLUGIN DEV targets
all: setup makemigrations migrate collectstatic initializers start

#.PHONY: test
#test:
# ${VENV_PY_PATH} /opt/netbox/netbox/manage.py runserver test ${PLUGIN_NAME}
.PHONY: rebuild ## Run PLUGIN DEV targets to rebuild
rebuild: setup makemigrations migrate collectstatic start

.PHONY: test
test: setup
${VENV_PY_PATH} ${NETBOX_MANAGE_PATH}/manage.py makemigrations ${PLUGIN_NAME} --check
${VENV_PY_PATH} ${NETBOX_MANAGE_PATH}/manage.py test ${PLUGIN_NAME}

#relpatch:
# $(eval GSTATUS := $(shell git status --porcelain))
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Each Plugin Version listed below has been tested with its corresponding NetBox V
| 3.2 | 1.0.1 |
| 3.3 | 1.1.0 |
| 3.4 | 1.2.2 |
| 3.5 | 1.3.0 |

## Installing

Expand Down
7 changes: 7 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- TODO: ACL Form Bubble/ICON Extended/Standard
- TODO: Add an Access List to an Interface Custom Fields after comments - DONE
- TODO: ACL rules, look at last number and increment to next 10
- TODO: Clone for ACL Interface should include device
- TODO: Inconsistent errors for add/edit (where model is using a generic page)
- TODO: Check Constants across codebase for consistency.
- TODO: Test API, Forms, & Models - https://github.com/k01ek/netbox-bgp/tree/main/netbox_bgp/tests , https://github.com/DanSheps/netbox-secretstore/tree/develop/netbox_secretstore/tests & https://github.com/FlxPeters/netbox-plugin-prometheus-sd/tree/main/netbox_prometheus_sd/tests
Loading

0 comments on commit 175f8c3

Please sign in to comment.