-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
61 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
erlang 26.0.1 | ||
elixir 1.15.0 | ||
erlang 26.0.2 | ||
elixir 1.15.2 | ||
k3d 5.4.6 | ||
kind 0.18.0 | ||
kind 0.19.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,11 +35,12 @@ defmodule K8s.Client.Runner.Wait do | |
``` | ||
""" | ||
@spec run(Operation.t(), keyword()) :: | ||
{:ok, map()} | {:error, :timeout | Error.t()} | ||
{:ok, :deleted} | {:ok, map()} | {:error, :timeout | Error.t()} | ||
|
||
def run(%Operation{conn: %Conn{} = conn} = op, opts), do: run(conn, op, opts) | ||
|
||
@spec run(Conn.t(), Operation.t(), keyword()) :: | ||
{:ok, map()} | {:error, :timeout | Error.t()} | ||
{:ok, :deleted} | {:ok, map()} | {:error, :timeout | Error.t()} | ||
def run(%Conn{} = conn, %Operation{method: :get} = op, opts) do | ||
conditions = | ||
Wait | ||
|
@@ -52,8 +53,35 @@ defmodule K8s.Client.Runner.Wait do | |
end | ||
end | ||
|
||
def run(%Conn{} = conn, %Operation{method: :delete} = op, opts) do | ||
case Base.run(conn, op) do | ||
{:ok, _} -> | ||
run( | ||
conn, | ||
struct(op, method: :get), | ||
Keyword.merge(opts, | ||
processor: &get_deleted_processor/2, | ||
find: &Function.identity/1, | ||
eval: :deleted | ||
) | ||
) | ||
|
||
error -> | ||
error | ||
end | ||
end | ||
|
||
def run(op, _, _), | ||
do: {:error, %Error{message: "Only HTTP GET operations are supported. #{inspect(op)}"}} | ||
do: | ||
{:error, | ||
%Error{message: "Only HTTP GET and DELETE operations are supported. #{inspect(op)}"}} | ||
|
||
defp get_deleted_processor(op, conn) do | ||
Check warning on line 79 in lib/k8s/client/runner/wait.ex GitHub Actions / test (v1.27.1)
|
||
case Base.run(op, conn) do | ||
{:error, %K8s.Client.APIError{reason: "NotFound"}} -> {:ok, :deleted} | ||
{:ok, _} -> {:error, :exists} | ||
end | ||
end | ||
|
||
@spec process_opts(Wait.t() | map) :: {:error, Error.t()} | {:ok, map} | ||
defp process_opts(%Wait{eval: nil}), do: {:error, %Error{message: ":eval is required"}} | ||
|
@@ -105,12 +133,12 @@ defmodule K8s.Client.Runner.Wait do | |
end | ||
|
||
@spec satisfied?(map, function | list, any) :: boolean | ||
defp satisfied?(resp = %{}, find, eval) when is_list(find) do | ||
defp satisfied?(resp, find, eval) when is_list(find) do | ||
value = get_in(resp, find) | ||
compare(value, eval) | ||
end | ||
|
||
defp satisfied?(resp = %{}, find, eval) when is_function(find) do | ||
defp satisfied?(resp, find, eval) when is_function(find) do | ||
value = find.(resp) | ||
compare(value, eval) | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters