(ctx context.Context, backendType, secretID string, orgID uuid.UUID, w io.Writer, digest string)
| 128 | } |
| 129 | |
| 130 | func (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 |
| 153 | func (uc *CASClientUseCase) casAPIClient(backendRef *CASCredsOpts) (casclient.DownloaderUploader, func(), error) { |
nothing calls this directly
no test coverage detected