Skip to content

Commit

Permalink
Applied patch to #101
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo93 committed Oct 5, 2020
1 parent 1684b66 commit 85c806c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
31 changes: 30 additions & 1 deletion src/Resources/command/SettingsCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,35 @@ def __init__(self):
)
)

enable_ipv6_item = SubmenuItem(enable_ipv6_string, enable_ipv6_menu, menu)
enable_ipv6_item = SubmenuItem(
enable_ipv6_string, enable_ipv6_menu, menu)

# Windows WLS2 Option
win_wls2_string = "(**Windows only**) Enable WLS2 Support"
win_wls2_menu = SelectionMenu(strings=[],
title=win_wls2_string,
subtitle=current_bool("win_wls2"),
formatter=menu_formatter,
prologue_text="""This option is used only on Windows OS.
Enables the support for Docker using WLS2.
Default is %s.""" % format_bool(
DEFAULTS['win_wls2'])
)

win_wls2_menu.append_item(FunctionItem(text="Yes",
function=self.set_setting_value,
args=['win_wls2', True],
should_exit=True
)
)
win_wls2_menu.append_item(FunctionItem(text="No",
function=self.set_setting_value,
args=['win_wls2', False],
should_exit=True
)
)

win_wls2_item = SubmenuItem(win_wls2_string, win_wls2_menu, menu)

menu.append_item(submenu_item)
menu.append_item(manager_item)
Expand All @@ -375,6 +403,7 @@ def __init__(self):
menu.append_item(debug_level_item)
menu.append_item(print_startup_log_item)
menu.append_item(enable_ipv6_item)
menu.append_item(win_wls2_item)

self.menu = menu

Expand Down
11 changes: 8 additions & 3 deletions src/Resources/manager/docker/DockerPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from ... import utils
from ...os.Networking import Networking
from ...setting.Setting import Setting

PLUGIN_NAME = "kathara/katharanp"
BUSTER_TAG = "buster"
Expand All @@ -22,9 +23,13 @@ def _select_plugin_name_linux():
return "%s:%s" % (PLUGIN_NAME, BUSTER_TAG) if 'nf_tables' in iptables_version else \
"%s:%s" % (PLUGIN_NAME, STRETCH_TAG)

self.plugin_name = utils.exec_by_platform(_select_plugin_name_linux,
lambda: "%s:%s" % (PLUGIN_NAME, BUSTER_TAG),
lambda: "%s:%s" % (PLUGIN_NAME, BUSTER_TAG)
def _select_plugin_name_windows():
return "%s:%s" % (PLUGIN_NAME, STRETCH_TAG) if Setting.get_instance().win_wls2 else \
"%s:%s" % (PLUGIN_NAME, BUSTER_TAG)

self.plugin_name = utils.exec_by_platform(_select_plugin_name_linux, _select_plugin_name_windows,
lambda: "%s:%s" % (
PLUGIN_NAME, BUSTER_TAG)
)

def check_and_download_plugin(self):
Expand Down
8 changes: 5 additions & 3 deletions src/Resources/setting/Setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
"device_prefix": 'kathara',
"debug_level": 'INFO',
"print_startup_log": True,
"enable_ipv6": False
"enable_ipv6": False,
"win_wls2": False
}


class Setting(object):
__slots__ = ['image', 'manager_type', 'terminal', 'open_terminals',
'hosthome_mount', 'shared_mount', 'device_shell', 'net_prefix', 'device_prefix', 'debug_level',
'print_startup_log', 'enable_ipv6', 'last_checked']
'print_startup_log', 'enable_ipv6', 'last_checked', 'win_wls2']

__instance = None

Expand Down Expand Up @@ -209,5 +210,6 @@ def _to_dict(self):
"debug_level": self.debug_level,
"print_startup_log": self.print_startup_log,
"last_checked": self.last_checked,
"enable_ipv6": self.enable_ipv6
"enable_ipv6": self.enable_ipv6,
"win_wls2": self.win_wls2
}

0 comments on commit 85c806c

Please sign in to comment.