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

Conversation

Mrjaco12
Copy link
Contributor

Why:

This change addresses the need by:

  • Grab fwup version when creating config
  • Add fwup version to config params
  • Add a spec to check that fwup version key is present

Why:

* NH needs to know the fwup version to make decisions about delta updates
* Resolves Issue nerves-hub#43

This change addresses the need by:

* Grab fwup version when creating config
* Add fwup version to config params
* Add a spec to check that fwup version key is present
@Mrjaco12
Copy link
Contributor Author

@mobileoverlord @fhunleth let me know what you guys think about this. The test is pretty naive and would fail in a testing env without fwup installed so that's a downside but the tradeoff of extracting a module and creating a mock for this didn't really seem worth it.

@fhunleth
Copy link
Contributor

IMHO, fwup should be installed everywhere, so I think we should just view that as a given. ;)

@@ -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.


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

Why:

* We don't need to prefix data unnecessarily
* We don't need to pipe simple transformations

This change addresses the need by:

* Remove nerves_fw prefix
* Don't pipe
Mrjaco12 added a commit to verypossible/nerves_hub_web that referenced this pull request Aug 31, 2020
Why:

* We want to appropriately capture fwup version from devices
* We want to match the way fwup version sent from:
  * nerves-hub/nerves_hub_link#44
  * nerves-hub/nerves_hub_link_http#6

This change addresses the need by:

* Update the matching string for fwup_version in the various functions that check conn/channel
@mobileoverlord mobileoverlord merged commit ee0e61c into nerves-hub:main Sep 1, 2020
mobileoverlord pushed a commit to nerves-hub/nerves_hub_web that referenced this pull request Sep 17, 2020
Why:

* We want to appropriately capture fwup version from devices
* We want to match the way fwup version sent from:
  * nerves-hub/nerves_hub_link#44
  * nerves-hub/nerves_hub_link_http#6

This change addresses the need by:

* Update the matching string for fwup_version in the various functions that check conn/channel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants