Skip to content

Commit

Permalink
chore(seeds): reconcile tenant when seeding
Browse files Browse the repository at this point in the history
- Reconciling tenant is done directly in seeds when it gets created
- Edgehog in 5 minutes does no longer instruct users to manually
  reconcile the tenant with astarte

Signed-off-by: Luca Zaninotto <[email protected]>
  • Loading branch information
lusergit committed Dec 9, 2024
1 parent 1537d42 commit 323f422
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
12 changes: 7 additions & 5 deletions backend/priv/repo/seeds.exs
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,20 @@ tenant =
{status, realm_pk} =
read_key!.("SEEDS_REALM_PRIVATE_KEY_FILE", "SEEDS_REALM_ORIGINAL_FILE", "realm_private")

Astarte.create_realm!(
%{cluster_id: cluster.id, name: read_env_var.("SEEDS_REALM"), private_key: realm_pk},
tenant: tenant
)

if status == :default do
"""
You are using the default realm private key. \
This instance will not be able to connect to Astarte.
"""
|> String.trim_trailing("\n")
|> Logger.warning()
else
Edgehog.Tenants.reconcile_tenant(tenant)
end

Astarte.create_realm!(
%{cluster_id: cluster.id, name: read_env_var.("SEEDS_REALM"), private_key: realm_pk},
tenant: tenant
)

:ok
8 changes: 0 additions & 8 deletions doc/pages/tutorials/edgehog_in_5_minutes.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,6 @@ You can finally navigate to `http://edgehog.localhost` in your browser and login
## Test Astarte connection
Astarte connectivity may not work right away, as edgehog has not yet reconciled
its interfaces and triggers with astarte. Without waiting, we can force it to execute
the reconciler using:
```sh
$ docker compose exec edgehog-backend bin/edgehog rpc "Edgehog.Tenants.list_tenants |> Enum.each(&Edgehog.Tenants.reconcile_tenant/1)"
```
If you now connect a device to astarte and open or reload the edgehog web page,
you should see the new device in the appropriate section.
Expand Down

0 comments on commit 323f422

Please sign in to comment.