Adify v0.1.0 Adify.Tool.InstallationStrategy.Workflow

Represents a list of pre, post and main command of a set of commands for an installation_strategy

Link to this section Summary

Functions

Runs the workflow starting at pre, main and lastly post

Link to this section Types

Link to this type

t()
t() :: %Adify.Tool.InstallationStrategy.Workflow{
  main: term(),
  post: term(),
  pre: term()
}

Link to this section Functions

Link to this function

changeset(struct, params)

Link to this function

run(workflow)
run(Adify.Tool.InstallationStrategy.Workflow.t()) ::
  {:ok, term()} | {:error, term()}

Runs the workflow starting at pre, main and lastly post

Examples

# When pre, main and post are all success
iex> pre = %Adify.Tool.InstallationStrategy.Workflow.Op{
...>   command: "echo hi",
...>   success: true,
...>   expected: ".*"
...> }
iex> workflow = %Adify.Tool.InstallationStrategy.Workflow{
...>   pre: pre,
...>   main: pre,
...>   post: pre
...> }
iex> Adify.Tool.InstallationStrategy.Workflow.run(workflow)
{:ok, "Running Pre:\nhi\n\nRunning Main:\nhi\n\nRunning Post:\nhi\n\n"}

# When pre is a failure
iex> pre = %Adify.Tool.InstallationStrategy.Workflow.Op{
...>   command: "echo hi",
...>   success: false,
...>   expected: ".*"
...> }
iex> workflow = %Adify.Tool.InstallationStrategy.Workflow{
...>   pre: pre,
...>   main: pre,
...>   post: pre
...> }
iex> Adify.Tool.InstallationStrategy.Workflow.run(workflow)
{:error, "Running Pre:\nhi\n\n"}

# When main is a failure
iex> pre = %Adify.Tool.InstallationStrategy.Workflow.Op{
...>   command: "echo hi",
...>   success: true,
...>   expected: ".*"
...> }
iex> main = %Adify.Tool.InstallationStrategy.Workflow.Op{
...>   command: "echo hi",
...>   success: false,
...>   expected: ".*"
...> }
iex> workflow = %Adify.Tool.InstallationStrategy.Workflow{
...>   pre: pre,
...>   main: main,
...>   post: pre
...> }
iex> Adify.Tool.InstallationStrategy.Workflow.run(workflow)
{:error, "Running Pre:\nhi\n\nRunning Main:\nhi\n\n"}

# When post is a failure
iex> pre = %Adify.Tool.InstallationStrategy.Workflow.Op{
...>   command: "echo hi",
...>   success: true,
...>   expected: ".*"
...> }
iex> post = %Adify.Tool.InstallationStrategy.Workflow.Op{
...>   command: "echo hi",
...>   success: false,
...>   expected: ".*"
...> }
iex> workflow = %Adify.Tool.InstallationStrategy.Workflow{
...>   pre: pre,
...>   main: pre,
...>   post: post
...> }
iex> Adify.Tool.InstallationStrategy.Workflow.run(workflow)
{:error, "Running Pre:\nhi\n\nRunning Main:\nhi\n\nRunning Post:\nhi\n\n"}