# `Bonny.Operator`
[🔗](https://github.com/coryodaniel/bonny/blob/v1.5.0/lib/bonny/operator.ex#L1)

Defines a Bonny operator.

The operator defines custom resources, watch queries and their
controllers and serves as the entry point to the watching and handling of
processes.

Overall, an operator has the following responsibilities:

* to provide a wrapper for starting and stopping the
  operator as part of a supervision tree

* To define the resources to be watched together with the
  controllers which handle action events on those resources.

* to define an initial pluggable pipeline for all action events
  to pass through

* To define any custom resources ending up in the manifest
  generated by `mix bonny.gen.manifest`

## Operators

An operator is defined with the help of `Bonyy.Operator`. The step
`:delegate_to_controller` has do be part of the pipeline. It is the step that
calls the handling controller for a given action event:

    defmodule MyOperatorApp.Operator do
      use Bonny.Operator, default_watching_namespace: "default"

      # step ...
      step :delegate_to_controller
      # step ...

      def controllers(watching_namespace, _opts) do
        [
          %{
            query: K8s.Client.watch("my-controller.io", "MyCustomResource", namespace: nil)
            controller: MyOperator.Controller.MyCustomResourceController
          }
        ]
      end

    end

# `controller_spec`

```elixir
@type controller_spec() :: %{
  optional(:controller) =&gt; module() | {module(), keyword()},
  query: K8s.Operation.t()
}
```

# `controllers`

```elixir
@callback controllers(binary(), Keyword.t()) :: [controller_spec()]
```

# `crds`

```elixir
@callback crds() :: [Bonny.API.CRD.t()]
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
