Skip to content

Commit

Permalink
Cookie updated by NetworkToCode Cookie Drift Manager Tool (#319)
Browse files Browse the repository at this point in the history
* Cookie updated by NetworkToCode Cookie Drift Manager Tool

Template:

```
{
    "template": "https://github.com/nautobot/cookiecutter-nautobot-app.git",
    "dir": "nautobot-app",
    "ref": "refs/tags/nautobot-app-v2.3.2",
    "path": null
}
```

Cookie:

```
{
    "remote": "https://github.com/nautobot/nautobot-app-circuit-maintenance.git",
    "path": "/tmp/tmpuf9cbn9j/nautobot-app-circuit-maintenance",
    "repository_path": "/tmp/tmpuf9cbn9j/nautobot-app-circuit-maintenance",
    "dir": "",
    "branch_prefix": "drift-manager",
    "context": {
        "codeowner_github_usernames": "@chadell @glennmatthews @pke11y @scetron",
        "full_name": "Network to Code, LLC",
        "email": "[email protected]",
        "github_org": "nautobot",
        "app_name": "nautobot_circuit_maintenance",
        "verbose_name": "Circuit Maintenance",
        "app_slug": "nautobot-circuit-maintenance",
        "project_slug": "nautobot-app-circuit-maintenance",
        "repo_url": "https://github.com/nautobot/nautobot-app-circuit-maintenance",
        "base_url": "circuit-maintenance",
        "min_nautobot_version": "2.0.0",
        "max_nautobot_version": "2.9999",
        "camel_name": "NautobotCircuitMaintenance",
        "project_short_description": "Nautobot App that automatically manages network circuit maintenance notifications. Dynamically reads email inboxes (or APIs) and updates Nautobot mapping circuit maintenances to devices",
        "model_class_name": "None",
        "open_source_license": "Apache-2.0",
        "docs_base_url": "https://docs.nautobot.com",
        "docs_app_url": "https://docs.nautobot.com/projects/circuit-maintenance/en/latest",
        "_template": "https://github.com/nautobot/cookiecutter-nautobot-app.git",
        "_output_dir": "/tmp/tmpuf9cbn9j",
        "_repo_dir": "/github/home/.cookiecutters/cookiecutter-nautobot-app/nautobot-app",
        "_checkout": "refs/tags/nautobot-app-v2.3.2"
    },
    "base_branch": "develop",
    "remote_name": "origin",
    "pull_request_strategy": "PullRequestStrategy.CREATE",
    "post_actions": [
        "PostAction.BLACK"
    ],
    "baked_commit_ref": "33780c7f9417fdde501b238dc3a6f45ed8d587e2",
    "draft": true
}
```

CLI Arguments:

```
{
    "cookie_dir": "",
    "input": false,
    "json_filename": "",
    "output_dir": "",
    "push": true,
    "template": "",
    "template_dir": "",
    "template_ref": "refs/tags/nautobot-app-v2.3.2",
    "pull_request": null,
    "post_action": [],
    "disable_post_actions": false,
    "draft": null
}
```

* Poetry, Ruff and add back dependencies

Also added Capacity Metrics as an extra due to the change in the dockerfile.  This should have been an extra all along, but is important now.

* Fix nb-use-fields-all

* Exclude binary fields from filter

A better way might be to apply a filter_override, but this field was already excluded by not putting it in the fields declaration.

---------

Co-authored-by: bakebot <[email protected]>
Co-authored-by: Stephen Kiely <[email protected]>
  • Loading branch information
3 people authored Sep 12, 2024
1 parent 219a4f3 commit 93222f2
Show file tree
Hide file tree
Showing 12 changed files with 521 additions and 233 deletions.
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": "33780c7f9417fdde501b238dc3a6f45ed8d587e2"
"baked_commit_ref": "a05eb77056d979eb079934d35bda706b247b18e6"
}
}
}
Expand Down
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-circuit-maintenance"
APP_NAME: "nautobot-circuit-maintenance"

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_CIRCUIT_MAINTENANCE_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"
- 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 @@ -196,7 +202,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 @@ -231,7 +237,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/319.housekeeping
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rebake with nautobot-app-v2.3.2 Cookiecutter.
40 changes: 12 additions & 28 deletions development/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,18 @@ RUN --mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
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

