Skip to content

Commit bdd2536

Browse files
committed
update externalinvocation
1 parent be07ca5 commit bdd2536

File tree

10 files changed

+47
-31
lines changed

10 files changed

+47
-31
lines changed

docs/getting_started.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,12 @@ metadata:
251251
name: spawn-system # 1. Required. Name of the ActorSystem
252252
namespace: default # 2. Optional. Default namespace is "default"
253253
spec:
254-
# This externalInvocation section is required only if using the Nats broker in your project.
255-
externalInvocation:
256-
enabled: "true"
257-
externalConnectorRef: nats-invocation-conn-secret # 3. Nats broker credentials
254+
cluster:
255+
features:
256+
# This nats section is required only if using the Nats broker in your project.
257+
nats:
258+
enabled: true
259+
credentialsSecretRef: "nats-invocation-conn-secret" # 3. Nats broker credentials
258260
statestore:
259261
type: MariaDB # 4. Set database provider. Valid options: [MariaDB, Postgres, Native]
260262
credentialsSecretRef: mariadb-connection-secret # 5. Secret with database connection details created earlier

examples/activators/cron.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ metadata:
1010
spec:
1111
activator:
1212
type: Cron
13-
externalConnectorRef: invocation-connection-ref-secret
13+
externalConnectorRef: nats-invocation-conn-secret
1414
bindings:
1515
sources:
1616
- name: minute-scheduler

examples/secret/invocation-connection-secret-example.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
kubectl -n default create secret generic invocation-connection-ref-secret \
1+
kubectl -n default create secret generic nats-invocation-conn-secret \
22
--from-literal=url=spawn-nats:4222 \
33
--from-literal=authEnabled="false" \
44
--from-literal=tlsEnabled="false" \

examples/security/acl/system.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ metadata:
55
name: spawn-system # Mandatory. Name of the state store
66
namespace: default # Optional. Default namespace is "default"
77
spec:
8-
externalInvocation:
9-
enabled: "true"
10-
externalConnectorRef: invocation-connection-ref-secret
8+
cluster:
9+
features:
10+
nats:
11+
enabled: true
12+
credentialsSecretRef: "nats-invocation-conn-secret"
1113
statestore:
1214
type: MySql
1315
credentialsSecretRef: mysql-connection-secret # The secret containing connection params

examples/security/authentication/basic/system.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ metadata:
55
name: spawn-system # Mandatory. Name of the state store
66
namespace: default # Optional. Default namespace is "default"
77
spec:
8-
externalInvocation:
9-
enabled: "true"
10-
externalConnectorRef: invocation-connection-ref-secret
8+
cluster:
9+
features:
10+
nats:
11+
enabled: true
12+
credentialsSecretRef: "nats-invocation-conn-secret" # 3. Nats broker credentials
1113
statestore:
1214
type: MySql
1315
credentialsSecretRef: mysql-connection-secret # The secret containing connection params

examples/security/authentication/jwt/system.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ metadata:
55
name: spawn-system # Mandatory. Name of the state store
66
namespace: default # Optional. Default namespace is "default"
77
spec:
8-
externalInvocation:
9-
enabled: "true"
10-
externalConnectorRef: invocation-connection-ref-secret
8+
cluster:
9+
features:
10+
nats:
11+
enabled: true
12+
credentialsSecretRef: "nats-invocation-conn-secret" # 3. Nats broker credentials
1113
statestore:
1214
type: MySql
1315
credentialsSecretRef: mysql-connection-secret # The secret containing connection params

examples/simple/system.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ metadata:
55
name: spawn-system # Mandatory. Name of the state store
66
namespace: default # Optional. Default namespace is "default"
77
spec:
8-
# externalInvocation:
9-
# enabled: "true"
10-
# externalConnectorRef: invocation-connection-ref-secret
8+
# cluster:
9+
# features:
10+
# nats:
11+
# enabled: true
12+
# credentialsSecretRef: "nats-invocation-conn-secret" # 3. Nats broker credentials
1113
statestore:
1214
type: "MariaDB"
1315
credentialsSecretRef: "mariadb-connection-secret" # The secret containing connection params

examples/topology/system.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ metadata:
55
name: spawn-system # Mandatory. Name of the state store
66
namespace: default # Optional. Default namespace is "default"
77
spec:
8-
externalInvocation:
9-
enabled: "true"
10-
externalConnectorRef: invocation-connection-ref-secret
8+
cluster:
9+
features:
10+
nats:
11+
enabled: true
12+
credentialsSecretRef: "nats-invocation-conn-secret" # 3. Nats broker credentials
1113
statestore:
1214
type: MySql
1315
credentialsSecretRef: mysql-connection-secret # The secret containing connection params

spawn_operator/spawn_operator/lib/spawn_operator/k8s/system/secret/actor_system_secret.ex

+9-7
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,18 @@ defmodule SpawnOperator.K8s.System.Secret.ActorSystemSecret do
121121
end
122122

123123
defp maybe_use_nats_cluster(config, _name, namespace, params) do
124-
nats_params = Map.get(params, "externalInvocation", %{})
125-
enabled = Map.get(nats_params, "enabled", "false")
124+
cluster_params = Map.get(params, "cluster", %{})
125+
features = Map.get(cluster_params, "features", %{})
126+
nats_params = Map.get(features, "nats", %{})
127+
enabled = "#{Map.get(nats_params, "enabled", false)}"
126128

127129
nats_config =
128130
case enabled do
129131
"false" ->
130132
%{}
131133

132134
"true" ->
133-
nats_secret_ref = Map.fetch!(nats_params, "externalConnectorRef")
135+
nats_secret_ref = Map.fetch!(nats_params, "credentialsSecretRef")
134136

135137
{:ok, secret} =
136138
K8s.Client.get("v1", :secret,
@@ -139,11 +141,11 @@ defmodule SpawnOperator.K8s.System.Secret.ActorSystemSecret do
139141
)
140142
|> then(&K8s.Client.run(conn(), &1))
141143

142-
secret_data = Map.fetch!(secret, "data")
143-
nats_host_url = Map.fetch!(secret_data, "url")
144+
secret_data = Map.get(secret, "data")
145+
nats_host_url = Map.get(secret_data, "url", nats_params["url"])
144146
nats_auth = Map.get(secret_data, "authEnabled", "false")
145-
nats_user = Map.fetch!(secret_data, "username")
146-
nats_secret = Map.fetch!(secret_data, "password")
147+
nats_user = Map.get(secret_data, "username")
148+
nats_secret = Map.get(secret_data, "password")
147149
nats_tls = Map.get(secret_data, "tlsEnabled", "false")
148150

149151
%{

spawnctl/.k8s/example/system.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ metadata:
55
name: spawn-system
66
namespace: default
77
spec:
8-
externalInvocation:
9-
enabled: "false"
10-
externalConnectorRef: invocation-connection-ref-secret
8+
cluster:
9+
features:
10+
nats:
11+
enabled: true
12+
credentialsSecretRef: "nats-invocation-conn-secret" # 3. Nats broker credentials
1113
statestore:
1214
type: MySql
1315
credentialsSecretRef: mysql-connection-secret

0 commit comments

Comments
 (0)