Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network.type support added #62

Open
wants to merge 7 commits into
base: add/network-args
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
network.type support added
Signed-off-by: scicco <zendar79@gmail.com>
scicco committed Aug 25, 2022
commit 186576549e8a59fc2290fc37fc1df59a618e4fab
13 changes: 10 additions & 3 deletions scompose/project/instance.py
Original file line number Diff line number Diff line change
@@ -221,7 +221,7 @@ def network_args(self):
"""
return self.params.get("network", {}).get("args", [])

def _get_network_commands(self, ip_address=None):
def _get_network_commands(self, ip_address=None, network_type=None):
"""
Take a list of ports, return the list of --network-args to
ensure they are bound correctly.
@@ -236,7 +236,11 @@ def _get_network_commands(self, ip_address=None):
for arg in network_args:
ports += ["--network-args", arg]

if not network_args and (not self.sudo and not fakeroot):
if network_type is not None
# network_type is "bridge" by default when network.enable is True
ports += ["--network", network_type]

if network_type is None and (not self.sudo and not fakeroot):
ports += ["--network", "none"]

for pair in self.ports:
@@ -604,7 +608,10 @@ def create(self, ip_address=None, sudo=False, writable_tmpfs=False):

# Network configuration + Ports
if self.network["enable"]:
options += self._get_network_commands(ip_address)
# if network.enable is true a --network must be always added
# using bridge as default
network_type = self.network["type"] or "bridge"
options += self._get_network_commands(ip_address, network_type)

# Start options
options += self.start_opts