Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookie updated by NetworkToCode Cookie Drift Manager Tool #266

Merged
merged 7 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
"_drift_manager": {
"template": "https://github.com/nautobot/cookiecutter-nautobot-app.git",
"template_dir": "nautobot-app",
"template_ref": "refs/tags/nautobot-app-v2.3.0",
"template_ref": "refs/tags/nautobot-app-v2.3.2",
"cookie_dir": "",
"branch_prefix": "drift-manager",
"pull_request_strategy": "create",
"post_actions": [
"black"
],
"draft": true,
"baked_commit_ref": "fcb62757ef4e78dd327cacb192ea19f1ac5344f8"
"baked_commit_ref": "76075295fc33cea874dc8bbe7fac35f83b2b6869"
}
}
}
16 changes: 11 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on: # yamllint disable-line rule:truthy rule:comments
pull_request: ~

env:
APP_NAME: "nautobot-app-firewall-models"
APP_NAME: "nautobot-firewall-models"

jobs:
ruff-format:
Expand Down Expand Up @@ -91,6 +91,10 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Constrain Nautobot version and regenerate lock file"
env:
INVOKE_NAUTOBOT_FIREWALL_MODELS_LOCAL: "true"
run: "poetry run invoke lock --constrain-nautobot-ver --constrain-python-ver"
- name: "Set up Docker Buildx"
id: "buildx"
uses: "docker/setup-buildx-action@v3"
Expand All @@ -108,6 +112,7 @@ jobs:
build-args: |
NAUTOBOT_VER=${{ matrix.nautobot-version }}
PYTHON_VER=${{ matrix.python-version }}
CI=true
- name: "Copy credentials"
run: "cp development/creds.example.env development/creds.env"
- name: "Linting: pylint"
Expand All @@ -122,14 +127,14 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.8", "3.11"]
python-version: ["3.8", "3.12"]
db-backend: ["postgresql"]
nautobot-version: ["stable"]
include:
- python-version: "3.11"
db-backend: "postgresql"
nautobot-version: "2.0.0"
# - python-version: "3.11"
smk4664 marked this conversation as resolved.
Show resolved Hide resolved
# - python-version: "3.12"
# db-backend: "mysql"
# nautobot-version: "stable"
runs-on: "ubuntu-22.04"
Expand Down Expand Up @@ -158,6 +163,7 @@ jobs:
build-args: |
NAUTOBOT_VER=${{ matrix.nautobot-version }}
PYTHON_VER=${{ matrix.python-version }}
CI=true
- name: "Copy credentials"
run: "cp development/creds.example.env development/creds.env"
- name: "Use Mysql invoke settings when needed"
Expand Down Expand Up @@ -195,7 +201,7 @@ jobs:
- name: "Set up Python"
uses: "actions/setup-python@v5"
with:
python-version: "3.11"
python-version: "3.12"
- name: "Install Python Packages"
run: "pip install poetry"
- name: "Set env"
Expand Down Expand Up @@ -230,7 +236,7 @@ jobs:
- name: "Set up Python"
uses: "actions/setup-python@v5"
with:
python-version: "3.11"
python-version: "3.12"
- name: "Install Python Packages"
run: "pip install poetry"
- name: "Set env"
Expand Down
1 change: 1 addition & 0 deletions changes/266.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added Python3.12 support.
smk4664 marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions changes/266.housekeeping
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rebaked from the cookie `nautobot-app-v2.3.2`.
31 changes: 10 additions & 21 deletions development/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,18 @@ RUN which poetry || curl -sSL https://install.python-poetry.org | python3 - && \
WORKDIR /source
COPY . /source

# Get container's installed Nautobot version as a forced constraint
# NAUTOBOT_VER may be a branch name and not a published release therefor we need to get the installed version
# so pip can use it to recognize local constraints.
RUN pip show nautobot | grep "^Version: " | sed -e 's/Version: /nautobot==/' > constraints.txt
# Build args must be declared in each stage
ARG PYTHON_VER

# Use Poetry to grab dev dependencies from the lock file
# Can be improved in Poetry 1.2 which allows `poetry install --only dev`
#
# We can't use the entire freeze as it takes forever to resolve with rigidly fixed non-direct dependencies,
# especially those that are only direct to Nautobot but the container included versions slightly mismatch
RUN poetry export -f requirements.txt --without-hashes --extras all --output poetry_freeze_base.txt
RUN poetry export -f requirements.txt --without-hashes --extras all --with dev --output poetry_freeze_all.txt
RUN sort poetry_freeze_base.txt poetry_freeze_all.txt | uniq -u > poetry_freeze_dev.txt

