changed
CHANGELOG.md
|
@@ -1,5 +1,14 @@
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+ ## unreleased
|
4
|
+
|
5
|
+ ## v2.0.1
|
6
|
+
|
7
|
+ * Updated
|
8
|
+ * You can now use a single URI for defining the NervesHub instance you are connecting.
|
9
|
+ * `CAStore` is now an optional dep. If you have included `CAStore` in your Nerves project it will be used, otherwise `:public_key` will be the fallback.
|
10
|
+ * Firmware uploads will default to using HTTP1 as HTTP2 streaming issues exist with the `Tesla` usage of `Mint`
|
11
|
+
|
3
12
|
## v2.0.0
|
4
13
|
|
5
14
|
Update for compatibility with NervesHub 2.0
|
changed
README.md
|
@@ -55,16 +55,19 @@ automation. The following variables are available:
|
55
55
|
* `NERVES_HUB_FW_PRIVATE_KEY` - Fwup signing private key
|
56
56
|
* `NERVES_HUB_FW_PUBLIC_KEY` - Fwup signing public key
|
57
57
|
* `NERVES_HUB_HOME` - NervesHub CLI data directory (defaults to `~/.nerves-hub`)
|
58
|
- * `NERVES_HUB_HOST` - NervesHub API endpoint IP address or hostname (defaults to `api.nerves-hub.org`)
|
59
|
- * `NERVES_HUB_PORT` - NervesHub API endpoint port (defaults to 443)
|
58
|
+ * `NERVES_HUB_URI` - NervesHub API host, port, scheme (all in one)
|
59
|
+ * `NERVES_HUB_HOST` - NervesHub API endpoint IP address or hostname
|
60
|
+ * `NERVES_HUB_PORT` - NervesHub API endpoint port
|
61
|
+ * `NERVES_HUB_SCHEME` - NervesHub API endpoint scheme
|
60
62
|
* `NERVES_HUB_NON_INTERACTIVE` - Force all yes/no user interaction to be yes
|
61
63
|
|
62
64
|
For more information on using the CLI, see the
|
63
65
|
[`nerves_hub_link`](https://github.com/nerves-hub/nerves_hub_link) documentation.
|
64
66
|
|
65
|
- ## Connecting to other environments
|
67
|
+ ## Connecting to NervesHub
|
66
68
|
|
67
|
- NervesHubCLI can be directed to target other environments beside the public
|
68
|
- NervesHub instance. See the
|
69
|
+ NervesHubCLI must be configured to connect to your chosen NervesHub host.
|
70
|
+
|
71
|
+ See the
|
69
72
|
[documentation](https://docs.nerves-hub.org/nerves-hub/setup/connecting-other-envs)
|
70
73
|
for example config values to do this.
|
changed
hex_metadata.config
|
@@ -1,7 +1,7 @@
|
1
1
|
{<<"links">>,
|
2
2
|
[{<<"GitHub">>,<<"https://github.com/nerves-hub/nerves_hub_cli">>}]}.
|
3
3
|
{<<"name">>,<<"nerves_hub_cli">>}.
|
4
|
- {<<"version">>,<<"2.0.0">>}.
|
4
|
+ {<<"version">>,<<"2.0.1">>}.
|
5
5
|
{<<"description">>,<<"NervesHub Mix command-line interface">>}.
|
6
6
|
{<<"elixir">>,<<"~> 1.6">>}.
|
7
7
|
{<<"app">>,<<"nerves_hub_cli">>}.
|
|
@@ -14,7 +14,7 @@
|
14
14
|
{<<"repository">>,<<"hexpm">>}],
|
15
15
|
[{<<"name">>,<<"castore">>},
|
16
16
|
{<<"app">>,<<"castore">>},
|
17
|
- {<<"optional">>,false},
|
17
|
+ {<<"optional">>,true},
|
18
18
|
{<<"requirement">>,<<"~> 0.1 or ~> 1.0">>},
|
19
19
|
{<<"repository">>,<<"hexpm">>}],
|
20
20
|
[{<<"name">>,<<"jason">>},
|
|
@@ -73,7 +73,6 @@
|
73
73
|
<<"lib/nerves_hub_cli/api/product_user.ex">>,
|
74
74
|
<<"lib/nerves_hub_cli/api/device_certificate.ex">>,
|
75
75
|
<<"lib/nerves_hub_cli/api/product.ex">>,<<"lib/nerves_hub_cli/api.ex">>,
|
76
|
- <<"lib/nerves_hub_cli/application.ex">>,<<"lib/nerves_hub_cli/crypto.ex">>,
|
77
|
- <<".formatter.exs">>,<<"mix.exs">>,<<"README.md">>,<<"LICENSE">>,
|
78
|
- <<"CHANGELOG.md">>]}.
|
76
|
+ <<"lib/nerves_hub_cli/crypto.ex">>,<<".formatter.exs">>,<<"mix.exs">>,
|
77
|
+ <<"README.md">>,<<"LICENSE">>,<<"CHANGELOG.md">>]}.
|
79
78
|
{<<"build_tools">>,[<<"mix">>]}.
|
changed
lib/nerves_hub_cli/api.ex
|
@@ -19,11 +19,18 @@ defmodule NervesHubCLI.API do
|
19
19
|
@spec endpoint() :: String.t()
|
20
20
|
def endpoint() do
|
21
21
|
opts = Application.get_all_env(:nerves_hub_cli)
|
22
|
- scheme = System.get_env("NERVES_HUB_SCHEME") || opts[:scheme]
|
23
|
- host = System.get_env("NERVES_HUB_HOST") || opts[:host]
|
24
|
- port = get_env_as_integer("NERVES_HUB_PORT") || opts[:port]
|
25
22
|
|
26
|
- %URI{scheme: scheme, host: host, port: port, path: "/api"} |> URI.to_string()
|
23
|
+ if server = System.get_env("NERVES_HUB_URI") || opts[:uri] do
|
24
|
+ URI.parse(server)
|
25
|
+ |> URI.append_path("/api")
|
26
|
+ |> URI.to_string()
|
27
|
+ else
|
28
|
+ scheme = System.get_env("NERVES_HUB_SCHEME") || opts[:scheme]
|
29
|
+ host = System.get_env("NERVES_HUB_HOST") || opts[:host]
|
30
|
+ port = get_env_as_integer("NERVES_HUB_PORT") || opts[:port]
|
31
|
+
|
32
|
+ %URI{scheme: scheme, host: host, port: port, path: "/api"} |> URI.to_string()
|
33
|
+ end
|
27
34
|
end
|
28
35
|
|
29
36
|
def request(:get, path, params) when is_map(params) do
|
|
@@ -105,7 +112,9 @@ defmodule NervesHubCLI.API do
|
105
112
|
|
106
113
|
[
|
107
114
|
ssl_options: ssl_options,
|
108
|
- recv_timeout: 60_000
|
115
|
+ recv_timeout: 60_000,
|
116
|
+ protocols: [:http1],
|
117
|
+ timeout: 300_000
|
109
118
|
]
|
110
119
|
end
|
111
120
|
|
|
@@ -148,17 +157,14 @@ defmodule NervesHubCLI.API do
|
148
157
|
is_atom(ca_store) and !is_nil(ca_store) ->
|
149
158
|
ca_store.ca_certs()
|
150
159
|
|
160
|
+ Code.ensure_loaded?(CAStore) ->
|
161
|
+ CAStore.file_path()
|
162
|
+ |> File.read!()
|
163
|
+ |> X509.from_pem()
|
164
|
+ |> Enum.map(&X509.Certificate.to_der/1)
|
165
|
+
|
151
166
|
true ->
|
152
|
- scheme = Application.get_env(:nerves_hub_cli, :scheme)
|
153
|
- host = Application.get_env(:nerves_hub_cli, :host)
|
154
|
-
|
155
|
- unless is_nil(ca_store) && scheme == "http" && host == "localhost" do
|
156
|
- Logger.warning(
|
157
|
- "[NervesHubLink] No CA store or :cacerts have been specified. Request will fail"
|
158
|
- )
|
159
|
- end
|
160
|
-
|
161
|
- []
|
167
|
+ :public_key.cacerts_get()
|
162
168
|
end
|
163
169
|
end
|
removed
lib/nerves_hub_cli/application.ex
|
@@ -1,21 +0,0 @@
|
1
|
- defmodule NervesHubCLI.Application do
|
2
|
- # See https://hexdocs.pm/elixir/Application.html
|
3
|
- # for more information on OTP Applications
|
4
|
- @moduledoc false
|
5
|
-
|
6
|
- use Application
|
7
|
-
|
8
|
- def start(_type, _args) do
|
9
|
- NervesHubCLI.User.init()
|
10
|
- # List all child processes to be supervised
|
11
|
- children = [
|
12
|
- # Starts a worker by calling: NervesHubCLI.Worker.start_link(arg)
|
13
|
- # {NervesHubCLI.Worker, arg},
|
14
|
- ]
|
15
|
-
|
16
|
- # See https://hexdocs.pm/elixir/Supervisor.html
|
17
|
- # for other strategies and supported options
|
18
|
- opts = [strategy: :one_for_one, name: NervesHubCLI.Supervisor]
|
19
|
- Supervisor.start_link(children, opts)
|
20
|
- end
|
21
|
- end
|
changed
lib/nerves_hub_cli/config.ex
|
@@ -28,14 +28,14 @@ defmodule NervesHubCLI.Config do
|
28
28
|
end
|
29
29
|
|
30
30
|
defp write(config) do
|
31
|
+ unless File.dir?(NervesHubCLI.home_dir()) do
|
32
|
+ File.mkdir_p!(NervesHubCLI.home_dir())
|
33
|
+ end
|
34
|
+
|
31
35
|
File.write(file(), :erlang.term_to_binary(config))
|
32
36
|
end
|
33
37
|
|
34
38
|
defp file do
|
35
|
- Path.join(data_dir(), @config)
|
36
|
- end
|
37
|
-
|
38
|
- def data_dir() do
|
39
|
- NervesHubCLI.home_dir()
|
39
|
+ Path.join(NervesHubCLI.home_dir(), @config)
|
40
40
|
end
|
41
41
|
end
|
changed
lib/nerves_hub_cli/user.ex
|
@@ -1,18 +1,7 @@
|
1
1
|
defmodule NervesHubCLI.User do
|
2
|
- @spec init :: :ok
|
3
|
- def init() do
|
4
|
- File.mkdir_p!(data_dir())
|
5
|
-
|
6
|
- :ok
|
7
|
- end
|
8
|
-
|
9
2
|
@spec deauth() :: :ok
|
10
3
|
def deauth() do
|
11
4
|
_ = NervesHubCLI.Config.delete(:token)
|
12
5
|
:ok
|
13
6
|
end
|
14
|
-
|
15
|
- defp data_dir() do
|
16
|
- Path.join(NervesHubCLI.home_dir(), "user_data")
|
17
|
- end
|
18
7
|
end
|
changed
mix.exs
|
@@ -1,7 +1,7 @@
|
1
1
|
defmodule NervesHubCLI.MixProject do
|
2
2
|
use Mix.Project
|
3
3
|
|
4
|
- @version "2.0.0"
|
4
|
+ @version "2.0.1"
|
5
5
|
@source_url "https://github.com/nerves-hub/nerves_hub_cli"
|
6
6
|
|
7
7
|
def project do
|
|
@@ -23,12 +23,6 @@ defmodule NervesHubCLI.MixProject do
|
23
23
|
]
|
24
24
|
end
|
25
25
|
|
26
|
- def application do
|
27
|
- [
|
28
|
- mod: {NervesHubCLI.Application, []}
|
29
|
- ]
|
30
|
- end
|
31
|
-
|
32
26
|
defp description do
|
33
27
|
"NervesHub Mix command-line interface "
|
34
28
|
end
|
|
@@ -44,7 +38,7 @@ defmodule NervesHubCLI.MixProject do
|
44
38
|
[
|
45
39
|
# Avoid broken pbcs 0.1.3 version
|
46
40
|
{:pbcs, "== 0.1.2 or ~> 0.1.4"},
|
47
|
- {:castore, "~> 0.1 or ~> 1.0"},
|
41
|
+ {:castore, "~> 0.1 or ~> 1.0", optional: true},
|
48
42
|
{:dialyxir, "~> 1.2", only: [:dev, :test], runtime: false},
|
49
43
|
{:ex_doc, "~> 0.23", only: [:docs], runtime: false},
|
50
44
|
{:jason, "~> 1.0"},
|