View Source K8s.Discovery.Driver behaviour (k8s v2.6.1)

Driver behaviour for K8s.Discovery

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

Types

@type driver_error_t() :: {:error, atom() | 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"}}

Callbacks

Link to this callback

resources(api_version, conn)

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

List of Kubernetes APIResourceLists

Examples

iex> {:ok, conn} = K8s.Conn.from_file("test/support/kube-config.yaml")
...> 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)

View Source
@callback resources(api_version :: String.t(), conn :: K8s.Conn.t(), opts :: Keyword.t()) ::
  {:ok, [map()]} | driver_error_t()
@callback versions(conn :: K8s.Conn.t()) :: {:ok, [String.t()]} | driver_error_t()

List of Kubernetes apiVersions

Examples

iex> {:ok, conn} = K8s.Conn.from_file("test/support/kube-config.yaml")
...> K8s.Discovery.Driver.HTTP.api(conn)
{:ok, ["v1"]}
@callback versions(conn :: K8s.Conn.t(), opts :: Keyword.t()) ::
  {:ok, [String.t()]} | driver_error_t()