# Install all local project as editable, constrained on Nautobot version, to get any additional
# direct dependencies of the app
RUN --mount=type=cache,target="/root/.cache/pip",sharing=locked \
pip install -c constraints.txt -e .[all]
# Constrain the Nautobot version to NAUTOBOT_VER
# In CI, this should be done outside of the Dockerfile to prevent cross-compile build failures
ARG CI
RUN if [ -z "${CI+x}" ]; then \
INSTALLED_NAUTOBOT_VER=$(pip show nautobot | grep "^Version" | sed "s/Version: //"); \
poetry add --lock nautobot@${INSTALLED_NAUTOBOT_VER} --python ${PYTHON_VER}; fi

# Install any dev dependencies frozen from Poetry
# Can be improved in Poetry 1.2 which allows `poetry install --only dev`
RUN --mount=type=cache,target="/root/.cache/pip",sharing=locked \
pip install -c constraints.txt -r poetry_freeze_dev.txt
# Install the app
RUN poetry install --extras all --with dev

COPY development/nautobot_config.py ${NAUTOBOT_ROOT}/nautobot_config.py
# !!! USE CAUTION WHEN MODIFYING LINES ABOVE
9 changes: 5 additions & 4 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mkdocs==1.5.2
mkdocs-material==9.1.15
mkdocs==1.6.0
mkdocs-material==9.5.32
markdown-version-annotations==1.0.1
mkdocstrings-python==1.5.2
mkdocstrings==0.22.0
griffe==1.1.1
mkdocstrings-python==1.10.8
mkdocstrings==0.25.2
19 changes: 11 additions & 8 deletions invoke.example.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
---
nautobot_firewall_models:
project_name: "nautobot-firewall-models"
nautobot_ver: "2.0.0"
local: false
python_ver: "3.11"
compose_dir: "development"
compose_files:
- "docker-compose.base.yml"
- "docker-compose.redis.yml"
- "docker-compose.postgres.yml"
- "docker-compose.dev.yml"
# local: false
# compose_dir: "/full/path/to/nautobot-app-firewall-models/development"

# The following is an example of using MySQL as the database backend
# ---
# nautobot_firewall_models:
# compose_files:
# - "docker-compose.base.yml"
# - "docker-compose.redis.yml"
# - "docker-compose.mysql.yml"
# - "docker-compose.dev.yml"
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
dev_addr: "127.0.0.1:8001"
edit_uri: "edit/main/nautobot-app-firewall-models/docs"
edit_uri: "edit/main/docs"
site_dir: "nautobot_firewall_models/static/nautobot_firewall_models/docs"
site_name: "Nautobot Firewall Models Documentation"
site_url: "https://docs.nautobot.com/projects/firewall-models/en/latest/"
Expand Down
5 changes: 2 additions & 3 deletions nautobot_firewall_models/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ def validate(self, data):
if vrf is not None:
if qs.filter(start_address=start_address, end_address=end_address, vrf=vrf).exists():
raise serializers.ValidationError("The fields start_address, end_address, vrf must make a unique set.")
else:
if qs.filter(start_address=start_address, end_address=end_address, vrf__isnull=True).exists():
raise serializers.ValidationError("The fields start_address, end_address must make a unique set.")
elif qs.filter(start_address=start_address, end_address=end_address, vrf__isnull=True).exists():
raise serializers.ValidationError("The fields start_address, end_address must make a unique set.")

return super().validate(data)

Expand Down
2 changes: 1 addition & 1 deletion nautobot_firewall_models/tests/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Create basic objects for use in test class setup."""

# noqa: F403, F405
# ruff: noqa: F403, F405
from django.contrib.contenttypes.models import ContentType
from nautobot.dcim.models import Device, DeviceType, Location, LocationType, Manufacturer, Platform
from nautobot.extras.models import DynamicGroup, Job, Role
Expand Down
2 changes: 1 addition & 1 deletion nautobot_firewall_models/tests/test_capirca.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Test Capirca Utils."""

# noqa: F403, F405
# ruff: noqa: F403, F405
# pylint: disable=protected-access
from unittest import skip
from unittest.mock import patch
Expand Down
2 changes: 1 addition & 1 deletion nautobot_firewall_models/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Test Firewall models."""

# noqa: F403, F405
# ruff: noqa: F403, F405
# pylint: disable=invalid-name
from django.core.exceptions import ValidationError
from django.test import TestCase
Expand Down
2 changes: 1 addition & 1 deletion nautobot_firewall_models/tests/test_ui_views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Unit tests for views."""

# noqa: F403, F405
# ruff: noqa: F403, F405
# pylint: disable=invalid-name
# pylint: disable=duplicate-code
from nautobot.apps.testing import ViewTestCases
Expand Down
Loading