View Source K8s.Discovery.Driver behaviour (k8s v1.1.5)

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

@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

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)

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

List of Kubernetes APIResourceLists

examples

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

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()