diff --git a/config/test.exs b/config/test.exs index 27d7ac52..864b506b 100644 --- a/config/test.exs +++ b/config/test.exs @@ -2,6 +2,8 @@ import Config config :uplink, Uplink.Data, mode: "pro" +config :uplink, Uplink.Monitors, enabled: false + config :uplink, Uplink.Repo, username: System.get_env("UPLINK_DB_USERNAME") || System.get_env("POSTGRES_USERNAME"), diff --git a/lib/uplink/monitors.ex b/lib/uplink/monitors.ex index 317af6a5..b89d8572 100644 --- a/lib/uplink/monitors.ex +++ b/lib/uplink/monitors.ex @@ -12,7 +12,13 @@ defmodule Uplink.Monitors do } def start_link(options) do - Task.start_link(__MODULE__, :run, [options]) + enabled? = config(:enabled, true) + + if enabled? do + Task.start_link(__MODULE__, :run, [options]) + else + :ignore + end end def run(_options) do @@ -59,4 +65,9 @@ defmodule Uplink.Monitors do Pipelines.start(module) end + + def config(key, default) do + Application.get_env(:uplink, __MODULE__) + |> Keyword.get(key, default) + end end diff --git a/lib/uplink/packages/instance/install.ex b/lib/uplink/packages/instance/install.ex index 37909553..513264dc 100644 --- a/lib/uplink/packages/instance/install.ex +++ b/lib/uplink/packages/instance/install.ex @@ -2,7 +2,6 @@ defmodule Uplink.Packages.Instance.Install do use Oban.Worker, queue: :instance, max_attempts: 3 alias Uplink.Repo - alias Uplink.Cache alias Uplink.Instances alias Uplink.Clients.LXD diff --git a/mix.exs b/mix.exs index 804ef261..64f86dde 100644 --- a/mix.exs +++ b/mix.exs @@ -67,7 +67,7 @@ defmodule Uplink.MixProject do # Infrastructure {:formation, "~> 0.15"}, - {:lexdee, path: "../lexdee", override: true}, + {:lexdee, "~> 2.4.4"}, {:plug_cowboy, "~> 2.0"}, {:reverse_proxy_plug, "~> 2.1"}, {:mint_web_socket, "~> 1.0.2"}, diff --git a/mix.lock b/mix.lock index 48f35bb7..883f2736 100644 --- a/mix.lock +++ b/mix.lock @@ -24,7 +24,7 @@ "httpoison": {:hex, :httpoison, "2.2.1", "87b7ed6d95db0389f7df02779644171d7319d319178f6680438167d7b69b1f3d", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "51364e6d2f429d80e14fe4b5f8e39719cacd03eb3f9a9286e61e216feac2d2df"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, - "lexdee": {:hex, :lexdee, "2.4.3", "3049ee1df9ce9478208231bf8e3b1f63c98d2d71d7bfe6491a5b926446cdfe41", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mint, "~> 1.5", [hex: :mint, repo: "hexpm", optional: false]}, {:mint_web_socket, "~> 1.0.2", [hex: :mint_web_socket, repo: "hexpm", optional: false]}, {:tesla, "~> 1.7.0", [hex: :tesla, repo: "hexpm", optional: false]}, {:x509, "~> 0.8.1", [hex: :x509, repo: "hexpm", optional: false]}], "hexpm", "5464fecaaca8cdb773a412738c8bbb288928a21054f8acdbf184515fff628992"}, + "lexdee": {:hex, :lexdee, "2.4.4", "1763f4e0ab7a97cadc25622faaf80ae63186f12bf5e36d1f92bd8d820e31fa16", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mint, "~> 1.5", [hex: :mint, repo: "hexpm", optional: false]}, {:mint_web_socket, "~> 1.0.2", [hex: :mint_web_socket, repo: "hexpm", optional: false]}, {:tesla, "~> 1.7.0", [hex: :tesla, repo: "hexpm", optional: false]}, {:x509, "~> 0.8.1", [hex: :x509, repo: "hexpm", optional: false]}], "hexpm", "d460902b4f0a686485850cc4fd1eb7c9325a90bbf43106aac06a3b567bdc5e82"}, "libcluster": {:hex, :libcluster, "3.3.3", "a4f17721a19004cfc4467268e17cff8b1f951befe428975dd4f6f7b84d927fe0", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "7c0a2275a0bb83c07acd17dab3c3bfb4897b145106750eeccc62d302e3bdfee5"}, "libring": {:hex, :libring, "1.6.0", "d5dca4bcb1765f862ab59f175b403e356dec493f565670e0bacc4b35e109ce0d", [:mix], [], "hexpm", "5e91ece396af4bce99953d49ee0b02f698cd38326d93cd068361038167484319"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, diff --git a/test/uplink/clients/lxd/instance/manager_test.exs b/test/uplink/clients/lxd/instance/manager_test.exs index 2632bf0f..acbbdc69 100644 --- a/test/uplink/clients/lxd/instance/manager_test.exs +++ b/test/uplink/clients/lxd/instance/manager_test.exs @@ -37,7 +37,7 @@ defmodule Uplink.Clients.LXD.Instance.ManagerTest do |> Plug.Conn.resp(200, response) end) - assert [instance1, _instance2] = Manager.list("default") + assert [instance1, _instance2] = Manager.list(project: "default") assert %Instance{} = instance1 end end