From b24b686f2f7023db24e589917c1cff6a02ac4977 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 20 Dec 2024 16:18:33 +1300 Subject: [PATCH] Update Elixir and Erlang versions (#1693) Elixir 1.18.0 Erlang 27.1.3 --- .tool-versions | 4 ++-- Dockerfile | 6 +++--- lib/nerves_hub/extensions.ex | 3 +-- lib/nerves_hub/fwup.ex | 14 ++++++++++++-- lib/nerves_hub_web/components/ca_helpers.ex | 4 ++-- mix.exs | 2 +- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.tool-versions b/.tool-versions index 7d8a4c3cd..36c34201d 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,4 +1,4 @@ nodejs 16.18.1 python 3.10.13 -elixir 1.17.2-otp-27 -erlang 27.0.1 +elixir 1.18.0 +erlang 27.1.3 diff --git a/Dockerfile b/Dockerfile index 9d238d216..b2ed3b642 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -ARG ELIXIR_VERSION=1.17.2 -ARG OTP_VERSION=27.0.1 -ARG DISTRO=noble-20240605 +ARG ELIXIR_VERSION=1.18.0 +ARG OTP_VERSION=27.1.3 +ARG DISTRO=noble-20241015 ARG NODE_VERSION=16.20.2 ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-ubuntu-${DISTRO}" diff --git a/lib/nerves_hub/extensions.ex b/lib/nerves_hub/extensions.ex index 74983de31..80dede2ce 100644 --- a/lib/nerves_hub/extensions.ex +++ b/lib/nerves_hub/extensions.ex @@ -42,10 +42,9 @@ defmodule NervesHub.Extensions do @supported_extensions end - @spec module(extension()) :: module() | :unsupported + @spec module(extension()) :: module() def module(:health), do: NervesHub.Extensions.Health def module(:geo), do: NervesHub.Extensions.Geo - def module(_key), do: :unsupported @spec module(extension(), Version.t()) :: module() | :unsupported def module(:health, ver) do diff --git a/lib/nerves_hub/fwup.ex b/lib/nerves_hub/fwup.ex index 1d199d6e5..7e11bcde1 100644 --- a/lib/nerves_hub/fwup.ex +++ b/lib/nerves_hub/fwup.ex @@ -29,6 +29,17 @@ defmodule NervesHub.Fwup do misc: String.t(), vcs_identifier: String.t() } + + def keys() do + blank_values = + Enum.reduce(@enforce_keys, %{}, fn key, acc -> + Map.put(acc, key, nil) + end) + + struct!(Metadata, blank_values) + |> Map.from_struct() + |> Map.keys() + end end @doc """ @@ -70,8 +81,7 @@ defmodule NervesHub.Fwup do end defp transform_to_struct(metadata) do - keys = Map.keys(Map.from_struct(Metadata)) - filtered = Map.take(metadata, keys) + filtered = Map.take(metadata, Metadata.keys()) {:ok, struct!(Metadata, filtered)} rescue _ -> {:error, :invalid_metadata} diff --git a/lib/nerves_hub_web/components/ca_helpers.ex b/lib/nerves_hub_web/components/ca_helpers.ex index d5ccab1bd..d8c6536e1 100644 --- a/lib/nerves_hub_web/components/ca_helpers.ex +++ b/lib/nerves_hub_web/components/ca_helpers.ex @@ -15,10 +15,10 @@ defmodule NervesHubWeb.Components.CAHelpers do def certificate_status(assigns) do status = cond do - assigns.not_after > DateTime.utc_now() -> + DateTime.compare(assigns.not_after, DateTime.utc_now()) == :gt -> "Expired" - assigns.not_after > DateTime.shift(DateTime.utc_now(), month: -3) -> + DateTime.compare(assigns.not_after, DateTime.shift(DateTime.utc_now(), month: -3)) == :gt -> "Expiring Soon" true -> diff --git a/mix.exs b/mix.exs index adba01f55..fb84a033e 100644 --- a/mix.exs +++ b/mix.exs @@ -12,7 +12,7 @@ defmodule NervesHub.MixProject do docs: :docs ], elixirc_paths: elixirc_paths(Mix.env()), - elixir: "~> 1.17.2", + elixir: "~> 1.18.0", releases: [ nerves_hub: [ steps: [:assemble],