diff options
author | Florian Eckert <fe@dev.tdt.de> | 2020-07-28 15:58:49 +0200 |
---|---|---|
committer | Florian Eckert <fe@dev.tdt.de> | 2020-07-28 16:03:11 +0200 |
commit | dff11ad2404d77be1da786883fa7155b83a67be0 (patch) | |
tree | 91d9e199c4fc06a180b51ac148c048c824dc40bd /applications/luci-app-dockerman/luasrc/model/cbi/dockerman | |
parent | 18c2fef8b38df9d932200da0af7b61120984850a (diff) |
luci-app-dockerman: refactoring remote endpoint options
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Diffstat (limited to 'applications/luci-app-dockerman/luasrc/model/cbi/dockerman')
-rw-r--r-- | applications/luci-app-dockerman/luasrc/model/cbi/dockerman/container.lua | 16 | ||||
-rw-r--r-- | applications/luci-app-dockerman/luasrc/model/cbi/dockerman/overview.lua | 35 |
2 files changed, 31 insertions, 20 deletions
diff --git a/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/container.lua b/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/container.lua index 4f7a05e7f8..dfcb42ddb0 100644 --- a/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/container.lua +++ b/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/container.lua @@ -705,10 +705,18 @@ elseif action == "console" then luci.util.exec(kill_ttyd) local hosts local uci = (require "luci.model.uci").cursor() - local remote = uci:get("dockerd", "globals", "remote_endpoint") - local socket_path = (remote == "false" or not remote) and uci:get("dockerd", "globals", "socket_path") or nil - local host = (remote == "true") and uci:get("dockerd", "globals", "remote_host") or nil - local port = (remote == "true") and uci:get("dockerd", "globals", "remote_port") or nil + local remote = uci:get_bool("dockerd", "globals", "remote_endpoint") + local host = nil + local port = nil + local socket = nil + + if remote then + host = uci:get("dockerd", "globals", "remote_host") or nil + port = uci:get("dockerd", "globals", "remote_port") or nil + else + socket = uci:get("dockerd", "globals", "socket_path") or nil + end + if remote and host and port then hosts = host .. ':'.. port elseif socket_path then diff --git a/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/overview.lua b/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/overview.lua index 04a1f0e99e..c2ed6b139f 100644 --- a/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/overview.lua +++ b/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/overview.lua @@ -91,41 +91,42 @@ if docker.new():_ping().code == 200 then end s = m:section(NamedSection, "globals", "section", translate("Setting")) -s:tab("daemon", translate("Docker Daemon")) -s:tab("dockerman", translate("DockerMan")) -o = s:taboption("dockerman", Value, "socket_path", +o = s:option(Flag, "remote_endpoint", + translate("Remote Endpoint"), + translate("Connect to remote endpoint")) +o.rmempty = false + +o = s:option(Value, "socket_path", translate("Docker Socket Path")) o.default = "/var/run/docker.sock" o.placeholder = "/var/run/docker.sock" o.rmempty = false +o:depends("remote_endpoint", 1) -o = s:taboption("dockerman", Flag, "remote_endpoint", - translate("Remote Endpoint"), - translate("Dockerman connect to remote endpoint")) -o.rmempty = false -o.enabled = "true" -o.disabled = "false" - -o = s:taboption("dockerman", Value, "remote_host", +o = s:option(Value, "remote_host", translate("Remote Host")) o.placeholder = "10.1.1.2" +o:depends("remote_endpoint", 1) -o = s:taboption("dockerman", Value, "remote_port", +o = s:option(Value, "remote_port", translate("Remote Port")) o.placeholder = "2375" o.default = "2375" +o:depends("remote_endpoint", 1) if nixio.fs.access("/usr/bin/dockerd") then - o = s:taboption("daemon", Value, "data_root", + o = s:option(Value, "data_root", translate("Docker Root Dir")) o.placeholder = "/opt/docker/" + o:depends("remote_endpoint", 0) - o = s:taboption("daemon", DynamicList, "registry_mirrors", + o = s:option(DynamicList, "registry_mirrors", translate("Registry Mirrors")) o:value("https://hub-mirror.c.163.com", "https://hub-mirror.c.163.com") + o:depends("remote_endpoint", 0) - o = s:taboption("daemon", ListValue, "log_level", + o = s:option(ListValue, "log_level", translate("Log Level"), translate('Set the logging level')) o:value("debug", "debug") @@ -133,13 +134,15 @@ if nixio.fs.access("/usr/bin/dockerd") then o:value("warn", "warn") o:value("error", "error") o:value("fatal", "fatal") + o:depends("remote_endpoint", 0) - o = s:taboption("daemon", DynamicList, "hosts", + o = s:option(DynamicList, "hosts", translate("Client connection"), translate('Specifies where the Docker daemon will listen for client connections')) o:value("unix://var/run/docker.sock", "unix://var/run/docker.sock") o:value("tcp://0.0.0.0:2375", "tcp://0.0.0.0:2375") o.rmempty = true + o:depends("remote_endpoint", 0) end return m |