Skip to content

Commit 682eb17

Browse files
authored
feat(third-party-integrations): generic dispatcher (#142)
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
1 parent 3c8422f commit 682eb17

File tree

16 files changed

+683
-261
lines changed

16 files changed

+683
-261
lines changed

app/controlplane/cmd/wire.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ package main
2222

2323
import (
2424
"github.com/chainloop-dev/chainloop/app/controlplane/internal/biz"
25-
"github.com/chainloop-dev/chainloop/app/controlplane/internal/biz/integration"
2625
"github.com/chainloop-dev/chainloop/app/controlplane/internal/conf"
2726
"github.com/chainloop-dev/chainloop/app/controlplane/internal/data"
27+
"github.com/chainloop-dev/chainloop/app/controlplane/internal/dispatcher"
2828
"github.com/chainloop-dev/chainloop/app/controlplane/internal/server"
2929
"github.com/chainloop-dev/chainloop/app/controlplane/internal/service"
3030
backend "github.com/chainloop-dev/chainloop/internal/blobmanager"
@@ -41,7 +41,6 @@ func wireApp(*conf.Bootstrap, credentials.ReaderWriter, log.Logger) (*app, func(
4141
server.ProviderSet,
4242
data.ProviderSet,
4343
biz.ProviderSet,
44-
integration.ProviderSet,
4544
service.ProviderSet,
4645
wire.Bind(new(backend.Provider), new(*oci.BackendProvider)),
4746
wire.Bind(new(biz.CASClient), new(*biz.CASClientUseCase)),
@@ -50,6 +49,7 @@ func wireApp(*conf.Bootstrap, credentials.ReaderWriter, log.Logger) (*app, func(
5049
wire.Value([]biz.CASClientOpts{}),
5150
wire.FieldsOf(new(*conf.Bootstrap), "Server", "Auth", "Data", "CasServer"),
5251
loadIntegrations,
52+
dispatcher.New,
5353
newApp,
5454
),
5555
)

app/controlplane/cmd/wire_gen.go

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/integrations/sdk/v1/mocks/Custom.go

Lines changed: 99 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/internal/biz/integration.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (uc *IntegrationUseCase) RegisterAndSave(ctx context.Context, orgID string,
117117
}
118118

119119
// Persist the integration configuration
120-
return uc.integrationRepo.Create(ctx, orgUUID, preRegistration.Kind, secretID, config)
120+
return uc.integrationRepo.Create(ctx, orgUUID, i.Describe().ID, secretID, config)
121121
}
122122

123123
type AttachOpts struct {
@@ -251,6 +251,7 @@ func (uc *IntegrationUseCase) Delete(ctx context.Context, orgID, integrationID s
251251
return uc.integrationRepo.SoftDelete(ctx, integrationUUID)
252252
}
253253

254+
// List attachments returns the list of attachments for a given organization and optionally workflow
254255
func (uc *IntegrationUseCase) ListAttachments(ctx context.Context, orgID, workflowID string) ([]*IntegrationAttachment, error) {
255256
orgUUID, err := uuid.Parse(orgID)
256257
if err != nil {
@@ -264,6 +265,15 @@ func (uc *IntegrationUseCase) ListAttachments(ctx context.Context, orgID, workfl
264265
if err != nil {
265266
return nil, NewErrInvalidUUID(err)
266267
}
268+
269+
// We check that the workflow belongs to the provided organization
270+
// This check is mostly informative to the user
271+
wf, err := uc.workflowRepo.GetOrgScoped(ctx, orgUUID, workflowUUID)
272+
if err != nil {
273+
return nil, err
274+
} else if wf == nil {
275+
return nil, NewErrNotFound("workflow")
276+
}
267277
}
268278

269279
return uc.integrationARepo.List(ctx, orgUUID, workflowUUID)

app/controlplane/internal/biz/integration/dependencytrack/dependencytrack.go

Lines changed: 0 additions & 182 deletions
This file was deleted.

0 commit comments

Comments
 (0)