From 407a3f2356a8042c07c390d275dc2fa30725dd82 Mon Sep 17 00:00:00 2001 From: Kian Parvin Date: Mon, 28 Aug 2023 15:48:42 +0200 Subject: [PATCH] Fixes for migration and OpenFGA port --- docker-compose.yaml | 3 ++- internal/dbmodel/sql/postgres/1_3.sql | 13 ++++++------- service.go | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index b68fc3994..4b3858efe 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -69,7 +69,8 @@ services: PUBLIC_KEY: "izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=" PRIVATE_KEY: "ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=" OPENFGA_SCHEME: "http" - OPENFGA_HOST: "openfga:8080" + OPENFGA_HOST: "openfga" + OPENFGA_PORT: 8080 OPENFGA_STORE: "01GP1254CHWJC1MNGVB0WDG1T0" OPENFGA_AUTH_MODEL: "01GP1EC038KHGB6JJ2XXXXCXKB" OPENFGA_TOKEN: "jimm" diff --git a/internal/dbmodel/sql/postgres/1_3.sql b/internal/dbmodel/sql/postgres/1_3.sql index 922264725..5d64bdfc8 100644 --- a/internal/dbmodel/sql/postgres/1_3.sql +++ b/internal/dbmodel/sql/postgres/1_3.sql @@ -1,11 +1,10 @@ -- 1_3.sql is a migration that alters the foreign key relationship `cloud_credentials.cloud_name -> clouds.name` to a cascade on-delete. -alter table cloud_credentials -drop constraint cloud_credentials_cloud_name_fkey, -add constraint cloud_credentials_cloud_name_fkey - foreign key (cloud_name) - references clouds(name) - on delete cascade; -ALTER TABLE +ALTER TABLE cloud_credentials + DROP CONSTRAINT cloud_credentials_cloud_name_fkey, + ADD CONSTRAINT cloud_credentials_cloud_name_fkey + FOREIGN KEY (cloud_name) + REFERENCES clouds(name) + ON DELETE CASCADE; UPDATE versions SET major=1, minor=3 WHERE component='jimmdb'; diff --git a/service.go b/service.go index 1825a9429..1d2abe339 100644 --- a/service.go +++ b/service.go @@ -534,6 +534,7 @@ func newVaultStore(ctx context.Context, p Params) (jimmcreds.CredentialStore, er } func newOpenFGAClient(ctx context.Context, p OpenFGAParams) (*openfga.OFGAClient, error) { + const op = errors.Op("newOpenFGAClient") cofgaClient, err := cofga.NewClient(ctx, cofga.OpenFGAParams{ Scheme: p.Scheme, Host: p.Host, @@ -543,7 +544,7 @@ func newOpenFGAClient(ctx context.Context, p OpenFGAParams) (*openfga.OFGAClient AuthModelID: p.AuthModel, }) if err != nil { - return nil, errors.E(err, "failed to create ofga client") + return nil, errors.E(op, err) } return openfga.NewOpenFGAClient(cofgaClient), nil }