From ca6fa1834e73e66442a0da01a2246cc86b077b3d Mon Sep 17 00:00:00 2001 From: Vanessasaurus <814322+vsoch@users.noreply.github.com> Date: Sat, 11 May 2024 13:05:55 -0600 Subject: [PATCH] feat: support for network type (#72) * feat: support for network type * example for --network=fakeroot Signed-off-by: vsoch --- CHANGELOG.md | 1 + docs/commands.md | 2 ++ docs/spec/spec-2.0.md | 20 ++++++++++++++++++++ scompose/project/instance.py | 7 ++++++- scompose/version.py | 2 +- 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f17d2d0..afaa42e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are: The versions coincide with releases on pypi. ## [0.1.x](https://github.com/singularityhub/singularity-compose/tree/master) (0.1.x) + - support for custom network type (0.1.19) - fix 'bridge' option for 'up' command (0.1.18) - add support for instance replicas (0.1.17) - fix check command validation (0.1.16) diff --git a/docs/commands.md b/docs/commands.md index e054bd5..d2b1488 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -2,6 +2,8 @@ The following commands are currently supported. Remember, you must be in the present working directory of the compose file to reference the correct instances. +Along with the below, you can find more details and examples for singularity-compose.yaml +syntax under the [current spec](spec/spec-2.0.md) ## check diff --git a/docs/spec/spec-2.0.md b/docs/spec/spec-2.0.md index db1338d..ceaf0c0 100644 --- a/docs/spec/spec-2.0.md +++ b/docs/spec/spec-2.0.md @@ -149,6 +149,26 @@ The example below will disable the network features: enable: true | false ``` +### Custom Network + +If you want to add your own customized string of network types for `--network`, just do that: + +```yaml + instance1: + ... + network: + type: bridge +``` + +You might also want `--network=fakeroot`: + +```yaml + instance1: + ... + network: + type: fakeroot +``` + ## Start Group diff --git a/scompose/project/instance.py b/scompose/project/instance.py index 5313b97..d27a52f 100644 --- a/scompose/project/instance.py +++ b/scompose/project/instance.py @@ -226,8 +226,13 @@ def _get_network_commands(self, ip_address=None): # Fakeroot means not needing sudo fakeroot = "--fakeroot" in self.start_opts or "-f" in self.start_opts + # Do we have a custom type? + network_type = self.network.get("type") + if network_type is not None: + ports += ["--network", network_type] + # If not sudo or fakeroot, we need --network none - if not self.sudo and not fakeroot: + elif not self.sudo and not fakeroot: ports += ["--network", "none"] for pair in self.ports: diff --git a/scompose/version.py b/scompose/version.py index 3cfcd68..0399690 100644 --- a/scompose/version.py +++ b/scompose/version.py @@ -8,7 +8,7 @@ """ -__version__ = "0.1.18" +__version__ = "0.1.19" AUTHOR = "Vanessa Sochat" AUTHOR_EMAIL = "vsoch@users.noreply.github.com" NAME = "singularity-compose"