MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / Download

Method Download

app/controlplane/pkg/biz/casclient.go:130–150  ·  view source on GitHub ↗
(ctx context.Context, backendType, secretID string, orgID uuid.UUID, w io.Writer, digest string)

Source from the content-addressed store, hash-verified

128}
129
130func (uc *CASClientUseCase) Download(ctx context.Context, backendType, secretID string, orgID uuid.UUID, w io.Writer, digest string) error {
131 ctx, span := otelx.Start(ctx, casClientTracer, "CASClientUseCase.Download")
132 defer span.End()
133
134 uc.logger.Infow("msg", "download initialized", "digest", digest)
135
136 // SourceInternal flags this as the control plane's own traffic so the CAS doesn't emit audit events for it
137 client, closeFn, err := uc.casAPIClient(&CASCredsOpts{BackendType: backendType, SecretPath: secretID, Role: casJWT.Downloader, OrgID: orgID, SourceInternal: true})
138 if err != nil {
139 return fmt.Errorf("failed to create cas client: %w", err)
140 }
141 defer closeFn()
142
143 if err := client.Download(ctx, w, digest); err != nil {
144 return fmt.Errorf("failed to download content: %w", err)
145 }
146
147 uc.logger.Infow("msg", "download finalized", "digest", digest)
148
149 return nil
150}
151
152// create a client with a temporary set of credentials for a specific operation
153func (uc *CASClientUseCase) casAPIClient(backendRef *CASCredsOpts) (casclient.DownloaderUploader, func(), error) {

Callers

nothing calls this directly

Calls 4

casAPIClientMethod · 0.95
StartFunction · 0.92
InfowMethod · 0.65
DownloadMethod · 0.65

Tested by

no test coverage detected