outpost: add additional labels to docker container
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
dc41d0af27
commit
12ddee3bb6
|
@ -29,7 +29,9 @@ class DockerController(BaseController):
|
||||||
raise ControllerException from exc
|
raise ControllerException from exc
|
||||||
|
|
||||||
def _get_labels(self) -> dict[str, str]:
|
def _get_labels(self) -> dict[str, str]:
|
||||||
return {}
|
return {
|
||||||
|
"io.goauthentik.outpost-uuid": self.outpost.pk.hex,
|
||||||
|
}
|
||||||
|
|
||||||
def _get_env(self) -> dict[str, str]:
|
def _get_env(self) -> dict[str, str]:
|
||||||
return {
|
return {
|
||||||
|
@ -49,6 +51,17 @@ class DockerController(BaseController):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _comp_labels(self, container: Container) -> bool:
|
||||||
|
"""Check if container's labels is equal to what we would set. Return true if container needs
|
||||||
|
to be rebuilt."""
|
||||||
|
should_be = self._get_labels()
|
||||||
|
for key, expected_value in should_be.items():
|
||||||
|
if key not in container.labels:
|
||||||
|
return True
|
||||||
|
if container.labels[key] != expected_value:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def _comp_ports(self, container: Container) -> bool:
|
def _comp_ports(self, container: Container) -> bool:
|
||||||
"""Check that the container has the correct ports exposed. Return true if container needs
|
"""Check that the container has the correct ports exposed. Return true if container needs
|
||||||
to be rebuilt."""
|
to be rebuilt."""
|
||||||
|
@ -135,6 +148,11 @@ class DockerController(BaseController):
|
||||||
self.logger.info("Container has outdated config, re-creating...")
|
self.logger.info("Container has outdated config, re-creating...")
|
||||||
self.down()
|
self.down()
|
||||||
return self.up(depth + 1)
|
return self.up(depth + 1)
|
||||||
|
# Check that container values match our values
|
||||||
|
if self._comp_labels(container):
|
||||||
|
self.logger.info("Container has outdated labels, re-creating...")
|
||||||
|
self.down()
|
||||||
|
return self.up(depth + 1)
|
||||||
if (
|
if (
|
||||||
container.attrs.get("HostConfig", {})
|
container.attrs.get("HostConfig", {})
|
||||||
.get("RestartPolicy", {})
|
.get("RestartPolicy", {})
|
||||||
|
|
Reference in New Issue