Skip to content

Commit

Permalink
Refactor function
Browse files Browse the repository at this point in the history
  • Loading branch information
gordalina committed Jul 20, 2020
1 parent 27e2d82 commit 51f95cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 4 additions & 6 deletions lib/hush_provider.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ defmodule Hush.Provider.GcpSecretManager do
end

defp project(config \\ nil) do
cond do
config == nil ->
Application.get_env(:hush_gcp_secret_manager, :project_id, nil)

true ->
config[:hush_gcp_secret_manager] |> Keyword.get(:project_id, nil)
if config == nil do
Application.get_env(:hush_gcp_secret_manager, :project_id, nil)
else
config[:hush_gcp_secret_manager] |> Keyword.get(:project_id, nil)
end
end

Expand Down
4 changes: 3 additions & 1 deletion test/hush_provider_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ defmodule Hush.Provider.GcpSecretManagerTest do

test "with config" do
assert nil == Application.get_env(:hush_gcp_secret_manager, :project_id)
assert :ok == GcpSecretManager.load([{:hush_gcp_secret_manager, [project_id: "project_id"]}])

assert :ok ==
GcpSecretManager.load([{:hush_gcp_secret_manager, [project_id: "project_id"]}])
end
end

Expand Down

0 comments on commit 51f95cf

Please sign in to comment.