# 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

# TBD: Verify following instruction
# Install wheel to avoid deprecation warnings related to https://github.com/pypa/pip/issues/8559
RUN --mount=type=cache,target=/root/.cache/pip pip install \
wheel==0.41.1

# 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]

# 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
# Build args must be declared in each stage
ARG PYTHON_VER

# 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 the app
RUN poetry install --extras all --with dev

COPY development/nautobot_config.py ${NAUTOBOT_ROOT}/nautobot_config.py

Expand Down
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_circuit_maintenance:
project_name: "nautobot-circuit-maintenance"
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-circuit-maintenance/development"

# The following is an example of using MySQL as the database backend
# ---
# nautobot_circuit_maintenance:
# 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-circuit-maintenance/docs"
edit_uri: "edit/main/docs"
site_dir: "nautobot_circuit_maintenance/static/nautobot_circuit_maintenance/docs"
site_name: "Circuit Maintenance Documentation"
site_url: "https://docs.nautobot.com/projects/circuit-maintenance/en/latest/"
Expand Down
19 changes: 6 additions & 13 deletions nautobot_circuit_maintenance/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Meta:
"""Meta class attributes for CircuitMaintenanceFilterSet."""

model = CircuitMaintenance
fields = ["id", "name", "status", "ack"]
fields = '__all__'

def search(self, queryset, name, value): # pylint: disable=unused-argument
"""Perform the filtered search."""
Expand Down Expand Up @@ -71,7 +71,7 @@ class Meta:
"""Meta class attributes for CircuitImpactFilterSet."""

model = CircuitImpact
fields = ["id", "maintenance", "circuit", "impact"]
fields = '__all__'


class NoteFilterSet(NautobotFilterSet):
Expand All @@ -88,7 +88,7 @@ class Meta:
"""Meta class attributes for NoteFilterSet."""

model = Note
fields = ["id", "maintenance", "title"]
fields = '__all__'

def search(self, queryset, name, value): # pylint: disable=unused-argument
"""Perform the filtered search."""
Expand Down Expand Up @@ -124,14 +124,7 @@ class RawNotificationFilterSet(NautobotFilterSet):

class Meta: # noqa: D106 "Missing docstring in public nested class"
model = RawNotification
fields = [
"subject",
"provider",
"sender",
"source",
"parsed",
"stamp",
]
exclude = ["raw"]

def search(self, queryset, name, value): # pylint: disable=unused-argument
"""Perform the filtered search."""
Expand Down Expand Up @@ -160,7 +153,7 @@ class Meta:
"""Meta class attributes for ParsedNotificationFilterSet."""

model = ParsedNotification
fields = ["maintenance", "raw_notification", "json"]
fields = '__all__'

def search(self, queryset, name, value): # pylint: disable=unused-argument
"""Perform the filtered search."""
Expand All @@ -182,7 +175,7 @@ class Meta:
"""Meta class attributes for NotificationSourceFilterSet."""

model = NotificationSource
fields = ["name", "attach_all_providers"]
exclude = ["_token"]

def search(self, queryset, name, value): # pylint: disable=unused-argument
"""Perform the filtered search."""
Expand Down
2 changes: 1 addition & 1 deletion nautobot_circuit_maintenance/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def get_absolute_url(self, api=False):
"""Returns reverse loop up URL."""
return reverse("plugins:nautobot_circuit_maintenance:notificationsource", args=[self.pk])

# TODO: Look if we can replace token with Nautobot Secrets.
# TODO: Look if we can replace token with Nautobot Secrets.
@property
def token(self):
"""Getter for _token."""
Expand Down
Loading

0 comments on commit 93222f2

Please sign in to comment.