Skip to content

Commit

Permalink
[Image] Docker run restart policy support (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
omesser authored Jul 13, 2024
1 parent 1bda67b commit 9c5283a
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 86 deletions.
16 changes: 13 additions & 3 deletions .idea/runConfigurations/_it__basic_commands.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions .idea/runConfigurations/_it__shell_commands.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions .idea/runConfigurations/_ut__manof.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fmt:
.PHONY: fmt-check
fmt-check:
@echo "Running black fmt check..."
$(VENV_PYTHON) -m black --skip-string-normalization --check --diff -S --exclude='.*venv.*' .
$(VENV_PYTHON) -m black --skip-string-normalization --check --diff .

.PHONY: test
test: test-unit test-integ
Expand Down
10 changes: 9 additions & 1 deletion manof/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def run(self):
for env in self._update_env_override():

# single environment variable means set it to itself (x=x), thus forwarding the variable from the
# outter env into the docker env
# outer env into the docker env
if isinstance(env, str):
lvalue = env
rvalue = os.environ.get(lvalue, None)
Expand Down Expand Up @@ -212,6 +212,10 @@ def run(self):
if cap:
command += '--cap-drop={0} '.format(cap)

# set restart policy
if self.restart:
command += '--restart={0} '.format(self.restart)

command = self._add_device_arguments(command)

# set tag
Expand Down Expand Up @@ -727,6 +731,10 @@ def device_write_iops(self):

return None

@property
def restart(self):
return None

def to_dict(self):
d = super(Image, self).to_dict()
for idx, item in enumerate(d['volumes']):
Expand Down
21 changes: 17 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
[project]
name = "manof"
requires-python = ">=3.7,<3.10"
version = "0.1.2"
authors = [
{name = "LiranBG", email = "liran_ben_gida@mckinsey.com"},
]

[tool.setuptools]
py-modules = []

# please keep this to a minimum - defaults are good
[tool.black]
exclude = '''
/(
^/( # anchor to the root
( # exclude these directories
\.git
| \.venv
| \venv
)/
| \.venv
| venv
)/
)
'''
21 changes: 20 additions & 1 deletion tests/integration/cases/shell_commands/artifacts/manofest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,31 @@ def image_name(self):

@property
def command(self):
return '/bin/sh -c "echo \'{0}\'"'.format(self.name)
return '/bin/sh -c "echo \'{0}\' && sleep infinity"'.format(self.name)


class TestImage2(TestImage):
@property
def restart(self):
return 'on-failure:5'

@property
def memory(self):
return '6Mib'

@property
def cpus(self):
return '1'

@property
def cap_add(self):
return ['SYS_ADMIN']


class SomeGroup(manof.Group):
@property
def members(self):
return [
'TestImage',
'TestImage2',
]
Loading

0 comments on commit 9c5283a

Please sign in to comment.