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

Report fwup version to nerves hub #44

Merged
Merged
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion lib/nerves_hub_link/configurator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ defmodule NervesHubLink.Configurator do
|> Keyword.put_new(:verify, :verify_peer)
|> Keyword.put_new(:server_name_indication, to_charlist(base.device_api_sni))

%{base | params: Nerves.Runtime.KV.get_all_active(), socket: socket, ssl: ssl}
params = Map.put(Nerves.Runtime.KV.get_all_active(), "nerves_fw_fwup_version", fwup_version())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
params = Map.put(Nerves.Runtime.KV.get_all_active(), "nerves_fw_fwup_version", fwup_version())
params = Map.put(Nerves.Runtime.KV.get_all_active(), "fwup_version", fwup_version())

I'm not sure that the nerves_fw_ prefix matters here. My preference would be to drop it, but I don't feel strongly about it.


%{base | params: params, socket: socket, ssl: ssl}
end

defp do_build(configurator) when is_atom(configurator) do
Expand All @@ -71,4 +73,9 @@ defmodule NervesHubLink.Configurator do
Default
end
end

defp fwup_version do
{version_string, 0} = System.cmd("fwup", ["--version"])
version_string |> String.trim()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version_string |> String.trim()
String.trim(version_string)

piping for a short call might be unnecessary

end
end
5 changes: 5 additions & 0 deletions test/nerves_hub_link/configurator_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ defmodule NervesHubLink.ConfiguratorTest do
config = NervesHubLink.Configurator.build()
assert config.socket[:transport_opts][:socket_opts] == ssl
end

test "fwup_version is included in params" do
config = NervesHubLink.Configurator.build()
assert Map.has_key?(config.params, "nerves_fw_fwup_version")
end
end