k8s v0.5.2 K8s.Discovery.Driver behaviour

Driver behaviour for K8s.Discovery

Link to this section Summary

Types

Errors returned by adapters should return an error tuple with an atom() describing the error or alternatively an "error" struct with more details.

Callbacks

List of Kubernetes APIResourceLists

List of Kubernetes apiVersions

Link to this section Types

Link to this type

driver_error_t()

driver_error_t() :: {:error, atom()} | {:error, struct()}

Errors returned by adapters should return an error tuple with an atom() describing the error or alternatively an "error" struct with more details.

Examples

{:error, :file_not_found}
{:error, %K8s.Discovery.Driver.MyDriver.FileNotFoundError{config: "path-to-file"}}

Link to this section Callbacks

Link to this callback

resources(api_version, conn)

resources(api_version :: String.t(), conn :: K8s.Conn.t()) ::
  {:ok, [map()]} | driver_error_t()

List of Kubernetes APIResourceLists

Examples

iex> {:ok, conn} = K8s.Conn.lookup(:test)
...> K8s.Discovery.Driver.HTTP.resources("autoscaling/v1", conn)
{:ok, [
         %{
           "kind" => "DaemonSet",
           "name" => "daemonsets"
         },
         %{
           "kind" => "Deployment",
           "name" => "deployments"
         },
         %{
           "kind" => "Deployment",
           "name" => "deployments/status"
         }
       ]}
Link to this callback

resources(api_version, conn, opts)

resources(api_version :: String.t(), conn :: K8s.Conn.t(), opts :: Keyword.t()) ::
  {:ok, [map()]} | driver_error_t()
Link to this callback

versions(conn)

versions(conn :: K8s.Conn.t()) :: {:ok, [String.t()]} | driver_error_t()

List of Kubernetes apiVersions

Examples

iex> {:ok, conn} = K8s.Conn.lookup(:test)
...> K8s.Discovery.Driver.HTTP.api(conn)
{:ok, ["v1"]}
Link to this callback

versions(conn, opts)

versions(conn :: K8s.Conn.t(), opts :: Keyword.t()) ::
  {:ok, [String.t()]} | driver_error_t()