Skip to content

Commit

Permalink
Merge pull request #991 from eddbbt/keygen_on_dev_tool_up
Browse files Browse the repository at this point in the history
Run docker-compose-initializer on dev tool up command
  • Loading branch information
Annopaolo authored Sep 12, 2024
2 parents bbd88ce + 5ec9357 commit 89ba4fb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tools/astarte_dev_tool/lib/commands/system/up.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@ defmodule AstarteDevTool.Commands.System.Up do
alias AstarteDevTool.Constants.System, as: Constants

def exec(path) do
case System.cmd(
Constants.command(),
Constants.command_up_args(),
Constants.base_opts() ++ [cd: path]
) do
{_result, 0} -> :ok
with {_result, 0} <-
System.cmd(
Constants.command(),
Constants.command_initialize_keys(),
Constants.base_opts() ++ [cd: path]
),
{_result, 0} <-
System.cmd(
Constants.command(),
Constants.command_up_args(),
Constants.base_opts() ++ [cd: path]
) do
:ok
else
{:process, _} -> {:error, "The system is already running"}
{result, exit_code} -> {:error, "Cannot exec system.up: #{result}, #{exit_code}"}
end
Expand Down
3 changes: 3 additions & 0 deletions tools/astarte_dev_tool/lib/constants/system.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ defmodule AstarteDevTool.Constants.System do
def command_version_args,
do: ~w(version --format '{{.Client.Version}}')

def command_initialize_keys,
do: ~w(run -v ./compose:/compose astarte/docker-compose-initializer:snapshot)

def base_opts, do: [stderr_to_stdout: true, into: IO.stream(:stdio, :line)]
end

0 comments on commit 89ba4fb

Please sign in to comment.