Skip to content

Commit

Permalink
lib-v2: allow setting hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros-k committed Oct 25, 2024
1 parent 72e14a1 commit 42b7131
Show file tree
Hide file tree
Showing 49 changed files with 17 additions and 1 deletion.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions library/2.0.1/container.py → library/2.0.2/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(self, render_instance: "Render", name: str, image: str):
self._user: str = ""
self._tty: bool = False
self._stdin_open: bool = False
self._hostname: str = ""
self._cap_drop: set[str] = set(["ALL"]) # Drop all capabilities by default and add caps granularly
self._cap_add: set[str] = set()
self._security_opt: set[str] = set(["no-new-privileges"])
Expand Down Expand Up @@ -118,6 +119,9 @@ def set_tty(self, enabled: bool = False):
def set_stdin(self, enabled: bool = False):
self._stdin_open = enabled

def set_hostname(self, hostname: str):
self._hostname = hostname

def set_grace_period(self, grace_period: int):
if grace_period < 0:
raise RenderError(f"Grace period [{grace_period}] cannot be negative")
Expand Down Expand Up @@ -161,6 +165,10 @@ def render(self) -> dict[str, Any]:
"cap_drop": sorted(self._cap_drop),
"healthcheck": self.healthcheck.render(),
}

if self._hostname:
result["hostname"] = self._hostname

if self._build_image:
result["build"] = {"tags": [self._image], "dockerfile_inline": self._build_image}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ def test_stdin(mock_values):
assert output["services"]["test_container"]["stdin_open"] is True


def test_hostname(mock_values):
render = Render(mock_values)
c1 = render.add_container("test_container", "test_image")
c1.set_hostname("test_hostname")
output = render.render()
assert output["services"]["test_container"]["hostname"] == "test_hostname"


def test_grace_period(mock_values):
render = Render(mock_values)
c1 = render.add_container("test_container", "test_image")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion library/hashes.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
0.0.1: f074617a82a86d2a6cc78a4c8a4296fc9d168e456f12713e50c696557b302133
1.1.4: 6e32ff5969906d9c3a10fea2b17fdd3197afb052d3432344da03188d8a907113
2.0.1: 77e44b15832ac747aadc0d04c3eaac54cd0a9810cf761670b0215cb9c6aa7608
2.0.2: b1b52e42808f339fea7e15eab30d1902dd038d65e86cf59544798e75aff6753a

0 comments on commit 42b7131

Please sign in to comment.