Skip to content

Commit

Permalink
No more maybe_* in function names
Browse files Browse the repository at this point in the history
There is no _maybe_
  • Loading branch information
jamie-suse committed Mar 7, 2024
1 parent 99e1bd9 commit d9fca06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ defmodule Trento.Infrastructure.SoftwareUpdates.Suma.HttpExecutor do
"#{base_url}/auth/login",
payload,
[{"Content-type", "application/json"}],
maybe_provide_ssl_options(use_ca_cert)
ssl_options(use_ca_cert)
)
end

Expand All @@ -52,7 +52,7 @@ defmodule Trento.Infrastructure.SoftwareUpdates.Suma.HttpExecutor do
HTTPoison.get(
"#{base_url}/system/getId?name=#{fully_qualified_domain_name}",
[{"Content-type", "application/json"}],
hackney: [cookie: [auth]] ++ maybe_provide_ssl_options(use_ca_cert)
hackney: [cookie: [auth]] ++ ssl_options(use_ca_cert)
)
end

Expand All @@ -61,12 +61,12 @@ defmodule Trento.Infrastructure.SoftwareUpdates.Suma.HttpExecutor do
HTTPoison.get(
"#{base_url}/system/getRelevantErrata?sid=#{system_id}",
[{"Content-type", "application/json"}],
hackney: [cookie: [auth]] ++ maybe_provide_ssl_options(use_ca_cert)
hackney: [cookie: [auth]] ++ ssl_options(use_ca_cert)
)
end

defp maybe_provide_ssl_options(true),
defp ssl_options(true),
do: [ssl: [verify: :verify_peer, certfile: SumaApi.ca_cert_path()]]

defp maybe_provide_ssl_options(_), do: []
defp ssl_options(_), do: []
end
6 changes: 3 additions & 3 deletions lib/trento/infrastructure/software_updates/suma.ex
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ defmodule Trento.Infrastructure.SoftwareUpdates.Suma do
defp setup_auth(%State{} = state) do
with {:ok, %{url: url, username: username, password: password, ca_cert: ca_cert}} <-
SoftwareUpdates.get_settings(),
:ok <- maybe_write_ca_cert_file(ca_cert),
:ok <- write_ca_cert_file(ca_cert),
{:ok, auth_cookie} <- SumaApi.login(url, username, password, ca_cert != nil) do
{:ok,
%State{
Expand All @@ -129,9 +129,9 @@ defmodule Trento.Infrastructure.SoftwareUpdates.Suma do
end
end

defp maybe_write_ca_cert_file(nil), do: File.rm(SumaApi.ca_cert_path())
defp write_ca_cert_file(nil), do: File.rm(SumaApi.ca_cert_path())

defp maybe_write_ca_cert_file(ca_cert) do
defp write_ca_cert_file(ca_cert) do
SumaApi.ca_cert_path()
|> Path.dirname()
|> File.mkdir_p!()
Expand Down

0 comments on commit d9fca06

Please sign in to comment.