Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Bonny 1.1.0 #140

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ defmodule Mix.Tasks.Bonny.Gen.Manifest.SpawnOperatorCustomizer do
def override(%{kind: "ServiceAccount"} = resource) do
put_in(resource, ~w(metadata labels foo)a, "bar")
end
"""

@spec override(Bonny.Resource.t()) :: Bonny.Resource.t()

@doc """
This function generated Deployment manifest like bellow:
If kind is equal to Deployment then this function generated Deployment manifest like bellow:

```yaml
%{
Expand Down Expand Up @@ -83,9 +79,9 @@ defmodule Mix.Tasks.Bonny.Gen.Manifest.SpawnOperatorCustomizer do
}
}
}
}
```
"""

@spec override(Bonny.Resource.t()) :: Bonny.Resource.t()
def override(%{kind: "Deployment"} = resource) do
%{resource | spec: %{resource.spec | template: update_template(resource)}}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ defmodule SpawnOperator.K8s.ConfigMap.ActivatorCM do
@moduledoc false

@behaviour SpawnOperator.K8s.Manifest

@impl true
def manifest(_resource, _opts \\ []), do: %{}
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ defmodule SpawnOperator.K8s.ConfigMap.SidecarCM do

@behaviour SpawnOperator.K8s.Manifest

@impl true
def manifest(resource, _opts \\ []), do: gen_configmap(resource)

@doc """
ConfigMap is generated using following CRD labels:

Expand Down Expand Up @@ -72,6 +69,9 @@ defmodule SpawnOperator.K8s.ConfigMap.SidecarCM do
# Optional. Default ""
spawn-eigr.io/sidecar-pubsub-nats-auth-jwt: ""
"""
@impl true
def manifest(resource, _opts \\ []), do: gen_configmap(resource)

defp gen_configmap(
%{
system: system,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmodule SpawnOperator.K8s.Secret.ActorSystemSecret do
}
end

defp get_storage_options(_system, ns, params) do
defp get_storage_options(_system, _ns, params) do
statestore = String.downcase(Map.get(params, "type", "native")) |> Base.encode64()
pool_params = Map.get(params, "pool", %{})
pool_size = Map.get(pool_params, "size", "10") |> Base.encode64()
Expand Down
9 changes: 6 additions & 3 deletions spawn_operator/spawn_operator/lib/spawn_operator/k8s_conn.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ defmodule SpawnOperator.K8sConn do
@spec get(atom()) :: K8s.Conn.t()
def get(:dev) do
{:ok, conn} = K8s.Conn.from_file("~/.kube/config", context: "k3d-eigr-spawn")
conn
struct!(conn, insecure_skip_tls_verify: true)
end

def get(:test),
do: %K8s.Conn{
def get(:test) do
conn = %K8s.Conn{
discovery_driver: K8s.Discovery.Driver.File,
discovery_opts: [config: "test/support/discovery.json"],
http_provider: K8s.Client.DynamicHTTPProvider
}

struct!(conn, insecure_skip_tls_verify: true)
end

def get(_) do
K8s.Conn.from_service_account()
|> then(fn
Expand Down
6 changes: 3 additions & 3 deletions spawn_operator/spawn_operator/lib/spawn_operator/operator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ defmodule SpawnOperator.Operator do
def controllers(watch_namespace, _opts) do
[
%{
query: K8s.Client.list("spawn-eigr.io/v1", "Activator", namespace: watch_namespace),
query: K8s.Client.watch("spawn-eigr.io/v1", "Activator", namespace: watch_namespace),
controller: SpawnOperator.Controller.ActivatorController
},
%{
query: K8s.Client.list("spawn-eigr.io/v1", "ActorHost", namespace: watch_namespace),
query: K8s.Client.watch("spawn-eigr.io/v1", "ActorHost", namespace: watch_namespace),
controller: SpawnOperator.Controller.ActorHostController
},
%{
query: K8s.Client.list("spawn-eigr.io/v1", "ActorSystem", namespace: watch_namespace),
query: K8s.Client.watch("spawn-eigr.io/v1", "ActorSystem", namespace: watch_namespace),
controller: SpawnOperator.Controller.ActorSystemController
}
]
Expand Down
2 changes: 1 addition & 1 deletion spawn_operator/spawn_operator/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ defmodule Operator.MixProject do
[
{:bandit, "~> 0.5"},
{:bakeware, ">= 0.0.0", runtime: false},
{:bonny, "~> 1.0.0"},
{:bonny, "~> 1.1.0"},
{:spawn, path: "../../"}
]
end
Expand Down