Skip to content

Commit

Permalink
consistent API for K8s.Client.patch/N
Browse files Browse the repository at this point in the history
  • Loading branch information
mruoss committed Feb 25, 2023
1 parent 7d2c744 commit b5cb571
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/k8s/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,15 @@ defmodule K8s.Client do
}
"""
@spec patch(map()) :: Operation.t()
def patch(%{} = resource), do: Operation.build(:patch, resource, patch_type: :merge)
def patch(%{} = resource),
do: Operation.build(:patch, resource, patch_type: :merge)

@spec patch(map(), patch_type_or_resource :: atom() | map()) :: Operation.t()
def patch(%{} = resource, patch_type) when is_atom(patch_type),
do: Operation.build(:patch, resource, patch_type: patch_type)

def patch(%{} = resource, subresource) when is_map(resource),
do: patch(resource, subresource, :merge)

@doc """
Returns a `PATCH` operation to patch the given subresource given a resource's details and a subresource map.
Expand All @@ -476,7 +484,7 @@ defmodule K8s.Client do
"metadata" => %{"namespace" => ns, "name" => name}
},
%{"kind" => subkind} = subresource,
patch_type \\ :merge
patch_type
) do
Operation.build(
:patch,
Expand Down

0 comments on commit b5cb571

Please sign in to comment.