Skip to content

Commit

Permalink
Merge pull request #321 from nautobot/drift-manager/pr
Browse files Browse the repository at this point in the history
Cookie updated by NetworkToCode Cookie Drift Manager Tool
  • Loading branch information
smk4664 authored Aug 12, 2024
2 parents 8f6b03d + 6e7b625 commit a9782d2
Show file tree
Hide file tree
Showing 115 changed files with 552 additions and 691 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.2.1",
"template_ref": "refs/tags/nautobot-app-v2.3.0",
"cookie_dir": "",
"branch_prefix": "drift-manager",
"pull_request_strategy": "create",
"post_actions": [
"black"
],
"draft": true,
"baked_commit_ref": "cfd9475f3ea601572d0f3b23d4bb6d9655bc2721"
"baked_commit_ref": "76744d296d468b03fb528c902f68c3dc230a9a3f"
}
}
}
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ FAQ.md
.git/
.gitignore
.github
tasks.py
LICENSE
**/*.log
**/.vscode/
Expand Down
36 changes: 6 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
APP_NAME: "nautobot-app-chatops"

jobs:
black:
ruff-format:
runs-on: "ubuntu-22.04"
env:
INVOKE_NAUTOBOT_CHATOPS_LOCAL: "True"
Expand All @@ -25,20 +25,9 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Linting: black"
run: "poetry run invoke black"
bandit:
runs-on: "ubuntu-22.04"
env:
INVOKE_NAUTOBOT_CHATOPS_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Linting: bandit"
run: "poetry run invoke bandit"
ruff:
- name: "Linting: ruff format"
run: "poetry run invoke ruff --action format"
ruff-lint:
runs-on: "ubuntu-22.04"
env:
INVOKE_NAUTOBOT_CHATOPS_LOCAL: "True"
Expand All @@ -60,17 +49,6 @@ jobs:
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Check Docs Build"
run: "poetry run invoke build-and-check-docs"
flake8:
runs-on: "ubuntu-22.04"
env:
INVOKE_NAUTOBOT_CHATOPS_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
- name: "Linting: flake8"
run: "poetry run invoke flake8"
poetry:
runs-on: "ubuntu-22.04"
env:
Expand All @@ -95,12 +73,10 @@ jobs:
run: "poetry run invoke yamllint"
check-in-docker:
needs:
- "bandit"
- "ruff"
- "flake8"
- "ruff-format"
- "ruff-lint"
- "poetry"
- "yamllint"
- "black"
runs-on: "ubuntu-22.04"
strategy:
fail-fast: true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<a href="https://pypi.org/project/nautobot-chatops/"><img src="https://img.shields.io/pypi/v/nautobot-chatops"></a>
<a href="https://pypi.org/project/nautobot-chatops/"><img src="https://img.shields.io/pypi/dm/nautobot-chatops"></a>
<br>
A multi-platform ChatOps bot <a href="https://www.networktocode.com/nautobot/apps/">App</a> for <a href="https://nautobot.com/">Nautobot</a>.
An <a href="https://networktocode.com/nautobot-apps/">App</a> for <a href="https://nautobot.com/">Nautobot</a>.
</p>

## Overview
Expand Down
1 change: 1 addition & 0 deletions changes/321.housekeeping
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rebake with 2.3.0 Cookiecutter.
1 change: 1 addition & 0 deletions development/app_config_schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""App Config Schema Generator and Validator."""

import json
from importlib import import_module
from os import getenv
Expand Down
1 change: 0 additions & 1 deletion development/docker-compose.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ x-nautobot-base: &nautobot-base
- "creds.env"
tty: true

version: "3.8"
services:
nautobot:
depends_on:
Expand Down
1 change: 0 additions & 1 deletion development/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# any override will need to include these volumes to use them.
# see: https://github.com/docker/compose/issues/3729
---
version: "3.8"
services:
nautobot:
command: "nautobot-server runserver 0.0.0.0:8080"
Expand Down
2 changes: 0 additions & 2 deletions development/docker-compose.mysql.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
version: "3.8"

services:
nautobot:
environment:
Expand Down
2 changes: 0 additions & 2 deletions development/docker-compose.postgres.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
version: "3.8"

services:
nautobot:
environment:
Expand Down
1 change: 0 additions & 1 deletion development/docker-compose.redis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
version: "3.8"
services:
redis:
image: "redis:6-alpine"
Expand Down
9 changes: 4 additions & 5 deletions development/mattermost/nautobot_bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
"""Bootstrap script for Nautobot to allow Mattermost integration."""


import contextlib

from django.contrib.auth import get_user_model
from django.core.exceptions import ObjectDoesNotExist

from nautobot_chatops.models import (
AccessGrantTypeChoices,
PlatformChoices,
AccessGrant,
CommandToken,
AccessGrantTypeChoices,
ChatOpsAccountLink,
CommandToken,
PlatformChoices,
)


User = get_user_model()

for grant_type in AccessGrantTypeChoices.values():
Expand Down
10 changes: 6 additions & 4 deletions development/nautobot_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nautobot development configuration file."""

