Skip to content
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
19 changes: 7 additions & 12 deletions app/controlplane/pkg/data/casbackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (r *CASBackendRepo) List(ctx context.Context, orgID uuid.UUID) ([]*biz.CASB
ctx, span := otelx.Start(ctx, casBackendRepoTracer, "CASBackendRepo.List")
defer span.End()

backends, err := orgScopedQuery(r.data.DB, orgID).QueryCasBackends().WithOrganization().
backends, err := orgScopedQuery(r.data.DB, orgID).QueryCasBackends().
Where(casbackend.DeletedAtIsNil()).
Order(ent.Desc(casbackend.FieldCreatedAt)).
All(ctx)
Expand All @@ -68,7 +68,7 @@ func (r *CASBackendRepo) FindDefaultBackend(ctx context.Context, orgID uuid.UUID
ctx, span := otelx.Start(ctx, casBackendRepoTracer, "CASBackendRepo.FindDefaultBackend")
defer span.End()

backend, err := orgScopedQuery(r.data.DB, orgID).QueryCasBackends().WithOrganization().
backend, err := orgScopedQuery(r.data.DB, orgID).QueryCasBackends().
Where(casbackend.Default(true), casbackend.DeletedAtIsNil()).
Only(ctx)
if err != nil && !ent.IsNotFound(err) {
Expand All @@ -83,7 +83,7 @@ func (r *CASBackendRepo) FindFallbackBackend(ctx context.Context, orgID uuid.UUI
ctx, span := otelx.Start(ctx, casBackendRepoTracer, "CASBackendRepo.FindFallbackBackend")
defer span.End()

backend, err := orgScopedQuery(r.data.DB, orgID).QueryCasBackends().WithOrganization().
backend, err := orgScopedQuery(r.data.DB, orgID).QueryCasBackends().
Where(casbackend.Fallback(true), casbackend.DeletedAtIsNil()).
Only(ctx)
if err != nil && !ent.IsNotFound(err) {
Expand All @@ -98,7 +98,7 @@ func (r *CASBackendRepo) FindInlineBackend(ctx context.Context, orgID uuid.UUID)
ctx, span := otelx.Start(ctx, casBackendRepoTracer, "CASBackendRepo.FindInlineBackend")
defer span.End()

backend, err := orgScopedQuery(r.data.DB, orgID).QueryCasBackends().WithOrganization().
backend, err := orgScopedQuery(r.data.DB, orgID).QueryCasBackends().
Where(casbackend.ProviderEQ(biz.CASBackendInline), casbackend.DeletedAtIsNil()).
Only(ctx)
if err != nil && !ent.IsNotFound(err) {
Expand Down Expand Up @@ -264,7 +264,7 @@ func (r *CASBackendRepo) FindByID(ctx context.Context, id uuid.UUID) (*biz.CASBa
ctx, span := otelx.Start(ctx, casBackendRepoTracer, "CASBackendRepo.FindByID")
defer span.End()

backend, err := r.data.DB.CASBackend.Query().WithOrganization().
backend, err := r.data.DB.CASBackend.Query().
Where(casbackend.ID(id), casbackend.DeletedAtIsNil()).Only(ctx)
if err != nil && !ent.IsNotFound(err) {
return nil, err
Expand All @@ -281,7 +281,7 @@ func (r *CASBackendRepo) FindByIDInOrg(ctx context.Context, orgID, id uuid.UUID)
ctx, span := otelx.Start(ctx, casBackendRepoTracer, "CASBackendRepo.FindByIDInOrg")
defer span.End()

backend, err := orgScopedQuery(r.data.DB, orgID).QueryCasBackends().WithOrganization().
backend, err := orgScopedQuery(r.data.DB, orgID).QueryCasBackends().
Where(casbackend.ID(id), casbackend.DeletedAtIsNil()).Only(ctx)
if err != nil && !ent.IsNotFound(err) {
return nil, err
Expand All @@ -298,7 +298,6 @@ func (r *CASBackendRepo) FindByNameInOrg(ctx context.Context, orgID uuid.UUID, n

backend, err := orgScopedQuery(r.data.DB, orgID).
QueryCasBackends().
WithOrganization().
Where(casbackend.Name(name), casbackend.DeletedAtIsNil()).Only(ctx)
if err != nil {
if ent.IsNotFound(err) {
Expand Down Expand Up @@ -352,7 +351,6 @@ func (r *CASBackendRepo) ListBackends(ctx context.Context, defaultsOrFallbacks b
defer span.End()

query := r.data.DB.CASBackend.Query().
WithOrganization().
Where(casbackend.DeletedAtIsNil(),
casbackend.ProviderNEQ(biz.CASBackendInline),
casbackend.HasOrganizationWith(
Expand Down Expand Up @@ -406,10 +404,7 @@ func entCASBackendToBiz(backend *ent.CASBackend) *biz.CASBackend {
Limits: limits,
Fallback: backend.Fallback,
Managed: backend.Managed,
}

if org := backend.Edges.Organization; org != nil {
r.OrganizationID = org.ID
OrganizationID: backend.OrganizationCasBackends,
}

return r
Expand Down
23 changes: 12 additions & 11 deletions app/controlplane/pkg/data/ent/casbackend.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions app/controlplane/pkg/data/ent/casbackend/casbackend.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions app/controlplane/pkg/data/ent/casbackend/where.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 50 additions & 1 deletion app/controlplane/pkg/data/ent/casbackend_create.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 4 additions & 12 deletions app/controlplane/pkg/data/ent/casbackend_query.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading