From a634fff7170727d6e5a6a8ccbb6cf78aca26d9b2 Mon Sep 17 00:00:00 2001 From: Matt Siwiec Date: Fri, 25 Aug 2023 17:01:03 +0000 Subject: [PATCH] relationships Signed-off-by: Matt Siwiec --- go.sum | 8 ++++++++ internal/ent/schema/origin.go | 1 - internal/ent/schema/pool.go | 2 +- internal/ent/schema/port.go | 1 - internal/ent/schema/provider.go | 3 +++ internal/manualhooks/hooks.go | 27 ++++++--------------------- 6 files changed, 18 insertions(+), 24 deletions(-) diff --git a/go.sum b/go.sum index 1e68b289e..e5206e4af 100644 --- a/go.sum +++ b/go.sum @@ -100,6 +100,7 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= @@ -400,6 +401,8 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= +github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sebdah/goldie/v2 v2.5.3 h1:9ES/mNN+HNUbNWpVAlrzuZ7jE+Nrczbj8uFRjM7624Y= @@ -448,6 +451,9 @@ github.com/testcontainers/testcontainers-go v0.21.0 h1:syePAxdeTzfkap+RrJaQZpJQ/ github.com/testcontainers/testcontainers-go v0.21.0/go.mod h1:c1ez3WVRHq7T/Aj+X3TIipFBwkBaNT5iNCY8+1b83Ng= github.com/testcontainers/testcontainers-go/modules/postgres v0.21.0 h1:rFPyTR7pPMiHcDktXwd5iZ+mA1cHH/WRa+knxBcY8wU= github.com/testcontainers/testcontainers-go/modules/postgres v0.21.0/go.mod h1:Uoia8PX1RewxkJTbeXGBK6vgMjlmRbnL/4n0EXH2Z54= +github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo= +github.com/urfave/cli/v2 v2.25.5 h1:d0NIAyhh5shGscroL7ek/Ya9QYQE0KNabJgiUinIQkc= +github.com/urfave/cli/v2 v2.25.5/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= @@ -463,6 +469,8 @@ github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vb github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/wundergraph/graphql-go-tools v1.62.3 h1:WKpkhKqWoTq/AE0AbrZ+66ezUe3l/wAqZZurZeL5qqQ= github.com/wundergraph/graphql-go-tools v1.62.3/go.mod h1:Lsg/b4nVfNQLyJE1mjPV73O/JuhhCxH5qmaWQjitVHM= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/internal/ent/schema/origin.go b/internal/ent/schema/origin.go index 0d79cc486..bb393c5be 100644 --- a/internal/ent/schema/origin.go +++ b/internal/ent/schema/origin.go @@ -63,7 +63,6 @@ func (Origin) Fields() []ent.Field { Annotations( entgql.Type("ID"), entgql.Skip(entgql.SkipWhereInput, entgql.SkipMutationUpdateInput), - pubsubinfo.EventsHookAdditionalSubject("loadbalancerorigin"), ), } } diff --git a/internal/ent/schema/pool.go b/internal/ent/schema/pool.go index 6378db0d8..98432e28d 100644 --- a/internal/ent/schema/pool.go +++ b/internal/ent/schema/pool.go @@ -51,7 +51,7 @@ func (Pool) Fields() []ent.Field { Annotations( entgql.Type("ID"), entgql.Skip(entgql.SkipWhereInput, entgql.SkipMutationUpdateInput), - pubsubinfo.EventsHookAdditionalSubject("loadbalancerpool"), + pubsubinfo.EventsHookAdditionalSubject("owner"), ), } } diff --git a/internal/ent/schema/port.go b/internal/ent/schema/port.go index b5aa94545..b13e64c2f 100644 --- a/internal/ent/schema/port.go +++ b/internal/ent/schema/port.go @@ -57,7 +57,6 @@ func (Port) Fields() []ent.Field { Annotations( entgql.Type("ID"), entgql.Skip(entgql.SkipWhereInput, entgql.SkipMutationUpdateInput), - pubsubinfo.EventsHookAdditionalSubject("loadbalancer"), ), } } diff --git a/internal/ent/schema/provider.go b/internal/ent/schema/provider.go index a486b3bdb..2b2d9ce52 100644 --- a/internal/ent/schema/provider.go +++ b/internal/ent/schema/provider.go @@ -9,6 +9,8 @@ import ( "entgo.io/ent/schema/index" "go.infratographer.com/x/entx" "go.infratographer.com/x/gidx" + + "go.infratographer.com/load-balancer-api/x/pubsubinfo" ) // Provider holds the schema definition for the LoadBalancerProvider entity. @@ -51,6 +53,7 @@ func (Provider) Fields() []ent.Field { entgql.Type("ID"), entgql.Skip(entgql.SkipWhereInput, entgql.SkipMutationUpdateInput, entgql.SkipType), entgql.OrderField("OWNER"), + pubsubinfo.EventsHookAdditionalSubject("owner"), ), } } diff --git a/internal/manualhooks/hooks.go b/internal/manualhooks/hooks.go index 69dfe02e9..6d5a5cdd1 100644 --- a/internal/manualhooks/hooks.go +++ b/internal/manualhooks/hooks.go @@ -468,11 +468,6 @@ func OriginHooks() []ent.Hook { } additionalSubjects = append(additionalSubjects, pool_id) - relationships = append(relationships, events.AuthRelationshipRelation{ - Relation: "loadbalancerorigin", - SubjectID: pool_id, - }) - if ok { cv_pool_id = fmt.Sprintf("%s", fmt.Sprint(pool_id)) pv_pool_id := "" @@ -548,11 +543,6 @@ func OriginHooks() []ent.Hook { } } - relationships = append(relationships, events.AuthRelationshipRelation{ - Relation: "loadbalancerorigin", - SubjectID: dbObj.PoolID, - }) - // we have all the info we need, now complete the mutation before we process the event retValue, err := next.Mutate(ctx, m) if err != nil { @@ -721,7 +711,7 @@ func PoolHooks() []ent.Hook { additionalSubjects = append(additionalSubjects, owner_id) relationships = append(relationships, events.AuthRelationshipRelation{ - Relation: "loadbalancerpool", + Relation: "owner", SubjectID: owner_id, }) @@ -801,7 +791,7 @@ func PoolHooks() []ent.Hook { additionalSubjects = append(additionalSubjects, dbObj.OwnerID) relationships = append(relationships, events.AuthRelationshipRelation{ - Relation: "loadbalancerpool", + Relation: "owner", SubjectID: dbObj.OwnerID, }) @@ -975,11 +965,6 @@ func PortHooks() []ent.Hook { } additionalSubjects = append(additionalSubjects, load_balancer_id) - relationships = append(relationships, events.AuthRelationshipRelation{ - Relation: "loadbalancer", - SubjectID: load_balancer_id, - }) - if ok { cv_load_balancer_id = fmt.Sprintf("%s", fmt.Sprint(load_balancer_id)) pv_load_balancer_id := "" @@ -1048,10 +1033,10 @@ func PortHooks() []ent.Hook { additionalSubjects = append(additionalSubjects, dbObj.LoadBalancerID) - relationships = append(relationships, events.AuthRelationshipRelation{ - Relation: "loadbalancer", - SubjectID: dbObj.LoadBalancerID, - }) + // relationships = append(relationships, events.AuthRelationshipRelation{ + // Relation: "owner", + // SubjectID: dbObj, + // }) addSubjLoadBalancer, err := m.Client().LoadBalancer.Get(ctx, dbObj.LoadBalancerID) if err != nil {