import os
import sys

Expand All @@ -9,7 +10,7 @@
# Debug
#

DEBUG = is_truthy(os.getenv("NAUTOBOT_DEBUG", False))
DEBUG = is_truthy(os.getenv("NAUTOBOT_DEBUG", "false"))
_TESTING = len(sys.argv) > 1 and sys.argv[1] == "test"

if DEBUG and not _TESTING:
Expand Down Expand Up @@ -47,9 +48,10 @@
"PASSWORD": os.getenv("NAUTOBOT_DB_PASSWORD", ""), # Database password
"HOST": os.getenv("NAUTOBOT_DB_HOST", "localhost"), # Database server
"PORT": os.getenv(
"NAUTOBOT_DB_PORT", default_db_settings[nautobot_db_engine]["NAUTOBOT_DB_PORT"]
"NAUTOBOT_DB_PORT",
default_db_settings[nautobot_db_engine]["NAUTOBOT_DB_PORT"],
), # Database port, default to postgres
"CONN_MAX_AGE": int(os.getenv("NAUTOBOT_DB_TIMEOUT", 300)), # Database timeout
"CONN_MAX_AGE": int(os.getenv("NAUTOBOT_DB_TIMEOUT", "300")), # Database timeout
"ENGINE": nautobot_db_engine,
}
}
Expand Down Expand Up @@ -171,7 +173,7 @@
"tower_password": os.getenv("NAUTOBOT_TOWER_PASSWORD"),
"tower_uri": os.getenv("NAUTOBOT_TOWER_URI"),
"tower_username": os.getenv("NAUTOBOT_TOWER_USERNAME"),
"tower_verify_ssl": is_truthy(os.getenv("NAUTOBOT_TOWER_VERIFY_SSL", True)),
"tower_verify_ssl": is_truthy(os.getenv("NAUTOBOT_TOWER_VERIFY_SSL", "true")),
# - Arista CloudVision ---------------
"enable_aristacv": is_truthy(os.getenv("NAUTOBOT_CHATOPS_ENABLE_ARISTACV")),
"aristacv_cvaas_url": os.environ.get("ARISTACV_CVAAS_URL"),
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ a.autorefs-external:hover::after {
}


/* Customization for mkdocs-version-annotations */
/* Customization for markdown-version-annotations */
:root {
/* Icon for "version-added" admonition: Material Design Icons "plus-box-outline" */
--md-admonition-icon--version-added: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 19V5H5v14h14m0-16a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14m-8 4h2v4h4v2h-4v4h-2v-4H7v-2h4V7Z"/></svg>');
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The project is packaged with a light [development environment](dev_environment.m

The project is following Network to Code software development guidelines and is leveraging the following:

- Python linting and formatting: `black`, `pylint`, `bandit`, `flake8`, and `ruff`.
- Python linting and formatting: `pylint` and `ruff`.
- YAML linting is done with `yamllint`.
- Django unit test to ensure the app is working properly.

Expand Down
10 changes: 2 additions & 8 deletions docs/dev/dev_environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,7 @@ Each command can be executed with `invoke <command>`. All commands support the a
#### Testing

```
bandit Run bandit to validate basic static code security analysis.
black Run black to check that Python files adhere to its style standards.
flake8 Run flake8 to check that Python files adhere to its style standards.
ruff Run ruff to validate docstring formatting adheres to NTC defined standards.
ruff Run ruff to perform code formatting and/or linting.
pylint Run pylint code analysis.
tests Run all tests for this app.
unittest Run Django unit tests for the app.
Expand Down Expand Up @@ -462,7 +459,7 @@ This is the same as running:

### Tests

To run tests against your code, you can run all the tests that GitHub CI runs against any new PR with:
To run tests against your code, you can run all of the tests that the CI runs against any new PR with:

```bash
➜ invoke tests
Expand All @@ -472,9 +469,6 @@ To run an individual test, you can run any or all of the following:

```bash
➜ invoke unittest
➜ invoke bandit
➜ invoke black
➜ invoke flake8
➜ invoke ruff
➜ invoke pylint
```
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mkdocs==1.5.2
mkdocs-material==9.1.15
mkdocs-version-annotations==1.0.0
markdown-version-annotations==1.0.1
mkdocstrings-python==1.5.2
mkdocstrings==0.22.0
mkdocs-include-markdown-plugin==6.0.3
3 changes: 2 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ extra:
link: "https://twitter.com/networktocode"
name: "Network to Code Twitter"
markdown_extensions:
- "markdown_version_annotations":
admonition_tag: "???"
- "admonition"
- "toc":
permalink: true
Expand All @@ -89,7 +91,6 @@ markdown_extensions:
- "footnotes"
plugins:
- "search"
- "mkdocs-version-annotations"
- "mkdocstrings":
default_handler: "python"
handlers:
Expand Down
2 changes: 2 additions & 0 deletions nautobot_chatops/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""App declaration for nautobot_chatops."""

# Metadata is inherited from Nautobot. If not including Nautobot in the environment, this should be added
from importlib import metadata

Expand Down Expand Up @@ -158,6 +159,7 @@ def ready(self):
super().ready()
# pylint: disable=import-outside-toplevel
from nautobot_capacity_metrics import register_metric_func

from .metrics_app import metric_commands

register_metric_func(metric_commands)
Expand Down
1 change: 1 addition & 0 deletions nautobot_chatops/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Administrative capabilities for nautobot_chatops app."""

from django.contrib import admin

from .models import ChatOpsAccountLink, CommandLog


Expand Down
3 changes: 1 addition & 2 deletions nautobot_chatops/api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""API Serializers for ChatOps App."""

from rest_framework import serializers

from nautobot.core.api import NautobotModelSerializer
from rest_framework import serializers

from nautobot_chatops.models import AccessGrant, CommandLog, CommandToken

Expand Down
6 changes: 3 additions & 3 deletions nautobot_chatops/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.urls import include, path
from nautobot.apps.api import OrderedDefaultRouter
from nautobot.apps.config import get_app_settings_or_config

from nautobot_chatops.api.views.generic import (
AccessGrantViewSet,
CommandLogViewSet,
Expand All @@ -13,15 +14,14 @@
)
from nautobot_chatops.api.views.lookup import AccessLookupView, UserEmailLookupView


logger = logging.getLogger(__name__)
urlpatterns = [
path("lookup/", AccessLookupView.as_view(), name="access_lookup"),
path("email-lookup/", UserEmailLookupView.as_view(), name="email_lookup"),
]

if get_app_settings_or_config("nautobot_chatops", "enable_slack"):
from nautobot_chatops.api.views.slack import SlackSlashCommandView, SlackInteractionView, SlackEventAPIView
from nautobot_chatops.api.views.slack import SlackEventAPIView, SlackInteractionView, SlackSlashCommandView

urlpatterns += [
path("slack/slash_command/", SlackSlashCommandView.as_view(), name="slack_slash_command"),
Expand All @@ -44,7 +44,7 @@
]

if get_app_settings_or_config("nautobot_chatops", "enable_mattermost"):
from nautobot_chatops.api.views.mattermost import MattermostSlashCommandView, MattermostInteractionView
from nautobot_chatops.api.views.mattermost import MattermostInteractionView, MattermostSlashCommandView

urlpatterns += [
path("mattermost/slash_command/", MattermostSlashCommandView.as_view(), name="mattermost_slash_command"),
Expand Down
5 changes: 3 additions & 2 deletions nautobot_chatops/api/views/generic.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""API Views for Nautobot Chatops."""
from rest_framework.routers import APIRootView

from nautobot.apps.api import NautobotModelViewSet
from rest_framework.routers import APIRootView

from nautobot_chatops.api.serializers import AccessGrantSerializer, CommandLogSerializer, CommandTokenSerializer
from nautobot_chatops.models import AccessGrant, CommandLog, CommandToken
from nautobot_chatops.filters import AccessGrantFilterSet, CommandLogFilterSet, CommandTokenFilterSet
from nautobot_chatops.models import AccessGrant, CommandLog, CommandToken


class NautobotChatopsRootView(APIRootView):
Expand Down
3 changes: 2 additions & 1 deletion nautobot_chatops/api/views/lookup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""API views for dynamic lookup of platform-specific data."""

import contextlib
from django.http import JsonResponse, HttpResponseBadRequest, HttpResponseNotFound

from django.http import HttpResponseBadRequest, HttpResponseNotFound, JsonResponse
from django.views import View

from nautobot_chatops.dispatchers import Dispatcher
Expand Down
8 changes: 4 additions & 4 deletions nautobot_chatops/api/views/mattermost.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
from django.views import View
from django.views.decorators.csrf import csrf_exempt

from nautobot_chatops.workers import get_commands_registry, commands_help, parse_command_string
from nautobot_chatops.dispatchers.mattermost import MattermostDispatcher, Driver
from nautobot_chatops.utils import check_and_enqueue_command
from nautobot_chatops.choices import PlatformChoices
from nautobot_chatops.dispatchers.mattermost import Driver, MattermostDispatcher
from nautobot_chatops.metrics import signature_error_cntr
from nautobot_chatops.models import CommandToken
from nautobot_chatops.choices import PlatformChoices
from nautobot_chatops.utils import check_and_enqueue_command
from nautobot_chatops.workers import commands_help, get_commands_registry, parse_command_string

# pylint: disable=logging-fstring-interpolation

Expand Down
Loading

0 comments on commit a9782d2

Please sign in to comment.