Skip to content

Commit

Permalink
appease the dialyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
coryodaniel committed Dec 7, 2019
1 parent 14151fb commit b62bb68
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions lib/k8s/conn.ex
Expand Up @@ -27,7 +27,7 @@ defmodule K8s.Conn do
discovery_opts: nil

@type t :: %__MODULE__{
cluster_name: String.t() | nil,
cluster_name: atom(),
user_name: String.t() | nil,
url: String.t(),
insecure_skip_tls_verify: boolean(),
Expand Down Expand Up @@ -157,7 +157,9 @@ defmodule K8s.Conn do
cluster_name: cluster_name,
url: "https://#{host}:#{port}",
ca_cert: PKI.cert_from_pem(cert_path),
auth: %K8s.Conn.Auth.Token{token: File.read!(token_path)}
auth: %K8s.Conn.Auth.Token{token: File.read!(token_path)},
discovery_driver: K8s.Discovery.default_driver(),
discovery_opts: K8s.Discovery.default_opts()
}
end

Expand Down
12 changes: 7 additions & 5 deletions lib/k8s/discovery/resource_finder.ex
Expand Up @@ -5,6 +5,8 @@ defmodule K8s.Discovery.ResourceFinder do

alias K8s.Discovery.ResourceNaming

@type error_t :: {:error, :unsupported_resource, binary}

@doc """
Get the REST resource name for a kubernetes `Kind`.
Expand All @@ -13,9 +15,9 @@ defmodule K8s.Discovery.ResourceFinder do
Also accepts REST resource name in the event they are provided, as it may be known in the event of subresources.
"""
@spec resource_name_for_kind(atom(), binary(), binary()) ::
@spec resource_name_for_kind(K8s.Conn.t(), binary(), binary()) ::
{:ok, binary()}
| {:error, :unsupported_resource, binary()}
| error_t
def resource_name_for_kind(conn, api_version, name_or_kind) do
case find_resource(conn, api_version, name_or_kind) do
{:ok, %{"name" => name}} ->
Expand All @@ -29,9 +31,9 @@ defmodule K8s.Discovery.ResourceFinder do
@doc """
Finds a resource definition by api version and (name or kind).
"""
@spec find_resource(atom(), binary(), atom() | binary()) ::
@spec find_resource(K8s.Conn.t(), binary(), atom() | binary()) ::
{:ok, map}
| {:error, :unsupported_resource, binary()}
| error_t
def find_resource(conn, api_version, name_or_kind) do
with {:ok, resources} <- conn.discovery_driver.resources(api_version, conn) do
find_resource_by_name(resources, name_or_kind)
Expand All @@ -40,7 +42,7 @@ defmodule K8s.Discovery.ResourceFinder do

@doc false
@spec find_resource_by_name(list(map), atom() | binary()) ::
{:ok, map} | {:error, atom() | binary()}
{:ok, map} | error_t
def find_resource_by_name(resources, name_or_kind) do
resource = Enum.find(resources, &ResourceNaming.matches?(&1, name_or_kind))

Expand Down

0 comments on commit b62bb68

Please sign in to comment.