Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/main_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: main branch CI
on:
push:
branches:
- "main"
- "main_v4"

jobs:
testing:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Pull Request CI
on:
pull_request:
branches:
- "main"
- "main_v4"

jobs:
testing:
Expand Down
2 changes: 1 addition & 1 deletion netbox_docker_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class NetBoxDockerConfig(PluginConfig):
name = "netbox_docker_plugin"
verbose_name = " NetBox Docker Plugin"
description = "Manage Docker"
version = "4.12.1"
version = "4.12.2"
base_url = "docker"
min_version = "4.3.7"
author = "Vincent Simonin <vincent@saashup.com>, David Delassus <david.jose.delassus@gmail.com>"
Expand Down
9 changes: 7 additions & 2 deletions netbox_docker_plugin/models/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,27 @@ class ContainerCapAddChoices(ChoiceSet):
key = "Container.cap_add"

CHOICES = [
("NET_ADMIN", "NET_ADMIN"),
("AUDIT_WRITE", "AUDIT_WRITE"),
("CHOWN", "CHOWN"),
("DAC_OVERRIDE", "DAC_OVERRIDE"),
("DAC_READ_SEARCH", "DAC_READ_SEARCH"),
("FOWNER", "FOWNER"),
("FSETID", "FSETID"),
("KILL", "KILL"),
("MKNOD", "MKNOD"),
("NET_ADMIN", "NET_ADMIN"),
("NET_BIND_SERVICE", "NET_BIND_SERVICE"),
("NET_RAW", "NET_RAW"),
("SETFCAP", "SETFCAP"),
("SETGID", "SETGID"),
("SETPCAP", "SETPCAP"),
("SETUID", "SETUID"),
("SYS_ADMIN", "SYS_ADMIN"),
("SYS_CHROOT", "SYS_CHROOT"),
("SYS_NICE", "SYS_NICE"),
("SYS_PTRACE", "SYS_PTRACE"),
("SYS_RESOURCE", "SYS_RESOURCE"),
("SYS_NICE", "SYS_NICE"),
("ALL", "ALL"),
]


Expand Down
96 changes: 96 additions & 0 deletions netbox_docker_plugin/tests/container/test_agent_compatibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"""Agent compatibility regression tests.

Each test pins one payload shape that netbox-docker-agent >= 1.25 sends back to
NetBox and that plugin 3.3.0 rejected. See the migrations 0036 to 0038.
"""

from django.test import TestCase
from netbox_docker_plugin.models.container import Container, Env, Port
from netbox_docker_plugin.models.host import Host
from netbox_docker_plugin.models.image import Image
from netbox_docker_plugin.models.registry import Registry


class AgentCompatibilityTestCase(TestCase):
"""Agent Compatibility Test Case Class"""

objects = {}

@classmethod
def setUpTestData(cls) -> None:
cls.objects["host1"] = Host.objects.create(
endpoint="http://localhost:8080", name="host1"
)
cls.objects["registry1"] = Registry.objects.create(
host=cls.objects["host1"],
name="registry1",
serveraddress="http://localhost:8080",
)
cls.objects["image1"] = Image.objects.create(
host=cls.objects["host1"],
name="image1",
registry=cls.objects["registry1"],
)

def _container(self, name, **kwargs):
"""Create a container on the shared fixture host"""

container = Container.objects.create(
host=self.objects["host1"],
image=self.objects["image1"],
name=name,
operation="none",
state="created",
**kwargs,
)
container.full_clean()
return container

def test_docker_log_drivers_are_accepted(self):
"""The agent reports LogConfig.Type verbatim from the Docker daemon"""

for index, driver in enumerate(
["json-file", "syslog", "journald", "local", "none"]
):
container = self._container(f"container-log-{index}", log_driver=driver)
self.assertEqual(container.log_driver, driver)

def test_log_driver_may_be_empty(self):
"""A container created before any refresh has no log driver yet"""

container = self._container("container-log-null")
self.assertIsNone(container.log_driver)

def test_unpublished_port_is_accepted(self):
"""The agent uses -1 for exposed but unpublished ports"""

container = self._container("container-port")
port = Port.objects.create(
container=container,
private_port=8080,
public_port=-1,
type="tcp",
)
port.full_clean()
self.assertEqual(port.public_port, -1)

def test_docker_capabilities_are_accepted(self):
"""The agent reports the container capabilities with CAP_ stripped"""

container = self._container(
"container-caps",
cap_add=["CHOWN", "SETUID", "SYS_ADMIN", "MKNOD"],
)
self.assertEqual(len(container.cap_add), 4)

def test_long_environment_value_is_accepted(self):
"""Inline configuration and certificates exceed the old 4096 ceiling"""

container = self._container("container-env")
env = Env.objects.create(
container=container,
var_name="BIG_VALUE",
value="x" * 20000,
)
env.full_clean()
self.assertEqual(len(env.value), 20000)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "netbox-docker-plugin"
version = "4.12.1"
version = "4.12.2"
authors = [
{ name="Vincent Simonin", email="vincent@saashup.com" },
{ name="David Delassus", email="david.jose.delassus@gmail.com" }
Expand Down
Loading