Skip to content

Commit

Permalink
Format with styler
Browse files Browse the repository at this point in the history
  • Loading branch information
reachfh committed Dec 11, 2024
1 parent 713f76d commit 9d9e75b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
13 changes: 9 additions & 4 deletions lib/kubernetes_health_check/plug.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
defmodule KubernetesHealthCheck.Plug do
@moduledoc false
if Code.ensure_loaded?(Plug) do
@moduledoc """

Check warning on line 4 in lib/kubernetes_health_check/plug.ex

View workflow job for this annotation

GitHub Actions / Run tests (24, 1.13.4)

redefining @moduledoc attribute previously set at line 2

Check warning on line 4 in lib/kubernetes_health_check/plug.ex

View workflow job for this annotation

GitHub Actions / Run tests (24, 1.14.5)

redefining @moduledoc attribute previously set at line 2

Check warning on line 4 in lib/kubernetes_health_check/plug.ex

View workflow job for this annotation

GitHub Actions / Run tests (24, 1.15.7)

redefining @moduledoc attribute previously set at line 2

Check warning on line 4 in lib/kubernetes_health_check/plug.ex

View workflow job for this annotation

GitHub Actions / Run tests (25, 1.13.4)

redefining @moduledoc attribute previously set at line 2

Check warning on line 4 in lib/kubernetes_health_check/plug.ex

View workflow job for this annotation

GitHub Actions / Run tests (25, 1.14.5)

redefining @moduledoc attribute previously set at line 2

Check warning on line 4 in lib/kubernetes_health_check/plug.ex

View workflow job for this annotation

GitHub Actions / Run tests (25, 1.15.7)

redefining @moduledoc attribute previously set at line 2

Check warning on line 4 in lib/kubernetes_health_check/plug.ex

View workflow job for this annotation

GitHub Actions / Run tests (26, 1.15.7)

redefining @moduledoc attribute previously set at line 2
Plug to return health check results.
Expand Down Expand Up @@ -76,7 +77,8 @@ defmodule KubernetesHealthCheck.Plug do
|> halt()

{:error, {status_code, reason}} when is_integer(status_code) ->
send_resp(conn, status_code, inspect(reason))
conn
|> send_resp(status_code, inspect(reason))
|> halt()

{:error, reason} ->
Expand All @@ -95,7 +97,8 @@ defmodule KubernetesHealthCheck.Plug do
|> halt()

{:error, {status_code, reason}} when is_integer(status_code) ->
send_resp(conn, status_code, inspect(reason))
conn
|> send_resp(status_code, inspect(reason))
|> halt()

{:error, reason} ->
Expand All @@ -114,7 +117,8 @@ defmodule KubernetesHealthCheck.Plug do
|> halt()

{:error, {status_code, reason}} when is_integer(status_code) ->
send_resp(conn, status_code, inspect(reason))
conn
|> send_resp(status_code, inspect(reason))
|> halt()

{:error, reason} ->
Expand All @@ -133,7 +137,8 @@ defmodule KubernetesHealthCheck.Plug do
|> halt()

{:error, {status_code, reason}} when is_integer(status_code) ->
send_resp(conn, status_code, inspect(reason))
conn
|> send_resp(status_code, inspect(reason))
|> halt()

{:error, reason} ->
Expand Down
7 changes: 3 additions & 4 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ defmodule KubernetesHealthCheck.MixProject do
{:ex_doc, "~> 0.35.0", only: :dev, runtime: false},
{:excoveralls, "~> 0.18.0", only: [:dev, :test], runtime: false},
{:junit_formatter, "~> 3.3", only: [:dev, :test], runtime: false},
{:mix_audit, "~> 2.0", only: [:dev, :test], runtime: false}
# {:styler, "~> 0.10.0", only: [:dev, :test], runtime: false},
{:mix_audit, "~> 2.0", only: [:dev, :test], runtime: false},
{:styler, "~> 0.10.0", only: [:dev, :test], runtime: false}
]
end

Expand All @@ -73,8 +73,7 @@ defmodule KubernetesHealthCheck.MixProject do
licenses: ["Apache-2.0"],
links: %{
"GitHub" => @github,
"Changelog" =>
"#{@github}/blob/#{@version}/CHANGELOG.md##{String.replace(@version, ".", "")}"
"Changelog" => "#{@github}/blob/#{@version}/CHANGELOG.md##{String.replace(@version, ".", "")}"
}
]
end
Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"plug_cowboy": {:hex, :plug_cowboy, "2.7.2", "fdadb973799ae691bf9ecad99125b16625b1c6039999da5fe544d99218e662e4", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "245d8a11ee2306094840c000e8816f0cbed69a23fc0ac2bcf8d7835ae019bb2f"},
"plug_crypto": {:hex, :plug_crypto, "2.1.0", "f44309c2b06d249c27c8d3f65cfe08158ade08418cf540fd4f72d4d6863abb7b", [:mix], [], "hexpm", "131216a4b030b8f8ce0f26038bc4421ae60e4bb95c5cf5395e1421437824c4fa"},
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
"styler": {:hex, :styler, "0.10.5", "89b17a3ddebbde939f2e2929638275c10aa4c2b01d8000925b6c2d1933555916", [:mix], [], "hexpm", "567a6876b3ebc5dba5c7f9a9a2a47f294a6f51c46939955efae4325f0137ce48"},
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
"yamerl": {:hex, :yamerl, "0.10.0", "4ff81fee2f1f6a46f1700c0d880b24d193ddb74bd14ef42cb0bcf46e81ef2f8e", [:rebar3], [], "hexpm", "346adb2963f1051dc837a2364e4acf6eb7d80097c0f53cbdc3046ec8ec4b4e6e"},
"yaml_elixir": {:hex, :yaml_elixir, "2.11.0", "9e9ccd134e861c66b84825a3542a1c22ba33f338d82c07282f4f1f52d847bd50", [:mix], [{:yamerl, "~> 0.10", [hex: :yamerl, repo: "hexpm", optional: false]}], "hexpm", "53cc28357ee7eb952344995787f4bb8cc3cecbf189652236e9b163e8ce1bc242"},
Expand Down
28 changes: 18 additions & 10 deletions test/kubernetes_health_check/plug_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ defmodule KubernetesHealthCheck.PlugTest do
use Plug.Test

defmodule HealthErrorMessage do
@moduledoc false
def basic do
{:error, :basic}
end
Expand All @@ -21,6 +22,7 @@ defmodule KubernetesHealthCheck.PlugTest do
end

defmodule HealthErrorCode do
@moduledoc false
def basic do
{:error, {500, :basic}}
end
Expand All @@ -39,63 +41,69 @@ defmodule KubernetesHealthCheck.PlugTest do
end

defmodule DefaultsPlug do
@moduledoc false
use Plug.Builder

plug KubernetesHealthCheck.Plug
plug :passthrough
plug(KubernetesHealthCheck.Plug)
plug(:passthrough)

defp passthrough(conn, _) do
Plug.Conn.send_resp(conn, 200, "Passthrough")
end
end

defmodule PathPlug do
@moduledoc false
use Plug.Builder

plug KubernetesHealthCheck.Plug, base_path: "/foo"
plug(KubernetesHealthCheck.Plug, base_path: "/foo")

plug :passthrough
plug(:passthrough)

defp passthrough(conn, _) do
Plug.Conn.send_resp(conn, 200, "Passthrough")
end
end

defmodule CustomPathPlug do
@moduledoc false
use Plug.Builder

plug KubernetesHealthCheck.Plug,
plug(KubernetesHealthCheck.Plug,
mod: HealthErrorMessage,
base_path: "/health",
startup_path: "/startup",
liveness_path: "/liveness",
readiness_path: "/readiness"
)

plug :passthrough
plug(:passthrough)

defp passthrough(conn, _) do
Plug.Conn.send_resp(conn, 200, "Passthrough")
end
end

defmodule ErrorMessagePlug do
@moduledoc false
use Plug.Builder

plug KubernetesHealthCheck.Plug, mod: HealthErrorMessage
plug(KubernetesHealthCheck.Plug, mod: HealthErrorMessage)

plug :passthrough
plug(:passthrough)

defp passthrough(conn, _) do
Plug.Conn.send_resp(conn, 200, "Passthrough")
end
end

defmodule ErrorCodePlug do
@moduledoc false
use Plug.Builder

plug KubernetesHealthCheck.Plug, mod: HealthErrorCode
plug(KubernetesHealthCheck.Plug, mod: HealthErrorCode)

plug :passthrough
plug(:passthrough)

defp passthrough(conn, _) do
Plug.Conn.send_resp(conn, 200, "Passthrough")
Expand Down

0 comments on commit 9d9e75b

Please sign in to comment.