Skip to content

Commit

Permalink
ensure_tls_config fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mruoss committed Apr 1, 2023
1 parent 13617c6 commit eeaf6d4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/bonny/admission_control.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ defmodule Bonny.AdmissionControl do
{:admission_config, get_admission_config(conn, operator_name)},
{:cert_bundle, {:ok, cert_bundle}} <-
{:cert_bundle, get_or_create_cert_bundle(conn, operator_name)} do
encoded_ca = Base.encode64(cert_bundle["ca"])

admission_configurations
|> Enum.reject(fn config ->
Enum.all?(
List.wrap(config["webhooks"]),
&(&1["clientConfig"]["caBundle"] == cert_bundle["ca"])
&(&1["clientConfig"]["caBundle"] == encoded_ca)
)
end)
|> Enum.map(fn config ->
put_in(
config,
["webhooks", Access.all(), ["clientConfig"]["caBundle"]],
cert_bundle["ca"]
["webhooks", Access.all(), "clientConfig", "caBundle"],
encoded_ca
)
end)
|> Enum.each(&apply_admission_config(conn, &1))
Expand Down Expand Up @@ -199,9 +201,8 @@ defmodule Bonny.AdmissionControl do
defp apply_admission_config(conn, admission_config) do
result =
admission_config
|> K8s.Client.apply()
|> K8s.Client.put_conn(conn)
|> K8s.Client.run()
|> Bonny.Resource.drop_managed_fields()
|> Bonny.Resource.apply(conn, [])

case result do
{:ok, _} -> :ok
Expand Down

0 comments on commit eeaf6d4

Please sign in to comment.